List of all commands that cause git gc --auto

独自空忆成欢 提交于 2019-11-27 05:15:39
builtin/merge.c:            const char *argv_gc_auto[] = { "gc", "--auto", NULL };
builtin/receive-pack.c:     "gc", "--auto", "--quiet", NULL,
git-am.sh:                  git gc --auto
git-rebase--interactive.sh: git gc --auto &&
git-svn.perl:               command_noisy('gc', '--auto');

From git grep -- --auto on git.git, those results looked interesting. The notable one is builtin/merge.c meaning that the ever so common git pull should trigger a git gc --auto.

Additionally, unless your 'non-technical' staff is doing rather 'advanced' stuff (at which point they wouldn't be 'non-technical' anymore), I don't see why they would ever need to run git gc manually instead of just letting git gc --auto handle everything.

With Git 2.17 (Q2 2018), you will have to add git commit to the list of commands triggering a git gc --auto.
Actually, that should have been the case since the beginning of Git.

See commit 095c741 (28 Feb 2018) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit 9bb8eb0, 08 Mar 2018)

commit: run git gc --auto just before the post-commit hook

Change the behavior of git-commit back to what it was back in d4bb43e ("Invoke "git gc --auto" from commit, merge, am and rebase.", 2007-09-05, Git v1.5.4-rc0) when it was git-commit.sh.

Shortly afterwards in f5bbc32 ("Port git commit to C.", 2007-11-08, Git v1.5.4-rc0) when it was ported to C, the "git gc --auto" invocation went away.

Since that unintended regression, git gc --auto only ran for git-am, git-merge, git-fetch, and git-receive-pack.
It was possible to write a script that would "git commit" a lot of data locally, and gc would never run.

One such repository that was locally committing generated zone file changes had grown to a size of ~60GB before a daily cronjob was added to "git gc", bringing it down to less than 1GB. This will make such cases work without intervention.

I think fixing such pathological cases where the repository will grow forever is a worthwhile trade-off for spending a couple of milliseconds calling "git gc --auto" (in the common cases where it doesn't do anything).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!