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
9f9477d6
Commit
9f9477d6
authored
Feb 27, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1372 from ethomson/checkout_workdir_end
don't dereference at the end of the workdir iterator
parents
c493f821
395509ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
src/checkout.c
+4
-2
tests-clar/checkout/tree.c
+38
-0
No files found.
src/checkout.c
View file @
9f9477d6
...
...
@@ -456,7 +456,7 @@ static int checkout_action(
while
(
1
)
{
if
(
!
wd
)
return
checkout_action_no_wd
(
data
,
delta
);
cmp
=
strcomp
(
wd
->
path
,
delta
->
old_file
.
path
);
/* 1. wd before delta ("a/a" before "a/b")
...
...
@@ -475,6 +475,8 @@ static int checkout_action(
/* case 2 - entry prefixed by workdir tree */
if
(
git_iterator_advance_into_directory
(
workdir
,
&
wd
)
<
0
)
goto
fail
;
*
wditem_ptr
=
wd
;
continue
;
}
...
...
@@ -608,7 +610,7 @@ static int checkout_get_actions(
if
(
act
&
CHECKOUT_ACTION__CONFLICT
)
counts
[
CHECKOUT_ACTION__CONFLICT
]
++
;
}
error
=
checkout_remaining_wd_items
(
data
,
workdir
,
wditem
,
&
pathspec
);
if
(
error
<
0
)
goto
fail
;
...
...
tests-clar/checkout/tree.c
View file @
9f9477d6
...
...
@@ -444,3 +444,41 @@ void test_checkout_tree__checking_out_a_conflicting_content_change_returns_EMERG
assert_conflict
(
"branch_file.txt"
,
"hello
\n
"
,
"5b5b025"
,
"c47800c"
);
}
void
test_checkout_tree__can_checkout_with_last_workdir_item_missing
(
void
)
{
git_index
*
index
=
NULL
;
git_checkout_opts
opts
=
GIT_CHECKOUT_OPTS_INIT
;
git_oid
tree_id
,
commit_id
;
git_tree
*
tree
=
NULL
;
git_commit
*
commit
=
NULL
;
git_repository_index
(
&
index
,
g_repo
);
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
cl_git_pass
(
git_reference_name_to_id
(
&
commit_id
,
g_repo
,
"refs/heads/master"
));
cl_git_pass
(
git_commit_lookup
(
&
commit
,
g_repo
,
&
commit_id
));
cl_git_pass
(
git_checkout_tree
(
g_repo
,
(
git_object
*
)
commit
,
&
opts
));
cl_git_pass
(
git_repository_set_head
(
g_repo
,
"refs/heads/master"
));
cl_git_pass
(
p_mkdir
(
"./testrepo/this-is-dir"
,
0777
));
cl_git_mkfile
(
"./testrepo/this-is-dir/contained_file"
,
"content
\n
"
);
cl_git_pass
(
git_index_add_bypath
(
index
,
"this-is-dir/contained_file"
));
git_index_write_tree
(
&
tree_id
,
index
);
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
tree_id
));
cl_git_pass
(
p_unlink
(
"./testrepo/this-is-dir/contained_file"
));
opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
;
opts
.
checkout_strategy
=
1
;
git_checkout_tree
(
g_repo
,
(
git_object
*
)
tree
,
&
opts
);
git_tree_free
(
tree
);
git_commit_free
(
commit
);
git_index_free
(
index
);
}
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