Instead of waiting for a non-trivial GC command to write the commit-graph, write one during 'git fetch'. By using the equivalent method for 'git commit-graph write --split --reachable', we create a commit-graph chain that includes all reachable commits. Most of the time, these writes only add the newly-downloaded commits in a small file at the top of the commit-graph chain. Commits that are no longer reachable still exist in the commit-graph, but will be cleaned up by a later GC command that forces the commit-graph to be rewritten completely. A version of this patch [1] used to be a part of ds/commit-graph-incremental, but was removed to focus on the incremental commit-graph file format. Now that the incremental file format has been shipped in v2.23.0 and some config things have adjusted in ds/feature-macros, I'm reintroducing the idea. Ævar had mentioned wanting to do something with "incremental maintenance during GC" [2]. I haven't seen any patches towards that aim (please point me in that direction if they have been submitted). I still think it is worth allowing a write at fetch time, as some users have GC disabled. I know for sure that users who only interact with their Git repos via Visual Studio Team Explorer have all Git commands running with GC disabled, and likely other desktop GUI clients have it disabled to avoid blocking processes. Aside: VFS for Git users have GC disabled, but the commit-graph is being written in the background by a monitoring process. We shipped the incremental commit-graph writes in a recent version and reduced our writes from ~60 seconds each to less than a second on average. Very rarely, the layers of the commit-graph chain collapse and return to the old values. This feature has been performing well with no known issues. Thanks, -Stolee [1] https://public-inbox.org/git/3c52385e5696887c40cab4a6b9b7923d60a0567c.1557330827.git.gitgitgadget@xxxxxxxxx/ [2] https://public-inbox.org/git/b1de6af2-c015-098e-a656-e1b68056e037@xxxxxxxxx/ Derrick Stolee (1): fetch: add fetch.writeCommitGraph config setting Documentation/config/feature.txt | 8 ++++++++ Documentation/config/fetch.txt | 10 ++++++++++ builtin/fetch.c | 15 +++++++++++++++ repo-settings.c | 4 ++++ repository.h | 1 + t/t5510-fetch.sh | 13 +++++++++++++ 6 files changed, 51 insertions(+) base-commit: aaf633c2ad10b47af7623c130ddfe7231658c7e4 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-328%2Fderrickstolee%2Ffetch-write-commit-graph-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-328/derrickstolee/fetch-write-commit-graph-v1 Pull-Request: https://github.com/gitgitgadget/git/pull/328 -- gitgitgadget