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
85eb2cb6
Unverified
Commit
85eb2cb6
authored
Aug 26, 2018
by
Edward Thomson
Committed by
GitHub
Aug 26, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4727 from libgit2/cmn/null-oid-existing-tree
tree: accept null ids in existing trees when updating
parents
50186ce8
f00db9ed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
6 deletions
+24
-6
src/tree.c
+8
-6
tests/object/tree/update.c
+16
-0
tests/resources/testrepo2/.gitted/objects/39/6c7f1adb7925f51ba13a75f48252f44c5a14a2
+0
-0
No files found.
src/tree.c
View file @
85eb2cb6
...
...
@@ -460,15 +460,16 @@ static int append_entry(
git_treebuilder
*
bld
,
const
char
*
filename
,
const
git_oid
*
id
,
git_filemode_t
filemode
)
git_filemode_t
filemode
,
bool
validate
)
{
git_tree_entry
*
entry
;
int
error
=
0
;
if
(
!
valid_entry_name
(
bld
->
repo
,
filename
))
if
(
validate
&&
!
valid_entry_name
(
bld
->
repo
,
filename
))
return
tree_error
(
"failed to insert entry: invalid name for a tree entry"
,
filename
);
if
(
git_oid_iszero
(
id
))
if
(
validate
&&
git_oid_iszero
(
id
))
return
tree_error
(
"failed to insert entry: invalid null OID for a tree entry"
,
filename
);
entry
=
alloc_entry
(
filename
,
strlen
(
filename
),
id
);
...
...
@@ -566,12 +567,12 @@ static int write_tree(
last_comp
=
subdir
;
}
error
=
append_entry
(
bld
,
last_comp
,
&
sub_oid
,
S_IFDIR
);
error
=
append_entry
(
bld
,
last_comp
,
&
sub_oid
,
S_IFDIR
,
true
);
git__free
(
subdir
);
if
(
error
<
0
)
goto
on_error
;
}
else
{
error
=
append_entry
(
bld
,
filename
,
&
entry
->
id
,
entry
->
mode
);
error
=
append_entry
(
bld
,
filename
,
&
entry
->
id
,
entry
->
mode
,
true
);
if
(
error
<
0
)
goto
on_error
;
}
...
...
@@ -669,7 +670,8 @@ int git_treebuilder_new(
if
(
append_entry
(
bld
,
entry_src
->
filename
,
entry_src
->
oid
,
entry_src
->
attr
)
<
0
)
entry_src
->
attr
,
false
)
<
0
)
goto
on_error
;
}
}
...
...
tests/object/tree/update.c
View file @
85eb2cb6
...
...
@@ -284,3 +284,19 @@ void test_object_tree_update__add_conflict2(void)
cl_git_fail
(
git_tree_create_updated
(
&
tree_updater_id
,
g_repo
,
NULL
,
2
,
updates
));
}
void
test_object_tree_update__remove_invalid_submodule
(
void
)
{
git_tree
*
baseline
;
git_oid
updated_tree_id
,
baseline_id
;
git_tree_update
updates
[]
=
{
{
GIT_TREE_UPDATE_REMOVE
,
{{
0
}},
GIT_FILEMODE_BLOB
,
"submodule"
},
};
/* This tree contains a submodule with an all-zero commit for a submodule named 'submodule' */
cl_git_pass
(
git_oid_fromstr
(
&
baseline_id
,
"396c7f1adb7925f51ba13a75f48252f44c5a14a2"
));
cl_git_pass
(
git_tree_lookup
(
&
baseline
,
g_repo
,
&
baseline_id
));
cl_git_pass
(
git_tree_create_updated
(
&
updated_tree_id
,
g_repo
,
baseline
,
1
,
updates
));
git_tree_free
(
baseline
);
}
tests/resources/testrepo2/.gitted/objects/39/6c7f1adb7925f51ba13a75f48252f44c5a14a2
0 → 100644
View file @
85eb2cb6
File added
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