From: mail@abhinavg.net
To: git@vger.kernel.org, Phillip Wood <phillip.wood@dunelm.org.uk>,
gitster@pobox.com
Cc: Abhinav Gupta <mail@abhinavg.net>
Subject: [PATCH v3 1/1] rebase: ignore non-branch update-refs
Date: Sun, 10 May 2026 15:41:11 -0700 [thread overview]
Message-ID: <20260510224111.64467-2-mail@abhinavg.net> (raw)
In-Reply-To: <20260510224111.64467-1-mail@abhinavg.net>
From: Abhinav Gupta <mail@abhinavg.net>
The following Git configuration breaks git rebase --update-refs:
[rebase]
instructionFormat = %s%d
The '%d' format requests all available decorations for a commit,
filling the global decoration table with all of them,
which --update-refs then uses to populate 'update-ref' instructions
in the rebase todo list.
Specifically, this results in the following instruction:
update-ref HEAD
The todo parser then rejects the instruction:
error: update-ref requires a fully qualified refname e.g. refs/heads/HEAD
error: invalid line 3: update-ref HEAD
To fix, ignore decorations that are not local branches
when scanning through the table.
This matches the documented contract:
it moves branch refs under refs/heads/
and leaves display-only decorations (HEAD, tags, etc.) alone.
Verification:
A regression test that fails without this fix is included.
Signed-off-by: Abhinav Gupta <mail@abhinavg.net>
---
Updates:
v2: incorporate suggestions to simplify the test
v3: merge two if statements into one
sequencer.c | 8 +++++++-
t/t3404-rebase-interactive.sh | 18 ++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/sequencer.c b/sequencer.c
index b7d8dca47f..ca3ea863d6 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -6431,8 +6431,14 @@ static int add_decorations_to_list(const struct commit *commit,
/*
* If the branch is the current HEAD, then it will be
* updated by the default rebase behavior.
+ * Exclude it from the list of refs to update,
+ * as well as any non-branch decorations.
+ * Non-branch decorations may be present if the pretty format
+ * includes "%d", which would have loaded all refs
+ * into the global decoration table.
*/
- if (head_ref && !strcmp(head_ref, decoration->name)) {
+ if ((head_ref && !strcmp(head_ref, decoration->name)) ||
+ (decoration->type != DECORATION_REF_LOCAL)) {
decoration = decoration->next;
continue;
}
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 3e44562afa..58b3bb0c27 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1960,6 +1960,24 @@ test_expect_success '--update-refs adds commands with --rebase-merges' '
)
'
+test_expect_success '--update-refs ignores non-branch decorations' '
+ test_when_finished "git branch -D update-refs" &&
+ test_when_finished "git checkout primary" &&
+ git checkout -B update-refs no-conflict-branch &&
+ (
+ set_cat_todo_editor &&
+
+ # rebase.instructionFormat=%d loads normal log decorations before
+ # --update-refs adds its branch placeholders so we must ignore
+ # all non-local decorations.
+ test_must_fail git -c rebase.instructionFormat="%s%d" \
+ rebase -i --update-refs HEAD^ >todo
+ ) &&
+ grep ^update-ref todo >actual &&
+ test_write_lines "update-ref refs/heads/no-conflict-branch" >expect &&
+ test_cmp expect actual
+'
+
test_expect_success '--update-refs updates refs correctly' '
git checkout -B update-refs no-conflict-branch &&
git branch -f base HEAD~4 &&
--
2.54.0
next prev parent reply other threads:[~2026-05-10 22:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 2:39 [PATCH] rebase: ignore non-branch update-refs mail
2026-05-07 16:08 ` Phillip Wood
2026-05-08 1:58 ` [PATCH v2] " mail
2026-05-08 10:07 ` Phillip Wood
2026-05-10 22:41 ` [PATCH v3 0/1] " mail
2026-05-10 22:41 ` mail [this message]
2026-05-10 1:11 ` [PATCH] " Junio C Hamano
2026-05-10 13:37 ` Phillip Wood
2026-05-10 23:37 ` Junio C Hamano
2026-05-11 0:15 ` Abhinav Gupta
2026-05-11 0:20 ` Junio C Hamano
2026-05-11 0:33 ` Abhinav Gupta
2026-05-12 15:10 ` Phillip Wood
2026-05-15 15:40 ` Phillip Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260510224111.64467-2-mail@abhinavg.net \
--to=mail@abhinavg.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox