Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
230010d1
Commit
230010d1
authored
Jan 15, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1238 from nulltoken/fix/checkout-index
checkout: Teach checkout to cope with orphaned Head
parents
848d77dc
5b524d69
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
7 deletions
+21
-7
src/checkout.c
+8
-1
src/diff_output.c
+1
-3
tests-clar/checkout/index.c
+10
-0
tests-clar/checkout/tree.c
+2
-3
No files found.
src/checkout.c
View file @
230010d1
...
...
@@ -1173,7 +1173,14 @@ static int checkout_data_init(
if
(
!
data
->
opts
.
baseline
)
{
data
->
opts_free_baseline
=
true
;
if
((
error
=
checkout_lookup_head_tree
(
&
data
->
opts
.
baseline
,
repo
))
<
0
)
error
=
checkout_lookup_head_tree
(
&
data
->
opts
.
baseline
,
repo
);
if
(
error
==
GIT_EORPHANEDHEAD
)
{
error
=
0
;
giterr_clear
();
}
if
(
error
<
0
)
goto
cleanup
;
}
...
...
src/diff_output.c
View file @
230010d1
...
...
@@ -842,7 +842,7 @@ static int diff_patch_line_cb(
{
git_diff_patch
*
patch
=
payload
;
diff_patch_hunk
*
hunk
;
diff_patch_line
*
l
ast
,
*
l
ine
;
diff_patch_line
*
line
;
GIT_UNUSED
(
delta
);
GIT_UNUSED
(
range
);
...
...
@@ -872,8 +872,6 @@ static int diff_patch_line_cb(
patch
->
lines_asize
=
new_size
;
}
last
=
(
patch
->
lines_size
>
0
)
?
&
patch
->
lines
[
patch
->
lines_size
-
1
]
:
NULL
;
line
=
&
patch
->
lines
[
patch
->
lines_size
++
];
line
->
ptr
=
content
;
...
...
tests-clar/checkout/index.c
View file @
230010d1
...
...
@@ -498,3 +498,13 @@ void test_checkout_index__can_update_prefixed_files(void)
cl_assert
(
!
git_path_exists
(
"testrepo/branch_file"
));
cl_assert
(
!
git_path_exists
(
"testrepo/branch_file.txt.after"
));
}
void
test_checkout_index__can_checkout_a_newly_initialized_repository
(
void
)
{
test_checkout_index__cleanup
();
g_repo
=
cl_git_sandbox_init
(
"empty_standard_repo"
);
cl_git_remove_placeholders
(
git_repository_path
(
g_repo
),
"dummy-marker.txt"
);
cl_git_pass
(
git_checkout_index
(
g_repo
,
NULL
,
NULL
));
}
tests-clar/checkout/tree.c
View file @
230010d1
...
...
@@ -367,7 +367,6 @@ void assert_conflict(
git_object
*
hack_tree
;
git_reference
*
branch
,
*
head
;
git_buf
file_path
=
GIT_BUF_INIT
;
git_checkout_opts
opts
=
GIT_CHECKOUT_OPTS_INIT
;
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
...
...
@@ -383,7 +382,7 @@ void assert_conflict(
git_reference_free
(
branch
);
/* Checkout the parent */
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
g_
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
cl_git_pass
(
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
));
/* Hack-ishy workaound to ensure *all* the index entries
...
...
@@ -403,7 +402,7 @@ void assert_conflict(
/* Trying to checkout the original commit */
cl_git_pass
(
git_revparse_single
(
&
g_object
,
g_repo
,
commit_sha
));
opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
;
g_
opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
;
cl_assert_equal_i
(
GIT_EMERGECONFLICT
,
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment