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
c85e08b1
Commit
c85e08b1
authored
Aug 16, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
odb: Do not pass around a header when hashing
parent
7adba5f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
14 deletions
+10
-14
src/indexer.c
+2
-3
src/odb.c
+7
-10
src/odb.h
+1
-1
No files found.
src/indexer.c
View file @
c85e08b1
...
...
@@ -322,8 +322,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
git_oid
oid
;
struct
git_pack_entry
*
pentry
;
git_mwindow
*
w
=
NULL
;
char
hdr
[
512
]
=
{
0
};
/* FIXME: How long should this be? */
int
i
,
hdr_len
;
int
i
;
off_t
entry_start
=
off
;
void
*
packed
;
size_t
entry_size
;
...
...
@@ -345,7 +344,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
}
/* FIXME: Parse the object instead of hashing it */
error
=
git_odb__hash_obj
(
&
oid
,
hdr
,
sizeof
(
hdr
),
&
hdr_len
,
&
obj
);
error
=
git_odb__hash_obj
(
&
oid
,
&
obj
);
if
(
error
<
GIT_SUCCESS
)
{
error
=
git__rethrow
(
error
,
"Failed to hash object"
);
goto
cleanup
;
...
...
src/odb.c
View file @
c85e08b1
...
...
@@ -59,12 +59,13 @@ static int format_object_header(char *hdr, size_t n, size_t obj_len, git_otype o
return
len
+
1
;
}
int
git_odb__hash_obj
(
git_oid
*
id
,
char
*
hdr
,
size_t
n
,
int
*
len
,
git_rawobj
*
obj
)
int
git_odb__hash_obj
(
git_oid
*
id
,
git_rawobj
*
obj
)
{
git_buf_vec
vec
[
2
];
int
hdrlen
;
char
header
[
64
];
int
hdrlen
;
assert
(
id
&&
hdr
&&
len
&&
obj
);
assert
(
id
&&
obj
);
if
(
!
git_object_typeisloose
(
obj
->
type
))
return
git__throw
(
GIT_ERROR
,
"Failed to hash object. Wrong object type"
);
...
...
@@ -72,12 +73,10 @@ int git_odb__hash_obj(git_oid *id, char *hdr, size_t n, int *len, git_rawobj *ob
if
(
!
obj
->
data
&&
obj
->
len
!=
0
)
return
git__throw
(
GIT_ERROR
,
"Failed to hash object. No data given"
);
if
((
hdrlen
=
format_object_header
(
h
dr
,
n
,
obj
->
len
,
obj
->
type
))
<
0
)
if
((
hdrlen
=
format_object_header
(
h
eader
,
sizeof
(
header
)
,
obj
->
len
,
obj
->
type
))
<
0
)
return
git__rethrow
(
hdrlen
,
"Failed to hash object"
);
*
len
=
hdrlen
;
vec
[
0
].
data
=
hdr
;
vec
[
0
].
data
=
header
;
vec
[
0
].
len
=
hdrlen
;
vec
[
1
].
data
=
obj
->
data
;
vec
[
1
].
len
=
obj
->
len
;
...
...
@@ -182,8 +181,6 @@ int git_odb_hashfile(git_oid *out, const char *path, git_otype type)
int
git_odb_hash
(
git_oid
*
id
,
const
void
*
data
,
size_t
len
,
git_otype
type
)
{
char
hdr
[
64
];
int
hdrlen
;
git_rawobj
raw
;
assert
(
id
);
...
...
@@ -192,7 +189,7 @@ int git_odb_hash(git_oid *id, const void *data, size_t len, git_otype type)
raw
.
len
=
len
;
raw
.
type
=
type
;
return
git_odb__hash_obj
(
id
,
hdr
,
sizeof
(
hdr
),
&
hdrlen
,
&
raw
);
return
git_odb__hash_obj
(
id
,
&
raw
);
}
/**
...
...
src/odb.h
View file @
c85e08b1
...
...
@@ -28,6 +28,6 @@ struct git_odb {
git_cache
cache
;
};
int
git_odb__hash_obj
(
git_oid
*
id
,
char
*
hdr
,
size_t
n
,
int
*
len
,
git_rawobj
*
obj
);
int
git_odb__hash_obj
(
git_oid
*
id
,
git_rawobj
*
obj
);
#endif
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