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
afca16a7
Commit
afca16a7
authored
Jan 22, 2022
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: use a byte array for checksum
parent
c6e1f2bf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
src/config_file.c
+6
-5
No files found.
src/config_file.c
View file @
afca16a7
...
@@ -19,13 +19,14 @@
...
@@ -19,13 +19,14 @@
#include "regexp.h"
#include "regexp.h"
#include "sysdir.h"
#include "sysdir.h"
#include "wildmatch.h"
#include "wildmatch.h"
#include "hash.h"
/* Max depth for [include] directives */
/* Max depth for [include] directives */
#define MAX_INCLUDE_DEPTH 10
#define MAX_INCLUDE_DEPTH 10
typedef
struct
config_file
{
typedef
struct
config_file
{
git_futils_filestamp
stamp
;
git_futils_filestamp
stamp
;
git_oid
checksum
;
unsigned
char
checksum
[
GIT_HASH_SHA1_SIZE
]
;
char
*
path
;
char
*
path
;
git_array_t
(
struct
config_file
)
includes
;
git_array_t
(
struct
config_file
)
includes
;
}
config_file
;
}
config_file
;
...
@@ -132,7 +133,7 @@ static int config_file_is_modified(int *modified, config_file *file)
...
@@ -132,7 +133,7 @@ static int config_file_is_modified(int *modified, config_file *file)
{
{
config_file
*
include
;
config_file
*
include
;
git_str
buf
=
GIT_STR_INIT
;
git_str
buf
=
GIT_STR_INIT
;
git_oid
hash
;
unsigned
char
checksum
[
GIT_HASH_SHA1_SIZE
]
;
uint32_t
i
;
uint32_t
i
;
int
error
=
0
;
int
error
=
0
;
...
@@ -144,10 +145,10 @@ static int config_file_is_modified(int *modified, config_file *file)
...
@@ -144,10 +145,10 @@ static int config_file_is_modified(int *modified, config_file *file)
if
((
error
=
git_futils_readbuffer
(
&
buf
,
file
->
path
))
<
0
)
if
((
error
=
git_futils_readbuffer
(
&
buf
,
file
->
path
))
<
0
)
goto
out
;
goto
out
;
if
((
error
=
git_hash_buf
(
hash
.
id
,
buf
.
ptr
,
buf
.
size
,
GIT_HASH_ALGORITHM_SHA1
))
<
0
)
if
((
error
=
git_hash_buf
(
checksum
,
buf
.
ptr
,
buf
.
size
,
GIT_HASH_ALGORITHM_SHA1
))
<
0
)
goto
out
;
goto
out
;
if
(
!
git_oid_equal
(
&
hash
,
&
file
->
checksum
)
)
{
if
(
memcmp
(
checksum
,
file
->
checksum
,
GIT_HASH_SHA1_SIZE
)
!=
0
)
{
*
modified
=
1
;
*
modified
=
1
;
goto
out
;
goto
out
;
}
}
...
@@ -880,7 +881,7 @@ static int config_file_read(
...
@@ -880,7 +881,7 @@ static int config_file_read(
goto
out
;
goto
out
;
git_futils_filestamp_set_from_stat
(
&
file
->
stamp
,
&
st
);
git_futils_filestamp_set_from_stat
(
&
file
->
stamp
,
&
st
);
if
((
error
=
git_hash_buf
(
file
->
checksum
.
id
,
contents
.
ptr
,
contents
.
size
,
GIT_HASH_ALGORITHM_SHA1
))
<
0
)
if
((
error
=
git_hash_buf
(
file
->
checksum
,
contents
.
ptr
,
contents
.
size
,
GIT_HASH_ALGORITHM_SHA1
))
<
0
)
goto
out
;
goto
out
;
if
((
error
=
config_file_read_buffer
(
entries
,
repo
,
file
,
level
,
depth
,
if
((
error
=
config_file_read_buffer
(
entries
,
repo
,
file
,
level
,
depth
,
...
...
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