Skip to content

remove --prune from git fetch to avoid side-effects with read-only filesystems (#13645)#13679

Open
Byron wants to merge 1 commit intogitbutlerapp:masterfrom
Byron:remove-fetch-prune
Open

remove --prune from git fetch to avoid side-effects with read-only filesystems (#13645)#13679
Byron wants to merge 1 commit intogitbutlerapp:masterfrom
Byron:remove-fetch-prune

Conversation

@Byron
Copy link
Copy Markdown
Collaborator

@Byron Byron commented May 7, 2026

When a ref refs/heads/head exists on the remote, it creates ambiguity with the equally present refs/remotes/origin/HEAD when fetching to a local clone. If the remote HEAD points to refs/heads/main and we have a packed-refs file on a case-sensitive filesystem that looks like

    # pack-refs with: peeled fully-peeled sorted
   c30c646d31032f05ad62e5d2a967298c33df0f6f refs/remotes/origin/head
   c30c646d31032f05ad62e5d2a967298c33df0f6f refs/remotes/origin/main

Then --prune will somehow complain about origin/head and completely remove origin/main from packed-refs.

So removing --prune fixes this, but it will also leave the remote-ref cleanup to the users.

Separating this into specific on-demand maintenance seems like a good idea.

Note that with ref-tables, this will not be an issue, but in general, auto-pruning as an operation that removes refs that the user might expect seems to be something to avoid as well.

Fixes #13645.

…y filesystems (gitbutlerapp#13645)

When a ref `refs/heads/head` exists on the remote, it creates ambiguity with the equally
present `refs/remotes/origin/HEAD` when fetching to a local clone.
If the remote `HEAD` points to `refs/heads/main` and we have a packed-refs file
on a case-sensitive filesystem that looks like

   1 │ # pack-refs with: peeled fully-peeled sorted
   2 │ c30c646d31032f05ad62e5d2a967298c33df0f6f refs/remotes/origin/head
   3 │ c30c646d31032f05ad62e5d2a967298c33df0f6f refs/remotes/origin/main

Then `--prune` will *somehow* complain about `origin/head` and completely remove
`origin/main` from packed-refs.

So removing `--prune` fixes this, but it will also leave the remote-ref cleanup
to the users.

Separating this into specific on-demand maintenance seems like a good idea.

Note that with ref-tables, this will not be an issue, but in general, auto-pruning
as an operation that removes refs that the user might expect seems to be something
to avoid as well.
Copilot AI review requested due to automatic review settings May 7, 2026 02:06
@Byron Byron requested a review from krlvi May 7, 2026 02:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts GitButler’s Git fetch wrapper to avoid automatic ref pruning, preventing destructive side effects in edge cases (notably when the remote contains a branch named head that can collide with origin/HEAD on some filesystems and lead to unexpected packed-refs rewrites).

Changes:

  • Remove --prune from the git fetch invocation used by crates/gitbutler-git’s repository fetch helper.

@Byron
Copy link
Copy Markdown
Collaborator Author

Byron commented May 7, 2026

@krlvi --prune was probably added for a reason even though now there is a good reason to remove it as well. The question is which incentive is more important.
It's notable that with ref-table support in Git3 the problem solves itself, and --prune can be used again without such side-effects on case-insensitive filesystems.

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8af6544dd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/gitbutler-git/src/repository.rs
@krlvi
Copy link
Copy Markdown
Member

krlvi commented May 7, 2026

i think the prune was added because at some point we had gitbutler disable GC which was later removed. And this can now be removed too

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.

Cannot use GitButler if remote has a branch named "head"

3 participants