From: Junio C Hamano Date: Tue, 26 Jan 2016 23:40:29 +0000 (-0800) Subject: Merge branch 'js/close-packs-before-gc' X-Git-Tag: v2.8.0-rc0~100 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3c809405cb35679dd5205bf0ea118b7ee9256abb?hp=-c Merge branch 'js/close-packs-before-gc' 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 --- 3c809405cb35679dd5205bf0ea118b7ee9256abb diff --combined builtin/fetch.c index 33f04c1b4a,5b58001a98..8e742135f0 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@@ -37,7 -37,6 +37,7 @@@ static int prune = -1; /* unspecified * static int all, append, dry_run, force, keep, multiple, update_head_ok, verbosity; static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT; static int tags = TAGS_DEFAULT, unshallow, update_shallow; +static int max_children = 1; static const char *depth; static const char *upload_pack; static struct strbuf default_rla = STRBUF_INIT; @@@ -100,8 -99,6 +100,8 @@@ static struct option builtin_fetch_opti N_("fetch all tags and associated objects"), TAGS_SET), OPT_SET_INT('n', NULL, &tags, N_("do not fetch all tags (--no-tags)"), TAGS_UNSET), + OPT_INTEGER('j', "jobs", &max_children, + N_("number of submodules fetched in parallel")), OPT_BOOL('p', "prune", &prune, N_("prune remote-tracking branches no longer on remote")), { OPTION_CALLBACK, 0, "recurse-submodules", NULL, N_("on-demand"), @@@ -840,7 -837,7 +840,7 @@@ static void check_not_current_branch(st static int truncate_fetch_head(void) { const char *filename = git_path_fetch_head(); - FILE *fp = fopen(filename, "w"); + FILE *fp = fopen_for_writing(filename); if (!fp) return error(_("cannot open %s: %s\n"), filename, strerror(errno)); @@@ -1216,8 -1213,7 +1216,8 @@@ int cmd_fetch(int argc, const char **ar result = fetch_populated_submodules(&options, submodule_prefix, recurse_submodules, - verbosity < 0); + verbosity < 0, + max_children); argv_array_clear(&options); } @@@ -1225,6 -1221,8 +1225,8 @@@ 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"); diff --combined builtin/receive-pack.c index 2b3b746fb4,b3104433ed..f2d6761af6 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@@ -1618,7 -1618,7 +1618,7 @@@ static void prepare_shallow_update(stru continue; si->need_reachability_test[i]++; for (k = 0; k < 32; k++) - if (si->used_shallow[i][j] & (1 << k)) + if (si->used_shallow[i][j] & (1U << k)) si->shallow_ref[j * 32 + k]++; } @@@ -1796,6 -1796,7 +1796,7 @@@ int cmd_receive_pack(int argc, const ch "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) diff --combined t/t5510-fetch.sh index 47e68a597c,e3ee4bd700..9203a6507f --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@@ -7,7 -7,7 +7,7 @@@ test_description='Per branch config var . ./test-lib.sh -D=`pwd` +D=$(pwd) test_bundle_object_count () { git verify-pack -v "$1" >verify.out && @@@ -64,8 -64,8 +64,8 @@@ test_expect_success "fetch test" cd two && git fetch && test -f .git/refs/heads/one && - mine=`git rev-parse refs/heads/one` && - his=`cd ../one && git rev-parse refs/heads/master` && + mine=$(git rev-parse refs/heads/one) && + his=$(cd ../one && git rev-parse refs/heads/master) && test "z$mine" = "z$his" ' @@@ -75,8 -75,8 +75,8 @@@ test_expect_success "fetch test for-mer git fetch && test -f .git/refs/heads/two && test -f .git/refs/heads/one && - master_in_two=`cd ../two && git rev-parse master` && - one_in_two=`cd ../two && git rev-parse one` && + master_in_two=$(cd ../two && git rev-parse master) && + one_in_two=$(cd ../two && git rev-parse one) && { echo "$one_in_two " echo "$master_in_two not-for-merge" @@@ -708,4 -708,17 +708,17 @@@ test_expect_success 'fetching a one-lev ) ' + 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