fetch-pack: don't needlessly copy fsck_options

Change the behavior of the .gitmodules validation added in 5476e1efde (fetch-pack: print and use dangling .gitmodules, 2021-02-22) so we're using one "fsck_options". I found that code confusing to read. One might think that not setting up the error_func earlier means that we're relying on the "error_func" not being set in some code in between the two hunks being modified here. But we're not, all we're doing in the rest of "cmd_index_pack()" is further setup by calling fsck_set_msg_types(), and assigning to do_fsck_object. So there was no reason in 5476e1efde to make a shallow copy of the fsck_options struct before setting error_func. Let's just do this setup at the top of the function, along with the "walk" assignment. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 28, 2021 at 15:15 UTC 462f5cae0f764569da4e6a7ab40ee1d3b85353ed
1 file changed +3 -7
builtin/index-pack.c
+3 -7
@@ -1761,6 +1761,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1761
1762 read_replace_refs = 0;
1763 fsck_options.walk = mark_link;
1764 + fsck_options.error_func = print_dangling_gitmodules;
1765
1766 reset_pack_idx_option(&opts);
1767 git_config(git_index_pack_config, &opts);
@@ -1951,13 +1952,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1952 else
1953 close(input_fd);
1954
1954 - if (do_fsck_object) {
1955 - struct fsck_options fo = fsck_options;
1956 -
1957 - fo.error_func = print_dangling_gitmodules;
1958 - if (fsck_finish(&fo))
1959 - die(_("fsck error in pack objects"));
1960 - }
1955 + if (do_fsck_object && fsck_finish(&fsck_options))
1956 + die(_("fsck error in pack objects"));
1957
1958 free(objects);
1959 strbuf_release(&index_name_buf);