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
8dc91e31
Commit
8dc91e31
authored
Jul 13, 2011
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #323 from nulltoken/ntk/fix/treebuilder-insert
tree: fix insertion of entries with invalid filenames
parents
e6629d83
f4ad64c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
src/tree.c
+5
-3
tests/t09-tree.c
+5
-0
No files found.
src/tree.c
View file @
8dc91e31
...
...
@@ -379,10 +379,12 @@ int git_treebuilder_insert(git_tree_entry **entry_out, git_treebuilder *bld, con
assert
(
bld
&&
id
&&
filename
);
if
(
!
valid_attributes
(
attributes
))
return
git__throw
(
GIT_ERROR
,
"Failed to insert entry. Invalid at
r
ributes"
);
return
git__throw
(
GIT_ERROR
,
"Failed to insert entry. Invalid at
t
ributes"
);
if
(
build_ksearch
(
&
ksearch
,
filename
)
==
GIT_SUCCESS
&&
(
pos
=
git_vector_bsearch2
(
&
bld
->
entries
,
entry_search_cmp
,
&
ksearch
))
!=
GIT_ENOTFOUND
)
{
if
(
build_ksearch
(
&
ksearch
,
filename
)
<
GIT_SUCCESS
)
return
git__throw
(
GIT_ERROR
,
"Failed to insert entry. Invalid filename '%s'"
,
filename
);
if
((
pos
=
git_vector_bsearch2
(
&
bld
->
entries
,
entry_search_cmp
,
&
ksearch
))
!=
GIT_ENOTFOUND
)
{
entry
=
git_vector_get
(
&
bld
->
entries
,
pos
);
if
(
entry
->
removed
)
{
entry
->
removed
=
0
;
...
...
tests/t09-tree.c
View file @
8dc91e31
...
...
@@ -150,6 +150,11 @@ BEGIN_TEST(write2, "write a tree from a memory")
//create a second tree from first tree using `git_treebuilder_insert` on REPOSITORY_FOLDER.
must_pass
(
git_tree_lookup
(
&
tree
,
repo
,
&
id
));
must_pass
(
git_treebuilder_create
(
&
builder
,
tree
));
must_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
""
,
&
bid
,
0100644
));
must_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"/"
,
&
bid
,
0100644
));
must_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"folder/new.txt"
,
&
bid
,
0100644
));
must_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new.txt"
,
&
bid
,
0100644
));
must_pass
(
git_treebuilder_write
(
&
rid
,
repo
,
builder
));
...
...
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