X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=inline;f=builtin-gc.c;h=956c32d1af66444dae26a705159beba9adb7aba7;hb=4d4fcc5451d9d653bebcc8afa18543cb426abeed;hp=23ad2b6a21a81f469e813173ba04d626949e972f;hpb=61ab92df40b2c256299ad3d812ee0de14353098d;p=git.git diff --git a/builtin-gc.c b/builtin-gc.c index 23ad2b6a2..956c32d1a 100644 --- a/builtin-gc.c +++ b/builtin-gc.c @@ -26,7 +26,7 @@ static int gc_auto_pack_limit = 20; #define MAX_ADD 10 static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL}; static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL}; -static const char *argv_repack[MAX_ADD] = {"repack", "-a", "-d", "-l", NULL}; +static const char *argv_repack[MAX_ADD] = {"repack", "-d", "-l", NULL}; static const char *argv_prune[] = {"prune", NULL}; static const char *argv_rerere[] = {"rerere", "gc", NULL}; @@ -143,8 +143,6 @@ static int too_many_packs(void) static int need_to_gc(void) { - int ac = 0; - /* * Setting gc.auto and gc.autopacklimit to 0 or negative can * disable the automatic gc. @@ -158,14 +156,10 @@ static int need_to_gc(void) * we run "repack -A -d -l". Otherwise we tell the caller * there is no need. */ - argv_repack[ac++] = "repack"; if (too_many_packs()) - argv_repack[ac++] = "-A"; + append_option(argv_repack, "-A", MAX_ADD); else if (!too_many_loose_objects()) return 0; - argv_repack[ac++] = "-d"; - argv_repack[ac++] = "-l"; - argv_repack[ac++] = NULL; return 1; } @@ -211,6 +205,16 @@ int cmd_gc(int argc, const char **argv, const char *prefix) prune = 0; if (!need_to_gc()) return 0; + } else { + /* + * Use safer (for shared repos) "-A" option to + * repack when not pruning. Auto-gc makes its + * own decision. + */ + if (prune) + append_option(argv_repack, "-a", MAX_ADD); + else + append_option(argv_repack, "-A", MAX_ADD); } if (pack_refs && run_command_v_opt(argv_pack_refs, RUN_GIT_CMD))