Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"refusing to update ref with bad name" when using `git rebase --rebase-merges`

I've recently had to look at git rebase --rebase-merges, but I'm not having much luck.

I maintain a fork of the Rust compiler and I've just recently merged in upstream, fixing a ton of merge conflicts along the way. Then I had to do a second merge, as I got unlucky and the upstream repo was busted at the time I did the first merge.

I was hoping to use git rebase -i --rebase-merges to squash my two merges together, but preserving the nested merges created upstream (if that's even possible).

The problem is, whatever I try I get this error message:

$ git rebase --rebase-merges -i sd-upstream/master                                                                         
error: refusing to update ref with bad name 'refs/rewritten/Auto-merge-of-#65134---davidtwco:issue-19834-improper-ctypes-in-extern-C-fn,-r=rkruppe'
hint: Could not execute the todo command
hint: 
hint:     label Auto-merge-of-#65134---davidtwco:issue-19834-improper-ctypes-in-extern-C-fn,-r=rkruppe
hint: 
hint: It has been rescheduled; To edit the command before continuing, please
hint: edit the todo list first:
hint: 
hint:     git rebase --edit-todo
hint:     git rebase --continue

(In the above sd-upstream is my organisation's upstream, not Rust's -- I'm rebasing against the tree before my branch with the merges on)

I get the above error even when I make no changes to the todo.

Am I doing something wrong, or is that a git bug? Looks like git is choking on the commit message auto-generated by Bors (a bot used by the Rust team to do rollup merges and the like).

I'm using git-2.20.1 on Debian 10.

like image 311
Edd Barrett Avatar asked Mar 02 '23 19:03

Edd Barrett


1 Answers

There was a bug in --rebase-merges that was fixed in Git 2.25:

  • A label used in the todo list that are generated by "git rebase --rebase-merges" is used as a part of a refname; the logic to come up with the label has been tightened to avoid names that cannot be used as such.

Along with that bug was a related one:

  • The logic to avoid duplicate label names generated by "git rebase --rebase-merges" forgot that the machinery itself uses "onto" as a label name, which must be avoided by auto-generated labels, which has been corrected.

(Both of these are from the Git 2.25 release notes.)

If you upgrade your Git to version 2.25, the problem should go away. Until then, the best advice I have is "don't use --rebase-merges".

like image 91
torek Avatar answered Mar 05 '23 16:03

torek