Skip to content

auto-rebase: add -f to the filter-branch invocation#432514

Merged
MattSturgeon merged 1 commit into
NixOS:masterfrom
Ma27:auto-rebase-fix
Mar 31, 2026
Merged

auto-rebase: add -f to the filter-branch invocation#432514
MattSturgeon merged 1 commit into
NixOS:masterfrom
Ma27:auto-rebase-fix

Conversation

@Ma27

@Ma27 Ma27 commented Aug 10, 2025

Copy link
Copy Markdown
Member

...because it tells me to do so:

+ git filter-branch --parent-filter 'sed '\''s/2140bf39e41767f25a395d20fb0d5698b8934b33/374e6bcc403e02a35e07b650463c01a52b13a7c8/'\''' --tree-filter 'nix-shell --run treefmt' 374e6bcc403e02a35e07b650463c01a52b13a7c8..HEAD Cannot create a new backup. A previous backup already exists in refs/original/ Force overwriting the backup with -f

If this is the wrong thing to do, feel free to propose a better solution. I just want this to work somewhat reliably.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

...because it tells me to do so:

    + git filter-branch --parent-filter 'sed '\''s/2140bf39e41767f25a395d20fb0d5698b8934b33/374e6bcc403e02a35e07b650463c01a52b13a7c8/'\''' --tree-filter 'nix-shell --run treefmt' 374e6bc..HEAD
    Cannot create a new backup.
    A previous backup already exists in refs/original/
    Force overwriting the backup with -f
@Ma27 Ma27 requested a review from infinisil August 10, 2025 12:26
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 10, 2025
@Ma27

Ma27 commented Aug 10, 2025

Copy link
Copy Markdown
Member Author

That beign said, I get unrelated conflicts in Nix snippets in markdown files. So it seems the treefmt.toml is somewhat off?

@Ma27

Ma27 commented Aug 10, 2025

Copy link
Copy Markdown
Member Author

Yeah, the first commit from the patchset I rebased contains every single Nix-in-markdown snippet reformatted 🤡

@wolfgangwalther

wolfgangwalther commented Aug 10, 2025

Copy link
Copy Markdown
Contributor

Yeah, the first commit from the patchset I rebased contains every single Nix-in-markdown snippet reformatted 🤡

This means you likely ran an outdated version of treefmt, not from the latest master branch. Formatting these codeblocks was introduced in #427460.

Edit: Although... if you get the reformatting for the codeblocks, but their format changes.. that looks more like "latest treefmt, but outdated nixfmt". You might need to run all of these inside a nix-shell, so that the nixfmt available is 1.0.0. It could be that you ran it outside a nix-shell and had system-wide nixfmt installed from nixfmt-classic or so?

@Ma27

Ma27 commented Aug 23, 2025

Copy link
Copy Markdown
Member Author

Edit: Although... if you get the reformatting for the codeblocks, but their format changes.. that looks more like "latest treefmt, but outdated nixfmt". You might need to run all of these inside a nix-shell, so that the nixfmt available is 1.0.0. It could be that you ran it outside a nix-shell and had system-wide nixfmt installed from nixfmt-classic or so?

Probably. I guess I should revise my entire dev setup for nixpkgs now to avoid further of these issues.

The change itself should still be valid, no? @wolfgangwalther

@wolfgangwalther

Copy link
Copy Markdown
Contributor

tbh, I don't know whether that's the correct change or whether it should not even get there, so something else would be off. I have never used that script myself either.

@Ma27

Ma27 commented Aug 23, 2025

Copy link
Copy Markdown
Member Author

ping @infinisil then.

@nixpkgs-ci nixpkgs-ci Bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 21, 2026
@Ma27

Ma27 commented Mar 28, 2026

Copy link
Copy Markdown
Member Author

ping @NixOS/nix-formatting

@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 29, 2026
@dyegoaurelio

Copy link
Copy Markdown
Contributor

I didn't manage to reproduce the issue

What's the diff you're actually encountering in the markdown files?
What branch are you trying to rebase (to and from) ?

@infinisil

Copy link
Copy Markdown
Member

Iirc the script also failed for me when I actually wanted to use it in practice. Pretty disappointing because I even wrote a test for it :/

Regardless, this change is fine imo

@jfly jfly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Honestly have very little context on this codepath, but it seems low-risk to me, as we have branch protection enabled in this repo.

# - The tree filter runs the command on each of our own commits,
# effectively reapplying it.
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch \
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Personally I'd prefer to use verbose CLI flags in script sources, as they add additional self-documenting context.

Suggested change
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f \
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --force \

@MattSturgeon MattSturgeon added this pull request to the merge queue Mar 31, 2026
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 2 This PR was reviewed and approved by two persons. label Mar 31, 2026
Merged via the queue into NixOS:master with commit 3f2f8ce Mar 31, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants