Skip to content

Commit c660b0d

Browse files
ttaylorrgitster
authored andcommitted
builtin/repack.c: avoid "the_hash_algo" in finish_pack_objects_cmd()
In a similar spirit as previous commits, avoid referring directly to "the_hash_algo" in builtin/repack.c::finish_pack_objects_cmd() and instead accept one as a parameter to the function. Since this function has a number of callers throughout the builtin, the diff is a little noisier than previous commits. However, each hunk is limited to passing the hash_algo parameter from a repository pointer that is already in scope. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a7a5a60 commit c660b0d

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

builtin/repack.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,8 @@ static void remove_redundant_bitmaps(struct string_list *include,
10731073
strbuf_release(&path);
10741074
}
10751075

1076-
static int finish_pack_objects_cmd(struct child_process *cmd,
1076+
static int finish_pack_objects_cmd(const struct git_hash_algo *algop,
1077+
struct child_process *cmd,
10771078
struct string_list *names,
10781079
int local)
10791080
{
@@ -1084,7 +1085,7 @@ static int finish_pack_objects_cmd(struct child_process *cmd,
10841085
while (strbuf_getline_lf(&line, out) != EOF) {
10851086
struct string_list_item *item;
10861087

1087-
if (line.len != the_hash_algo->hexsz)
1088+
if (line.len != algop->hexsz)
10881089
die(_("repack: Expecting full hex object ID lines only "
10891090
"from pack-objects."));
10901091
/*
@@ -1150,7 +1151,8 @@ static int write_filtered_pack(const struct pack_objects_args *args,
11501151
fprintf(in, "%s%s.pack\n", caret, item->string);
11511152
fclose(in);
11521153

1153-
return finish_pack_objects_cmd(&cmd, names, local);
1154+
return finish_pack_objects_cmd(existing->repo->hash_algo, &cmd, names,
1155+
local);
11541156
}
11551157

11561158
static void combine_small_cruft_packs(FILE *in, size_t combine_cruft_below_size,
@@ -1247,7 +1249,8 @@ static int write_cruft_pack(const struct pack_objects_args *args,
12471249
fprintf(in, "%s.pack\n", item->string);
12481250
fclose(in);
12491251

1250-
return finish_pack_objects_cmd(&cmd, names, local);
1252+
return finish_pack_objects_cmd(existing->repo->hash_algo, &cmd, names,
1253+
local);
12511254
}
12521255

12531256
static const char *find_pack_prefix(const char *packdir, const char *packtmp)
@@ -1534,7 +1537,7 @@ int cmd_repack(int argc,
15341537
fclose(in);
15351538
}
15361539

1537-
ret = finish_pack_objects_cmd(&cmd, &names, 1);
1540+
ret = finish_pack_objects_cmd(repo->hash_algo, &cmd, &names, 1);
15381541
if (ret)
15391542
goto cleanup;
15401543

0 commit comments

Comments
 (0)