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

[PATCH 1/2] t3404: add failing branch symref test

From
Son Luong Ngoc via GitGitGadget <gitgitgadget@gmail.com>
Date
May 28, 2026, 05:42 UTC
Message-ID
<a550923440a233daea0b9819e05d6c380de00d09.1779946921.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2126.git.1779946921.gitgitgadget@gmail.com>
From: Son Luong Ngoc <sluongng@gmail.com>

rebase --update-refs queues local branch decorations by their literal refnames. When a branch such as refs/heads/main is a symbolic ref to the current branch, the normal rebase path first updates the current branch and the queued symref update later tries to update the same referent with the old value it recorded before the rebase.

Add a known-breakage test that exercises this case so that the fix can flip it to test_expect_success. The expected behavior is that the branch symref keeps pointing at the rebased current branch.

Signed-off-by: Son Luong Ngoc <sluongng@gmail.com>
---
 t/t3404-rebase-interactive.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 58b3bb0c27..42ba8cc313 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1978,6 +1978,31 @@ test_expect_success '--update-refs ignores non-branch decorations' '
 	test_cmp expect actual
 '
 
+test_expect_failure '--update-refs skips branch symrefs to current branch' '
+	test_when_finished "
+		test_might_fail git rebase --abort &&
+		git checkout primary &&
+		test_might_fail git symbolic-ref -d refs/heads/update-refs-symref-alias &&
+		test_might_fail git branch -D update-refs-symref update-refs-symref-base
+	" &&
+	git checkout -B update-refs-symref-base primary &&
+	test_commit --no-tag update-refs-symref-base symref-base.t &&
+	git checkout -B update-refs-symref &&
+	test_commit --no-tag update-refs-symref-topic symref-topic.t &&
+	git checkout update-refs-symref-base &&
+	test_commit --no-tag update-refs-symref-newbase symref-newbase.t &&
+	git checkout update-refs-symref &&
+	git symbolic-ref refs/heads/update-refs-symref-alias refs/heads/update-refs-symref &&
+
+	git rebase --update-refs update-refs-symref-base 2>err &&
+
+	test_cmp_rev update-refs-symref-base update-refs-symref^ &&
+	test_cmp_rev refs/heads/update-refs-symref refs/heads/update-refs-symref-alias &&
+	test_write_lines refs/heads/update-refs-symref >expect &&
+	git symbolic-ref refs/heads/update-refs-symref-alias >actual &&
+	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 &&
-- 
gitgitgadget
Previous: Son Luong Ngoc via GitGitGadgetNext: Phillip Wood
Message 2 of 25 in “rebase: handle --update-refs branch symrefs”
  1. 0/2 rebase: handle --update-refs branch symrefsSon Luong Ngoc via GitGitGadget, May 28, 2026
  2. 1/2 t3404: add failing branch symref testSon Luong Ngoc via GitGitGadget, May 28, 2026
  3. Phillip WoodJun 1, 2026
  4. 2/2 rebase: skip branch symref aliasesSon Luong Ngoc via GitGitGadget, May 28, 2026
  5. Kristoffer HaugsbakkMay 28, 2026
  6. Phillip WoodJun 1, 2026
  7. Junio C HamanoMay 28, 2026
  8. rebase: skip branch symref aliasesSon Luong Ngoc via GitGitGadget, Jun 3, 2026
  9. Phillip WoodJun 4, 2026
  10. Son Luong NgocJul 22, 2026
  11. 0/2 rebase: handle --update-refs branch symrefsSon Luong Ngoc via GitGitGadget, Jul 22, 2026
  12. 1/2 rebase: skip branch symref aliasesSon Luong Ngoc via GitGitGadget, Jul 22, 2026
  13. Phillip WoodJul 23, 2026
  14. Phillip WoodJul 24, 2026
  15. Erik Cervin-EdinJul 25, 2026
  16. Junio C HamanoJul 26, 2026
  17. Phillip WoodJul 28, 2026
  18. Junio C HamanoJul 28, 2026
  19. Phillip WoodJul 29, 2026
  20. Junio C HamanoJul 29, 2026
  21. Phillip WoodJul 30, 2026
  22. Junio C HamanoAug 6, 2026
  23. Phillip WoodAug 7, 2026
  24. 2/2 rebase: guard non-branch symref targetsSon Luong Ngoc via GitGitGadget, Jul 22, 2026
  25. Phillip WoodAug 7, 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.