git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] rebase: ignore non-branch update-refs

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
May 8, 2026, 10:07 UTC
Message-ID
<d9128068-d5e3-4a81-a4d6-b94bfc7d3717@gmail.com>
In-Reply-To
<20260508015817.86177-1-mail@abhinavg.net>
Hi Abhinav
Thanks for re-working the test - this looks great.
Phillip
On 08/05/2026 02:58, mail@abhinavg.net wrote:
Show 92 quoted lines
> 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
> 
>   sequencer.c                   | 10 ++++++++++
>   t/t3404-rebase-interactive.sh | 18 ++++++++++++++++++
>   2 files changed, 28 insertions(+)
> 
> diff --git a/sequencer.c b/sequencer.c
> index b7d8dca47f..25bcfc5da0 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -6428,6 +6428,16 @@ static int add_decorations_to_list(const struct commit *commit,
>   		const char *path;
>   		size_t base_offset = ctx->buf->len;
>   
> +		/*
> +		 * The global decoration table may contain names loaded by
> +		 * a previous pretty format such as "%d".
> +		 * This will result in refs such as "HEAD" being present.
> +		 */
> +		if (decoration->type != DECORATION_REF_LOCAL) {
> +			decoration = decoration->next;
> +			continue;
> +		}
> +
>   		/*
>   		 * If the branch is the current HEAD, then it will be
>   		 * updated by the default rebase behavior.
> 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 &&
> 
> base-commit: 94f057755b7941b321fd11fec1b2e3ca5313a4e0
Previous: mail@abhinavg.netNext: mail@abhinavg.net
Message 4 of 14 in “rebase: ignore non-branch update-refs”
  1. rebase: ignore non-branch update-refsmail@abhinavg.net, May 6, 2026
  2. Phillip WoodMay 7, 2026
  3. rebase: ignore non-branch update-refsmail@abhinavg.net, May 8, 2026
  4. Phillip WoodMay 8, 2026
  5. 0/1 rebase: ignore non-branch update-refsmail@abhinavg.net, May 10, 2026
  6. 1/1 rebase: ignore non-branch update-refsmail@abhinavg.net, May 10, 2026
  7. Junio C HamanoMay 10, 2026
  8. Phillip WoodMay 10, 2026
  9. Junio C HamanoMay 10, 2026
  10. Abhinav GuptaMay 11, 2026
  11. Junio C HamanoMay 11, 2026
  12. Abhinav GuptaMay 11, 2026
  13. Phillip WoodMay 12, 2026
  14. Phillip WoodMay 15, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.