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
c3b5099f
Commit
c3b5099f
authored
Jul 11, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add git_path_is_dot_or_dotdot.
Also, remove some duplication in the clone test suite.
parent
822d9dd5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
18 deletions
+12
-18
src/clone.c
+2
-8
src/path.c
+2
-10
src/path.h
+8
-0
No files found.
src/clone.c
View file @
c3b5099f
...
...
@@ -24,6 +24,7 @@
#include "remote.h"
#include "fileops.h"
#include "refs.h"
#include "path.h"
GIT_BEGIN_DECL
...
...
@@ -191,13 +192,6 @@ static int setup_remotes_and_fetch(git_repository *repo,
}
static
bool
is_dot_or_dotdot
(
const
char
*
name
)
{
return
(
name
[
0
]
==
'.'
&&
(
name
[
1
]
==
'\0'
||
(
name
[
1
]
==
'.'
&&
name
[
2
]
==
'\0'
)));
}
/* TODO: p_opendir, p_closedir */
static
bool
path_is_okay
(
const
char
*
path
)
{
...
...
@@ -238,7 +232,7 @@ static bool path_is_okay(const char *path)
}
while
((
e
=
readdir
(
dir
))
!=
NULL
)
{
if
(
!
is_dot_or_dotdot
(
e
->
d_name
))
{
if
(
!
git_path_
is_dot_or_dotdot
(
e
->
d_name
))
{
giterr_set
(
GITERR_INVALID
,
"'%s' exists and is not an empty directory"
,
path
);
retval
=
false
;
...
...
src/path.c
View file @
c3b5099f
...
...
@@ -488,14 +488,6 @@ int git_path_cmp(
return
(
c1
<
c2
)
?
-
1
:
(
c1
>
c2
)
?
1
:
0
;
}
/* Taken from git.git */
GIT_INLINE
(
int
)
is_dot_or_dotdot
(
const
char
*
name
)
{
return
(
name
[
0
]
==
'.'
&&
(
name
[
1
]
==
'\0'
||
(
name
[
1
]
==
'.'
&&
name
[
2
]
==
'\0'
)));
}
int
git_path_direach
(
git_buf
*
path
,
int
(
*
fn
)(
void
*
,
git_buf
*
),
...
...
@@ -524,7 +516,7 @@ int git_path_direach(
while
(
p_readdir_r
(
dir
,
de_buf
,
&
de
)
==
0
&&
de
!=
NULL
)
{
int
result
;
if
(
is_dot_or_dotdot
(
de
->
d_name
))
if
(
git_path_
is_dot_or_dotdot
(
de
->
d_name
))
continue
;
if
(
git_buf_puts
(
path
,
de
->
d_name
)
<
0
)
{
...
...
@@ -583,7 +575,7 @@ int git_path_dirload(
char
*
entry_path
;
size_t
entry_len
;
if
(
is_dot_or_dotdot
(
de
->
d_name
))
if
(
git_path_
is_dot_or_dotdot
(
de
->
d_name
))
continue
;
entry_len
=
strlen
(
de
->
d_name
);
...
...
src/path.h
View file @
c3b5099f
...
...
@@ -80,6 +80,14 @@ extern int git_path_to_dir(git_buf *path);
*/
extern
void
git_path_string_to_dir
(
char
*
path
,
size_t
size
);
/* Taken from git.git */
GIT_INLINE
(
int
)
git_path_is_dot_or_dotdot
(
const
char
*
name
)
{
return
(
name
[
0
]
==
'.'
&&
(
name
[
1
]
==
'\0'
||
(
name
[
1
]
==
'.'
&&
name
[
2
]
==
'\0'
)));
}
#ifdef GIT_WIN32
/**
* Convert backslashes in path to forward slashes.
...
...
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