Skip to content

Commit bb5f4b8

Browse files
committed
Merge branch 'kn/pack-write-with-reduced-globals' into next
Code clean-up. * kn/pack-write-with-reduced-globals: pack-write: pass hash_algo to internal functions pack-write: pass hash_algo to `write_rev_file()` pack-write: pass hash_algo to `write_idx_file()` pack-write: pass repository to `index_pack_lockfile()` pack-write: pass hash_algo to `fixup_pack_header_footer()`
2 parents c7c317a + 8705c9b commit bb5f4b8

File tree

9 files changed

+106
-74
lines changed

9 files changed

+106
-74
lines changed

builtin/fast-import.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,8 @@ static const char *create_index(void)
798798
if (c != last)
799799
die("internal consistency error creating the index");
800800

801-
tmpfile = write_idx_file(NULL, idx, object_count, &pack_idx_opts,
802-
pack_data->hash);
801+
tmpfile = write_idx_file(the_hash_algo, NULL, idx, object_count,
802+
&pack_idx_opts, pack_data->hash);
803803
free(idx);
804804
return tmpfile;
805805
}
@@ -878,9 +878,10 @@ static void end_packfile(void)
878878

879879
close_pack_windows(pack_data);
880880
finalize_hashfile(pack_file, cur_pack_oid.hash, FSYNC_COMPONENT_PACK, 0);
881-
fixup_pack_header_footer(pack_data->pack_fd, pack_data->hash,
882-
pack_data->pack_name, object_count,
883-
cur_pack_oid.hash, pack_size);
881+
fixup_pack_header_footer(the_hash_algo, pack_data->pack_fd,
882+
pack_data->hash, pack_data->pack_name,
883+
object_count, cur_pack_oid.hash,
884+
pack_size);
884885

885886
if (object_count <= unpack_limit) {
886887
if (!loosen_small_pack(pack_data)) {

builtin/index-pack.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
13921392
strbuf_release(&msg);
13931393
finalize_hashfile(f, tail_hash, FSYNC_COMPONENT_PACK, 0);
13941394
hashcpy(read_hash, pack_hash, the_repository->hash_algo);
1395-
fixup_pack_header_footer(output_fd, pack_hash,
1395+
fixup_pack_header_footer(the_hash_algo, output_fd, pack_hash,
13961396
curr_pack, nr_objects,
13971397
read_hash, consumed_bytes-the_hash_algo->rawsz);
13981398
if (!hasheq(read_hash, tail_hash, the_repository->hash_algo))
@@ -2089,11 +2089,12 @@ int cmd_index_pack(int argc,
20892089
ALLOC_ARRAY(idx_objects, nr_objects);
20902090
for (i = 0; i < nr_objects; i++)
20912091
idx_objects[i] = &objects[i].idx;
2092-
curr_index = write_idx_file(index_name, idx_objects, nr_objects, &opts, pack_hash);
2092+
curr_index = write_idx_file(the_hash_algo, index_name, idx_objects,
2093+
nr_objects, &opts, pack_hash);
20932094
if (rev_index)
2094-
curr_rev_index = write_rev_file(rev_index_name, idx_objects,
2095-
nr_objects, pack_hash,
2096-
opts.flags);
2095+
curr_rev_index = write_rev_file(the_hash_algo, rev_index_name,
2096+
idx_objects, nr_objects,
2097+
pack_hash, opts.flags);
20972098
free(idx_objects);
20982099

20992100
if (!verify)

builtin/pack-objects.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,8 +1319,9 @@ static void write_pack_file(void)
13191319
*/
13201320

13211321
int fd = finalize_hashfile(f, hash, FSYNC_COMPONENT_PACK, 0);
1322-
fixup_pack_header_footer(fd, hash, pack_tmp_name,
1323-
nr_written, hash, offset);
1322+
fixup_pack_header_footer(the_hash_algo, fd, hash,
1323+
pack_tmp_name, nr_written,
1324+
hash, offset);
13241325
close(fd);
13251326
if (write_bitmap_index) {
13261327
if (write_bitmap_index != WRITE_BITMAP_QUIET)
@@ -1368,9 +1369,10 @@ static void write_pack_file(void)
13681369
if (cruft)
13691370
pack_idx_opts.flags |= WRITE_MTIMES;
13701371

1371-
stage_tmp_packfiles(&tmpname, pack_tmp_name,
1372-
written_list, nr_written,
1373-
&to_pack, &pack_idx_opts, hash,
1372+
stage_tmp_packfiles(the_hash_algo, &tmpname,
1373+
pack_tmp_name, written_list,
1374+
nr_written, &to_pack,
1375+
&pack_idx_opts, hash,
13741376
&idx_tmp_name);
13751377

13761378
if (write_bitmap_index) {

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)
23042304
if (status)
23052305
return "index-pack fork failed";
23062306

2307-
lockfile = index_pack_lockfile(child.out, NULL);
2307+
lockfile = index_pack_lockfile(the_repository, child.out, NULL);
23082308
if (lockfile) {
23092309
pack_lockfile = register_tempfile(lockfile);
23102310
free(lockfile);

bulk-checkin.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ static void finish_tmp_packfile(struct strbuf *basename,
4444
{
4545
char *idx_tmp_name = NULL;
4646

47-
stage_tmp_packfiles(basename, pack_tmp_name, written_list, nr_written,
48-
NULL, pack_idx_opts, hash, &idx_tmp_name);
47+
stage_tmp_packfiles(the_hash_algo, basename, pack_tmp_name,
48+
written_list, nr_written, NULL, pack_idx_opts, hash,
49+
&idx_tmp_name);
4950
rename_tmp_packfile_idx(basename, &idx_tmp_name);
5051

5152
free(idx_tmp_name);
@@ -70,7 +71,7 @@ static void flush_bulk_checkin_packfile(struct bulk_checkin_packfile *state)
7071
CSUM_HASH_IN_STREAM | CSUM_FSYNC | CSUM_CLOSE);
7172
} else {
7273
int fd = finalize_hashfile(state->f, hash, FSYNC_COMPONENT_PACK, 0);
73-
fixup_pack_header_footer(fd, hash, state->pack_tmp_name,
74+
fixup_pack_header_footer(the_hash_algo, fd, hash, state->pack_tmp_name,
7475
state->nr_written, hash,
7576
state->offset);
7677
close(fd);

fetch-pack.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,9 @@ static int get_pack(struct fetch_pack_args *args,
10361036
die(_("fetch-pack: unable to fork off %s"), cmd_name);
10371037
if (do_keep && (pack_lockfiles || fsck_objects)) {
10381038
int is_well_formed;
1039-
char *pack_lockfile = index_pack_lockfile(cmd.out, &is_well_formed);
1039+
char *pack_lockfile = index_pack_lockfile(the_repository,
1040+
cmd.out,
1041+
&is_well_formed);
10401042

10411043
if (!is_well_formed)
10421044
die(_("fetch-pack: invalid index-pack output"));

midx-write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,8 @@ static void write_midx_reverse_index(char *midx_name, unsigned char *midx_hash,
658658
strbuf_addf(&buf, "%s-%s.rev", midx_name, hash_to_hex_algop(midx_hash,
659659
ctx->repo->hash_algo));
660660

661-
tmp_file = write_rev_file_order(NULL, ctx->pack_order, ctx->entries_nr,
662-
midx_hash, WRITE_REV);
661+
tmp_file = write_rev_file_order(ctx->repo->hash_algo, NULL, ctx->pack_order,
662+
ctx->entries_nr, midx_hash, WRITE_REV);
663663

664664
if (finalize_object_file(tmp_file, buf.buf))
665665
die(_("cannot store reverse index file"));

0 commit comments

Comments
 (0)