]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t3404: add failing branch symref test
authorSon Luong Ngoc <sluongng@gmail.com>
Thu, 28 May 2026 05:42:00 +0000 (05:42 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 May 2026 20:42:28 +0000 (05:42 +0900)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3404-rebase-interactive.sh

index 58b3bb0c271aaebab4381795c9d9dcf8ba3a7593..42ba8cc313e576a1ae7298c0a9668612528cf360 100755 (executable)
@@ -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 &&