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>

Taylor Blau committed Oct 15, 2025 at 18:27 UTC c660b0dbcbb70647f5103a4573963397522a1f0f
1 file changed +8 -5
builtin/repack.c
+8 -5
@@ -1073,7 +1073,8 @@ static void remove_redundant_bitmaps(struct string_list *include,
1073 strbuf_release(&path);
1074 }
1075
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,
1078 struct string_list *names,
1079 int local)
1080 {
@@ -1084,7 +1085,7 @@ static int finish_pack_objects_cmd(struct child_process *cmd,
1085 while (strbuf_getline_lf(&line, out) != EOF) {
1086 struct string_list_item *item;
1087
1087 - if (line.len != the_hash_algo->hexsz)
1088 + if (line.len != algop->hexsz)
1089 die(_("repack: Expecting full hex object ID lines only "
1090 "from pack-objects."));
1091 /*
@@ -1150,7 +1151,8 @@ static int write_filtered_pack(const struct pack_objects_args *args,
1151 fprintf(in, "%s%s.pack\n", caret, item->string);
1152 fclose(in);
1153
1153 - return finish_pack_objects_cmd(&cmd, names, local);
1154 + return finish_pack_objects_cmd(existing->repo->hash_algo, &cmd, names,
1155 + local);
1156 }
1157
1158 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,
1249 fprintf(in, "%s.pack\n", item->string);
1250 fclose(in);
1251
1250 - return finish_pack_objects_cmd(&cmd, names, local);
1252 + return finish_pack_objects_cmd(existing->repo->hash_algo, &cmd, names,
1253 + local);
1254 }
1255
1256 static const char *find_pack_prefix(const char *packdir, const char *packtmp)
@@ -1534,7 +1537,7 @@ int cmd_repack(int argc,
1537 fclose(in);
1538 }
1539
1537 - ret = finish_pack_objects_cmd(&cmd, &names, 1);
1540 + ret = finish_pack_objects_cmd(repo->hash_algo, &cmd, &names, 1);
1541 if (ret)
1542 goto cleanup;
1543