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
9e94b6af
Commit
9e94b6af
authored
Dec 30, 2017
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iterator: cleanups with symlink dir handling
Perform some error checking when examining symlink directories.
parent
e9628e7b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
17 deletions
+32
-17
src/iterator.c
+29
-14
src/iterator.h
+2
-2
src/refdb_fs.c
+1
-1
No files found.
src/iterator.c
View file @
9e94b6af
...
...
@@ -23,7 +23,7 @@
#define iterator__has_been_accessed(I) iterator__flag(I,FIRST_ACCESS)
#define iterator__honor_ignores(I) iterator__flag(I,HONOR_IGNORES)
#define iterator__ignore_dot_git(I) iterator__flag(I,IGNORE_DOT_GIT)
#define iterator__
symlinksdir(I) iterator__flag(I,INCLUDE_SYMLINK_REFSDIR
)
#define iterator__
descend_symlinks(I) iterator__flag(I,DESCEND_SYMLINKS
)
static
void
iterator_set_ignore_case
(
git_iterator
*
iter
,
bool
ignore_case
)
...
...
@@ -1492,29 +1492,41 @@ static int filesystem_iterator_current(
return
0
;
}
static
int
is_directory
(
const
filesystem_iterator
*
iter
,
const
filesystem_iterator_entry
*
entry
)
static
int
filesystem_iterator_is_dir
(
bool
*
is_dir
,
const
filesystem_iterator
*
iter
,
const
filesystem_iterator_entry
*
entry
)
{
int
isdir
=
0
;
struct
stat
st
;
git_buf
fullpath
;
git_buf
fullpath
=
GIT_BUF_INIT
;
int
error
=
0
;
if
(
S_ISDIR
(
entry
->
st
.
st_mode
))
return
1
;
if
(
!
iterator__symlinksdir
(
iter
)
||
!
S_ISLNK
(
entry
->
st
.
st_mode
))
return
0
;
if
(
S_ISDIR
(
entry
->
st
.
st_mode
))
{
*
is_dir
=
1
;
goto
done
;
}
if
(
!
iterator__descend_symlinks
(
iter
)
||
!
S_ISLNK
(
entry
->
st
.
st_mode
))
{
*
is_dir
=
0
;
goto
done
;
}
git_buf_init
(
&
fullpath
,
0
);
git_buf_joinpath
(
&
fullpath
,
iter
->
root
,
entry
->
path
);
isdir
=
!
p_stat
(
fullpath
.
ptr
,
&
st
)
&&
S_ISDIR
(
st
.
st_mode
);
if
((
error
=
git_buf_joinpath
(
&
fullpath
,
iter
->
root
,
entry
->
path
))
<
0
||
(
error
=
p_stat
(
fullpath
.
ptr
,
&
st
))
<
0
)
goto
done
;
*
is_dir
=
S_ISDIR
(
st
.
st_mode
);
done
:
git_buf_free
(
&
fullpath
);
return
isdi
r
;
return
erro
r
;
}
static
int
filesystem_iterator_advance
(
const
git_index_entry
**
out
,
git_iterator
*
i
)
{
filesystem_iterator
*
iter
=
(
filesystem_iterator
*
)
i
;
bool
is_dir
;
int
error
=
0
;
iter
->
base
.
flags
|=
GIT_ITERATOR_FIRST_ACCESS
;
...
...
@@ -1539,7 +1551,10 @@ static int filesystem_iterator_advance(
entry
=
frame
->
entries
.
contents
[
frame
->
next_idx
];
frame
->
next_idx
++
;
if
(
is_directory
(
iter
,
entry
))
{
if
((
error
=
filesystem_iterator_is_dir
(
&
is_dir
,
iter
,
entry
))
<
0
)
break
;
if
(
is_dir
)
{
if
(
iterator__do_autoexpand
(
iter
))
{
error
=
filesystem_iterator_frame_push
(
iter
,
entry
);
...
...
src/iterator.h
View file @
9e94b6af
...
...
@@ -39,8 +39,8 @@ typedef enum {
GIT_ITERATOR_DONT_PRECOMPOSE_UNICODE
=
(
1u
<<
5
),
/** include conflicts */
GIT_ITERATOR_INCLUDE_CONFLICTS
=
(
1u
<<
6
),
/** descend into symlinked directories
when looking for references
*/
GIT_ITERATOR_
INCLUDE_SYMLINK_REFSDIR
=
(
1u
<<
7
),
/** descend into symlinked directories */
GIT_ITERATOR_
DESCEND_SYMLINKS
=
(
1u
<<
7
),
}
git_iterator_flag_t
;
typedef
enum
{
...
...
src/refdb_fs.c
View file @
9e94b6af
...
...
@@ -2035,7 +2035,7 @@ int git_refdb_backend_fs(
if
((
!
git_repository__cvar
(
&
t
,
backend
->
repo
,
GIT_CVAR_FSYNCOBJECTFILES
)
&&
t
)
||
git_repository__fsync_gitdir
)
backend
->
fsync
=
1
;
backend
->
iterator_flags
|=
GIT_ITERATOR_
INCLUDE_SYMLINK_REFSDIR
;
backend
->
iterator_flags
|=
GIT_ITERATOR_
DESCEND_SYMLINKS
;
backend
->
parent
.
exists
=
&
refdb_fs_backend__exists
;
backend
->
parent
.
lookup
=
&
refdb_fs_backend__lookup
;
...
...
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