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
0cc7d8df
Commit
0cc7d8df
authored
May 01, 2013
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow empty dirs to exist when doing checkout
parent
e1807113
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletions
+30
-1
src/checkout.c
+5
-1
tests-clar/checkout/tree.c
+25
-0
No files found.
src/checkout.c
View file @
0cc7d8df
...
@@ -467,6 +467,7 @@ static int checkout_action(
...
@@ -467,6 +467,7 @@ static int checkout_action(
int
cmp
=
-
1
,
act
;
int
cmp
=
-
1
,
act
;
int
(
*
strcomp
)(
const
char
*
,
const
char
*
)
=
data
->
diff
->
strcomp
;
int
(
*
strcomp
)(
const
char
*
,
const
char
*
)
=
data
->
diff
->
strcomp
;
int
(
*
pfxcomp
)(
const
char
*
str
,
const
char
*
pfx
)
=
data
->
diff
->
pfxcomp
;
int
(
*
pfxcomp
)(
const
char
*
str
,
const
char
*
pfx
)
=
data
->
diff
->
pfxcomp
;
int
error
;
/* move workdir iterator to follow along with deltas */
/* move workdir iterator to follow along with deltas */
...
@@ -490,8 +491,11 @@ static int checkout_action(
...
@@ -490,8 +491,11 @@ static int checkout_action(
if
(
cmp
==
0
)
{
if
(
cmp
==
0
)
{
if
(
wd
->
mode
==
GIT_FILEMODE_TREE
)
{
if
(
wd
->
mode
==
GIT_FILEMODE_TREE
)
{
/* case 2 - entry prefixed by workdir tree */
/* case 2 - entry prefixed by workdir tree */
if
(
git_iterator_advance_into
(
&
wd
,
workdir
)
<
0
)
if
((
error
=
git_iterator_advance_into
(
&
wd
,
workdir
))
<
0
)
{
if
(
error
!=
GIT_ENOTFOUND
||
git_iterator_advance
(
&
wd
,
workdir
)
<
0
)
goto
fail
;
goto
fail
;
}
*
wditem_ptr
=
wd
;
*
wditem_ptr
=
wd
;
continue
;
continue
;
...
...
tests-clar/checkout/tree.c
View file @
0cc7d8df
...
@@ -501,3 +501,28 @@ void test_checkout_tree__issue_1397(void)
...
@@ -501,3 +501,28 @@ void test_checkout_tree__issue_1397(void)
git_object_free
(
tree
);
git_object_free
(
tree
);
}
}
void
test_checkout_tree__can_write_to_empty_dirs
(
void
)
{
git_checkout_opts
opts
=
GIT_CHECKOUT_OPTS_INIT
;
git_oid
oid
;
git_object
*
obj
=
NULL
;
assert_on_branch
(
g_repo
,
"master"
);
cl_git_pass
(
p_mkdir
(
"testrepo/a"
,
0777
));
/* do first checkout with FORCE because we don't know if testrepo
* base data is clean for a checkout or not
*/
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
cl_git_pass
(
git_reference_name_to_id
(
&
oid
,
g_repo
,
"refs/heads/dir"
));
cl_git_pass
(
git_object_lookup
(
&
obj
,
g_repo
,
&
oid
,
GIT_OBJ_ANY
));
cl_git_pass
(
git_checkout_tree
(
g_repo
,
obj
,
&
opts
));
cl_assert
(
git_path_isfile
(
"testrepo/a/b.txt"
));
git_object_free
(
obj
);
}
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