Merge branch 'js/close-packs-before-gc' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 5 Feb 2016 22:54:13 +0000 (14:54 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Feb 2016 22:54:13 +0000 (14:54 -0800)
Many codepaths that run "gc --auto" before exiting kept packfiles
mapped and left the file descriptors to them open, which was not
friendly to systems that cannot remove files that are open. They
now close the packs before doing so.

* js/close-packs-before-gc:
receive-pack: release pack files before garbage-collecting
merge: release pack files before garbage-collecting
am: release pack files before garbage-collecting
fetch: release pack files before garbage-collecting

builtin/am.c
builtin/fetch.c
builtin/merge.c
builtin/receive-pack.c
t/t5510-fetch.sh
index 9fb42fdd714a7785f6d75486db0d48fecceaacd6..de235cf11a9df925f482d02ec0df7c6e748ff35d 100644 (file)
@@ -1939,6 +1939,7 @@ static void am_run(struct am_state *state, int resume)
         */
        if (!state->rebasing) {
                am_destroy(state);
+               close_all_packs();
                run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
        }
 }
index 9e24bb485f4ba438c8e3cd84856b13f4ab7fa927..17f40e10f6960e73fa1bff0024c7e1a09a1d8503 100644 (file)
@@ -1221,6 +1221,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        list.strdup_strings = 1;
        string_list_clear(&list, 0);
 
+       close_all_packs();
+
        argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
        if (verbosity < 0)
                argv_array_push(&argv_gc_auto, "--quiet");
index 15bf95b3ac6c54727992103b1943515a1da32ff4..b98a3489bf24c0726b3847704e7ec0b658a79e51 100644 (file)
@@ -404,6 +404,7 @@ static void finish(struct commit *head_commit,
                         * We ignore errors in 'gc --auto', since the
                         * user should see them.
                         */
+                       close_all_packs();
                        run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
                }
        }
index 2b3b746fb40d7a3da9cefd4688b6f60efde10c24..f2d6761af66c8bcc43c2da13f69fa083cf1e1e60 100644 (file)
@@ -1796,6 +1796,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
                                "gc", "--auto", "--quiet", NULL,
                        };
                        int opt = RUN_GIT_CMD | RUN_COMMAND_STDOUT_TO_STDERR;
+                       close_all_packs();
                        run_command_v_opt(argv_gc_auto, opt);
                }
                if (auto_update_server_info)
index 0ba9db08847255d28e3e185d18b68703fb0755dc..e3ee4bd700c3e72479ce1c7a4d8b1333a35a8473 100755 (executable)
@@ -708,4 +708,17 @@ test_expect_success 'fetching a one-level ref works' '
        )
 '
 
+test_expect_success 'fetching with auto-gc does not lock up' '
+       write_script askyesno <<-\EOF &&
+       echo "$*" &&
+       false
+       EOF
+       git clone "file://$D" auto-gc &&
+       test_commit test2 &&
+       cd auto-gc &&
+       git config gc.autoPackLimit 1 &&
+       GIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 &&
+       ! grep "Should I try again" fetch.out
+'
+
 test_done