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
19af78bb
Commit
19af78bb
authored
Nov 18, 2012
by
Scott J. Goldman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent creating `..`, `.`, and `.git` with tree builder
As per core git.
parent
629c0829
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
+9
-1
src/tree.c
+3
-1
tests-clar/object/tree/write.c
+6
-0
No files found.
src/tree.c
View file @
19af78bb
...
@@ -26,7 +26,9 @@ static bool valid_filemode(const int filemode)
...
@@ -26,7 +26,9 @@ static bool valid_filemode(const int filemode)
static
int
valid_entry_name
(
const
char
*
filename
)
static
int
valid_entry_name
(
const
char
*
filename
)
{
{
return
*
filename
!=
'\0'
&&
strchr
(
filename
,
'/'
)
==
NULL
;
return
*
filename
!=
'\0'
&&
strchr
(
filename
,
'/'
)
==
NULL
&&
strcmp
(
filename
,
".."
)
!=
0
&&
strcmp
(
filename
,
"."
)
!=
0
&&
strcmp
(
filename
,
".git"
)
!=
0
;
}
}
static
int
entry_sort_cmp
(
const
void
*
a
,
const
void
*
b
)
static
int
entry_sort_cmp
(
const
void
*
a
,
const
void
*
b
)
...
...
tests-clar/object/tree/write.c
View file @
19af78bb
...
@@ -39,6 +39,12 @@ void test_object_tree_write__from_memory(void)
...
@@ -39,6 +39,12 @@ void test_object_tree_write__from_memory(void)
&
bid
,
GIT_FILEMODE_BLOB
));
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"/"
,
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"/"
,
&
bid
,
GIT_FILEMODE_BLOB
));
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
".git"
,
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
".."
,
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"."
,
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"folder/new.txt"
,
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"folder/new.txt"
,
&
bid
,
GIT_FILEMODE_BLOB
));
&
bid
,
GIT_FILEMODE_BLOB
));
...
...
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