Skip to content

Disable automatic Git maintenance in cloner#4554

Merged
doriable merged 1 commit into
bufbuild:mainfrom
winor30:remove-git-metadata-from-clone
Jun 1, 2026
Merged

Disable automatic Git maintenance in cloner#4554
doriable merged 1 commit into
bufbuild:mainfrom
winor30:remove-git-metadata-from-clone

Conversation

@winor30
Copy link
Copy Markdown
Contributor

@winor30 winor30 commented May 24, 2026

What

This disables Git's automatic maintenance while the git cloner is preparing a temporary checkout for CloneToBucket.

The cloner now passes these config overrides to the Git commands that operate on the temporary clone:

-c maintenance.auto=false
-c maintenance.autoDetach=false
-c gc.auto=0
-c gc.autoDetach=false
-c fetch.writeCommitGraph=false

The regression test checks the actual Git argv via GIT_TRACE2_EVENT, so it pins down that these options are passed before fetch, checkout, and submodule.

Why

I ran into this through bufbuild/buf-breaking-action@v1 on GitHub Actions. The action failed while cloning the against input with missing files under .git:

Failure: could not clone https://github.com/winor30/buf-breaking-repro.git: stat .git/objects/bitmap-ref-tips_4VcgMk: file does not exist                                                                                                                                                                                      stat .git/info/refs_9E0SyG: file does not exist

That run was on ubuntu-24.04 with Git 2.54.0.

The cloner creates a temporary Git repository, runs fetch/checkout/optional submodule commands, and then copies the result into a storage bucket. In the affected path, .git files can be part of that copy. If Git kicks off automatic maintenance or GC around the same time, it can create and remove temporary files under .git while storage.Copy is walking the directory. That leaves storage.Copy with a path it saw during the walk, but can no longer stat/open.
I verified the race with a local reproducer that puts a small git wrapper at the front of PATH. The wrapper delegates to the real Git binary, but after git fetch it simulates background Git maintenance by creating files under .git/buf-copy-race and deleting them while CloneToBucket is copying the checkout.

On main, cloning with no matcher fails in the same way:

CloneToBucket error: stat .git/buf-copy-race/file-0: file does not exist

On this branch, the same reproducer passes because the maintenance-simulating path is not started.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 24, 2026

CLA assistant check
All committers have signed the CLA.

@winor30 winor30 force-pushed the remove-git-metadata-from-clone branch from e177076 to 35335a5 Compare May 25, 2026 23:49
Copy link
Copy Markdown
Member

@doriable doriable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense and looks good to me! Thank you for this contribution.

@doriable doriable merged commit 74b0287 into bufbuild:main Jun 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants