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
cf06de46
Commit
cf06de46
authored
Apr 09, 2023
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iterator: support sha256
parent
a47bc4ea
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
src/libgit2/iterator.c
+20
-5
src/libgit2/iterator.h
+3
-0
src/libgit2/refdb_fs.c
+4
-1
No files found.
src/libgit2/iterator.c
View file @
cf06de46
...
...
@@ -1036,6 +1036,8 @@ typedef struct {
git_index
*
index
;
git_vector
index_snapshot
;
git_oid_t
oid_type
;
git_array_t
(
filesystem_iterator_frame
)
frames
;
git_ignores
ignores
;
...
...
@@ -1271,7 +1273,7 @@ static int filesystem_iterator_entry_hash(
int
error
;
if
(
S_ISDIR
(
entry
->
st
.
st_mode
))
{
memset
(
&
entry
->
id
,
0
,
GIT_OID_SHA1_SIZE
);
memset
(
&
entry
->
id
,
0
,
git_oid_size
(
iter
->
oid_type
)
);
return
0
;
}
...
...
@@ -1281,7 +1283,7 @@ static int filesystem_iterator_entry_hash(
if
(
!
(
error
=
git_str_joinpath
(
&
fullpath
,
iter
->
root
,
entry
->
path
))
&&
!
(
error
=
git_path_validate_str_length
(
iter
->
base
.
repo
,
&
fullpath
)))
error
=
git_odb__hashfile
(
&
entry
->
id
,
fullpath
.
ptr
,
GIT_OBJECT_BLOB
,
GIT_OID_SHA1
);
error
=
git_odb__hashfile
(
&
entry
->
id
,
fullpath
.
ptr
,
GIT_OBJECT_BLOB
,
iter
->
oid_type
);
git_str_dispose
(
&
fullpath
);
return
error
;
...
...
@@ -1530,7 +1532,7 @@ static void filesystem_iterator_set_current(
if
(
iter
->
base
.
flags
&
GIT_ITERATOR_INCLUDE_HASH
)
git_oid_cpy
(
&
iter
->
entry
.
id
,
&
entry
->
id
);
else
git_oid_clear
(
&
iter
->
entry
.
id
,
GIT_OID_SHA1
);
git_oid_clear
(
&
iter
->
entry
.
id
,
iter
->
oid_type
);
iter
->
entry
.
path
=
entry
->
path
;
...
...
@@ -1975,6 +1977,8 @@ static int iterator_for_filesystem(
(
iterator__flag
(
&
iter
->
base
,
PRECOMPOSE_UNICODE
)
?
GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE
:
0
);
iter
->
oid_type
=
options
->
oid_type
;
if
((
error
=
filesystem_iterator_init
(
iter
))
<
0
)
goto
on_error
;
...
...
@@ -1989,10 +1993,15 @@ on_error:
int
git_iterator_for_filesystem
(
git_iterator
**
out
,
const
char
*
root
,
git_iterator_options
*
option
s
)
git_iterator_options
*
given_opt
s
)
{
git_iterator_options
options
=
GIT_ITERATOR_OPTIONS_INIT
;
if
(
given_opts
)
memcpy
(
&
options
,
given_opts
,
sizeof
(
git_iterator_options
));
return
iterator_for_filesystem
(
out
,
NULL
,
root
,
NULL
,
NULL
,
GIT_ITERATOR_FS
,
options
);
NULL
,
root
,
NULL
,
NULL
,
GIT_ITERATOR_FS
,
&
options
);
}
int
git_iterator_for_workdir_ext
(
...
...
@@ -2019,6 +2028,12 @@ int git_iterator_for_workdir_ext(
options
.
flags
|=
GIT_ITERATOR_HONOR_IGNORES
|
GIT_ITERATOR_IGNORE_DOT_GIT
;
if
(
!
options
.
oid_type
)
options
.
oid_type
=
repo
->
oid_type
;
else
if
(
options
.
oid_type
!=
repo
->
oid_type
)
git_error_set
(
GIT_ERROR_INVALID
,
"specified object ID type does not match repository object ID type"
);
return
iterator_for_filesystem
(
out
,
repo
,
repo_workdir
,
index
,
tree
,
GIT_ITERATOR_WORKDIR
,
&
options
);
}
...
...
src/libgit2/iterator.h
View file @
cf06de46
...
...
@@ -63,6 +63,9 @@ typedef struct {
/* flags, from above */
unsigned
int
flags
;
/* oid type - necessary for non-workdir filesystem iterators */
git_oid_t
oid_type
;
}
git_iterator_options
;
#define GIT_ITERATOR_OPTIONS_INIT {0}
...
...
src/libgit2/refdb_fs.c
View file @
cf06de46
...
...
@@ -805,7 +805,9 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
git__free
(
iter
);
}
static
int
iter_load_loose_paths
(
refdb_fs_backend
*
backend
,
refdb_fs_iter
*
iter
)
static
int
iter_load_loose_paths
(
refdb_fs_backend
*
backend
,
refdb_fs_iter
*
iter
)
{
int
error
=
0
;
git_str
path
=
GIT_STR_INIT
;
...
...
@@ -819,6 +821,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
return
0
;
fsit_opts
.
flags
=
backend
->
iterator_flags
;
fsit_opts
.
oid_type
=
backend
->
oid_type
;
if
(
iter
->
glob
)
{
const
char
*
last_sep
=
NULL
;
...
...
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