Skip to content

Commit 5951bf4

Browse files
bk2204gitster
authored andcommitted
Use the final_oid_fn to finalize hashing of object IDs
When we're hashing a value which is going to be an object ID, we want to zero-pad that value if necessary. To do so, use the final_oid_fn instead of the final_fn anytime we're going to create an object ID to ensure we perform this operation. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab795f0 commit 5951bf4

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

builtin/fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ static int store_object(
940940
the_hash_algo->init_fn(&c);
941941
the_hash_algo->update_fn(&c, hdr, hdrlen);
942942
the_hash_algo->update_fn(&c, dat->buf, dat->len);
943-
the_hash_algo->final_fn(oid.hash, &c);
943+
the_hash_algo->final_oid_fn(&oid, &c);
944944
if (oidout)
945945
oidcpy(oidout, &oid);
946946

@@ -1136,7 +1136,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
11361136
}
11371137
}
11381138
git_deflate_end(&s);
1139-
the_hash_algo->final_fn(oid.hash, &c);
1139+
the_hash_algo->final_oid_fn(&oid, &c);
11401140

11411141
if (oidout)
11421142
oidcpy(oidout, &oid);

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,
489489
bad_object(offset, _("inflate returned %d"), status);
490490
git_inflate_end(&stream);
491491
if (oid)
492-
the_hash_algo->final_fn(oid->hash, &c);
492+
the_hash_algo->final_oid_fn(oid, &c);
493493
return buf == fixed_buf ? NULL : buf;
494494
}
495495

builtin/unpack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
576576
the_hash_algo->init_fn(&ctx);
577577
unpack_all();
578578
the_hash_algo->update_fn(&ctx, buffer, offset);
579-
the_hash_algo->final_fn(oid.hash, &ctx);
579+
the_hash_algo->final_oid_fn(&oid, &ctx);
580580
if (strict) {
581581
write_rest();
582582
if (fsck_finish(&fsck_options))

bulk-checkin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
238238
if (lseek(fd, seekback, SEEK_SET) == (off_t) -1)
239239
return error("cannot seek back");
240240
}
241-
the_hash_algo->final_fn(result_oid->hash, &ctx);
241+
the_hash_algo->final_oid_fn(result_oid, &ctx);
242242
if (!idx)
243243
return 0;
244244

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6234,7 +6234,7 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid
62346234
}
62356235

62366236
if (!stable)
6237-
the_hash_algo->final_fn(oid->hash, &ctx);
6237+
the_hash_algo->final_oid_fn(oid, &ctx);
62386238

62396239
return 0;
62406240
}

http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,7 @@ int finish_http_object_request(struct http_object_request *freq)
25762576
}
25772577

25782578
git_inflate_end(&freq->stream);
2579-
the_hash_algo->final_fn(freq->real_oid.hash, &freq->c);
2579+
the_hash_algo->final_oid_fn(&freq->real_oid, &freq->c);
25802580
if (freq->zret != Z_STREAM_END) {
25812581
unlink_or_warn(freq->tmpfile.buf);
25822582
return -1;

object-file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ int check_object_signature(struct repository *r, const struct object_id *oid,
10541054
break;
10551055
r->hash_algo->update_fn(&c, buf, readlen);
10561056
}
1057-
r->hash_algo->final_fn(real_oid.hash, &c);
1057+
r->hash_algo->final_oid_fn(&real_oid, &c);
10581058
close_istream(st);
10591059
return !oideq(oid, &real_oid) ? -1 : 0;
10601060
}
@@ -1755,7 +1755,7 @@ static void write_object_file_prepare(const struct git_hash_algo *algo,
17551755
algo->init_fn(&c);
17561756
algo->update_fn(&c, hdr, *hdrlen);
17571757
algo->update_fn(&c, buf, len);
1758-
algo->final_fn(oid->hash, &c);
1758+
algo->final_oid_fn(oid, &c);
17591759
}
17601760

17611761
/*
@@ -1927,7 +1927,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
19271927
if (ret != Z_OK)
19281928
die(_("deflateEnd on object %s failed (%d)"), oid_to_hex(oid),
19291929
ret);
1930-
the_hash_algo->final_fn(parano_oid.hash, &c);
1930+
the_hash_algo->final_oid_fn(&parano_oid, &c);
19311931
if (!oideq(oid, &parano_oid))
19321932
die(_("confused by unstable object source data for %s"),
19331933
oid_to_hex(oid));
@@ -2508,7 +2508,7 @@ static int check_stream_oid(git_zstream *stream,
25082508
return -1;
25092509
}
25102510

2511-
the_hash_algo->final_fn(real_oid.hash, &c);
2511+
the_hash_algo->final_oid_fn(&real_oid, &c);
25122512
if (!oideq(expected_oid, &real_oid)) {
25132513
error(_("hash mismatch for %s (expected %s)"), path,
25142514
oid_to_hex(expected_oid));

0 commit comments

Comments
 (0)