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
2a612fe3
Commit
2a612fe3
authored
Nov 13, 2012
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filebuf now has a git_hash_ctx instead of a ctx*
parent
a8527429
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
18 deletions
+17
-18
src/filebuf.c
+15
-17
src/filebuf.h
+2
-1
No files found.
src/filebuf.c
View file @
2a612fe3
...
@@ -85,8 +85,8 @@ static int lock_file(git_filebuf *file, int flags)
...
@@ -85,8 +85,8 @@ static int lock_file(git_filebuf *file, int flags)
while
((
read_bytes
=
p_read
(
source
,
buffer
,
sizeof
(
buffer
)))
>
0
)
{
while
((
read_bytes
=
p_read
(
source
,
buffer
,
sizeof
(
buffer
)))
>
0
)
{
p_write
(
file
->
fd
,
buffer
,
read_bytes
);
p_write
(
file
->
fd
,
buffer
,
read_bytes
);
if
(
file
->
digest
)
if
(
file
->
compute_
digest
)
git_hash_update
(
file
->
digest
,
buffer
,
read_bytes
);
git_hash_update
(
&
file
->
digest
,
buffer
,
read_bytes
);
}
}
p_close
(
source
);
p_close
(
source
);
...
@@ -108,9 +108,9 @@ void git_filebuf_cleanup(git_filebuf *file)
...
@@ -108,9 +108,9 @@ void git_filebuf_cleanup(git_filebuf *file)
if
(
file
->
fd_is_open
&&
file
->
path_lock
&&
git_path_exists
(
file
->
path_lock
))
if
(
file
->
fd_is_open
&&
file
->
path_lock
&&
git_path_exists
(
file
->
path_lock
))
p_unlink
(
file
->
path_lock
);
p_unlink
(
file
->
path_lock
);
if
(
file
->
digest
)
{
if
(
file
->
compute_
digest
)
{
git_hash_ctx_cleanup
(
file
->
digest
);
git_hash_ctx_cleanup
(
&
file
->
digest
);
git__free
(
file
->
digest
)
;
file
->
compute_digest
=
0
;
}
}
if
(
file
->
buffer
)
if
(
file
->
buffer
)
...
@@ -151,8 +151,8 @@ static int write_normal(git_filebuf *file, void *source, size_t len)
...
@@ -151,8 +151,8 @@ static int write_normal(git_filebuf *file, void *source, size_t len)
return
-
1
;
return
-
1
;
}
}
if
(
file
->
digest
)
if
(
file
->
compute_
digest
)
git_hash_update
(
file
->
digest
,
source
,
len
);
git_hash_update
(
&
file
->
digest
,
source
,
len
);
}
}
return
0
;
return
0
;
...
@@ -188,8 +188,8 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
...
@@ -188,8 +188,8 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
assert
(
zs
->
avail_in
==
0
);
assert
(
zs
->
avail_in
==
0
);
if
(
file
->
digest
)
if
(
file
->
compute_
digest
)
git_hash_update
(
file
->
digest
,
source
,
len
);
git_hash_update
(
&
file
->
digest
,
source
,
len
);
}
}
return
0
;
return
0
;
...
@@ -223,10 +223,9 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags)
...
@@ -223,10 +223,9 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags)
/* If we are hashing on-write, allocate a new hash context */
/* If we are hashing on-write, allocate a new hash context */
if
(
flags
&
GIT_FILEBUF_HASH_CONTENTS
)
{
if
(
flags
&
GIT_FILEBUF_HASH_CONTENTS
)
{
file
->
digest
=
git__calloc
(
1
,
sizeof
(
git_hash_ctx
));
file
->
compute_digest
=
1
;
GITERR_CHECK_ALLOC
(
file
->
digest
);
if
(
git_hash_ctx_init
(
file
->
digest
)
<
0
)
if
(
git_hash_ctx_init
(
&
file
->
digest
)
<
0
)
goto
cleanup
;
goto
cleanup
;
}
}
...
@@ -296,17 +295,16 @@ cleanup:
...
@@ -296,17 +295,16 @@ cleanup:
int
git_filebuf_hash
(
git_oid
*
oid
,
git_filebuf
*
file
)
int
git_filebuf_hash
(
git_oid
*
oid
,
git_filebuf
*
file
)
{
{
assert
(
oid
&&
file
&&
file
->
digest
);
assert
(
oid
&&
file
&&
file
->
compute_
digest
);
flush_buffer
(
file
);
flush_buffer
(
file
);
if
(
verify_last_error
(
file
)
<
0
)
if
(
verify_last_error
(
file
)
<
0
)
return
-
1
;
return
-
1
;
git_hash_final
(
oid
,
file
->
digest
);
git_hash_final
(
oid
,
&
file
->
digest
);
git_hash_ctx_cleanup
(
file
->
digest
);
git_hash_ctx_cleanup
(
&
file
->
digest
);
git__free
(
file
->
digest
);
file
->
compute_digest
=
0
;
file
->
digest
=
NULL
;
return
0
;
return
0
;
}
}
...
...
src/filebuf.h
View file @
2a612fe3
...
@@ -31,7 +31,8 @@ struct git_filebuf {
...
@@ -31,7 +31,8 @@ struct git_filebuf {
int
(
*
write
)(
struct
git_filebuf
*
file
,
void
*
source
,
size_t
len
);
int
(
*
write
)(
struct
git_filebuf
*
file
,
void
*
source
,
size_t
len
);
git_hash_ctx
*
digest
;
bool
compute_digest
;
git_hash_ctx
digest
;
unsigned
char
*
buffer
;
unsigned
char
*
buffer
;
unsigned
char
*
z_buf
;
unsigned
char
*
z_buf
;
...
...
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