提交 edb0e04e 编写于 作者: B Brandon Casey 提交者: Shawn O. Pearce

git-gc: by default use safer "-A" option to repack when not --prune'ing

This makes use of repack's new "-A" option which does not drop packed
unreachable objects. This makes git-gc safe to call at any time,
particularly when a repository is referenced as an alternate by
another repository.

git-gc --prune will use the "-a" option to repack instead of "-A", so
that packed unreachable objects will be removed.
Signed-off-by: NBrandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: NLars Hjemli <hjemli@gmail.com>
Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
上级 2f27f850
......@@ -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};
......@@ -211,6 +211,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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册