{"thread":{"id":"64637","subject":"rebasing on top of reformatted branch","startedAt":"2025-12-17T06:40:32Z","lastAt":"2025-12-17T08:57:09Z","messageCount":2,"participants":["Simon Richter","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"532321","messageId":"0e1e168e-e90c-4aba-a474-50d0df75a8e7@hogyros.de","threadId":"64637","inReplyTo":null,"subject":"rebasing on top of reformatted branch","fromName":"Simon Richter","fromEmail":"simon.richter@hogyros.de","sentAt":"2025-12-17T06:33:20Z","receivedAt":"2025-12-17T06:40:32Z","isPatch":false,"sender":{"key":"simon.richter@hogyros.de","avatar":"https://gravatar.com/avatar/1192aa9fa5dd19ce258b12b044cc27111dd7cdb58d920dc2123a02a24f55b5c5?d=mp&s=160"},"body":"Hi,\n\nI need to rebase a branch on top of a version that has had automatic \nformatting applied.\n\nMy usual approach for this is to create an empty extra commit after the \nbranch point, then filter-branch all the commits on my branch with the \nsame automatic formatting, then continue rebasing. Because the filter is \napplied to the tree, no three-way merges are performed, avoiding the \nconflicts.\n\nIs there a way to automate this in a nicer way, especially if I have \nmultiple branches that need to be rebased in this way?\n\n    Simon\n"},{"id":"532327","messageId":"c0a51f7f-2c3e-43b1-9e0b-668a450b0348@app.fastmail.com","threadId":"64637","inReplyTo":"0e1e168e-e90c-4aba-a474-50d0df75a8e7@hogyros.de","subject":"Re: rebasing on top of reformatted branch","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-12-17T08:56:48Z","receivedAt":"2025-12-17T08:57:09Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Dec 17, 2025, at 07:33, Simon Richter wrote:\n> I need to rebase a branch on top of a version that has had automatic\n> formatting applied.\n>\n> My usual approach for this is to create an empty extra commit after the\n> branch point, then filter-branch all the commits on my branch with the\n> same automatic formatting, then continue rebasing. Because the filter is\n> applied to the tree, no three-way merges are performed, avoiding the\n> conflicts.\n>\n> Is there a way to automate this in a nicer way, especially if I have\n> multiple branches that need to be rebased in this way?\n\nI haven’t tried it but git-test from git-branchless should be able to\nsolve this.[1][2]\n\n> > git-branchless’s git test command offers a solution to quickly run\n> > formatters, etc., on an entire stack of commits without causing merge\n> > conflicts.\n> > [...]\n> >     git test run --exec 'cargo fmt --all' --strategy worktree --jobs 8\n\nThat sounded great to me when I first read it (to transform the trees\nper snapshot). *Obvious in hindsight* considering the trend of\nautoformatters in various languages.\n\n🔗 1: https://blog.waleedkhan.name/formatting-a-commit-stack/\n† 2: Not to be confused with some git-test(1) scripts that run tests per\n     commit in a revision range and store failure/success\n\nI uninstalled git-branchless because it created so many weird refs and\nhooks and I didn’t understand the overarching goal of the command\nsuite. I still have hooks like this laying around. :)\n\n    #!/bin/sh\n    ## START BRANCHLESS CONFIG\n\n    # This hook has been uninstalled.\n    # Run `git branchless init` to reinstall.\n    ## END BRANCHLESS CONFIG\n"}]}