Skip to content

Commit c253849

Browse files
ebiedermgitster
authored andcommitted
object-file: add a compat_oid_in parameter to write_object_file_flags
To create the proper signatures for commit objects both versions of the commit object need to be generated and signed. After that it is a waste to throw away the work of generating the compatibility hash so update write_object_file_flags to take a compatibility hash input parameter that it can use to skip the work of generating the compatability hash. Update the places that don't generate the compatability hash to pass NULL so it is easy to tell write_object_file_flags should not attempt to use their compatability hash. Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 63a6745 commit c253849

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

cache-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static int update_one(struct cache_tree *it,
448448
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
449449
OBJ_TREE, &it->oid);
450450
} else if (write_object_file_flags(buffer.buf, buffer.len, OBJ_TREE,
451-
&it->oid, flags & WRITE_TREE_SILENT
451+
&it->oid, NULL, flags & WRITE_TREE_SILENT
452452
? HASH_SILENT : 0)) {
453453
strbuf_release(&buffer);
454454
return -1;

object-file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,
22352235

22362236
int write_object_file_flags(const void *buf, unsigned long len,
22372237
enum object_type type, struct object_id *oid,
2238-
unsigned flags)
2238+
struct object_id *compat_oid_in, unsigned flags)
22392239
{
22402240
struct repository *repo = the_repository;
22412241
const struct git_hash_algo *algo = repo->hash_algo;
@@ -2246,7 +2246,9 @@ int write_object_file_flags(const void *buf, unsigned long len,
22462246

22472247
/* Generate compat_oid */
22482248
if (compat) {
2249-
if (type == OBJ_BLOB)
2249+
if (compat_oid_in)
2250+
oidcpy(&compat_oid, compat_oid_in);
2251+
else if (type == OBJ_BLOB)
22502252
hash_object_file(compat, buf, len, type, &compat_oid);
22512253
else {
22522254
struct strbuf converted = STRBUF_INIT;

object-store-ll.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,
255255

256256
int write_object_file_flags(const void *buf, unsigned long len,
257257
enum object_type type, struct object_id *oid,
258-
unsigned flags);
258+
struct object_id *comapt_oid_in, unsigned flags);
259259
static inline int write_object_file(const void *buf, unsigned long len,
260260
enum object_type type, struct object_id *oid)
261261
{
262-
return write_object_file_flags(buf, len, type, oid, 0);
262+
return write_object_file_flags(buf, len, type, oid, NULL, 0);
263263
}
264264

265265
int write_object_file_literally(const void *buf, unsigned long len,

0 commit comments

Comments
 (0)