Skip to content

Commit aa30fe1

Browse files
hanwengitster
authored andcommitted
branch tests: test for errno propagating on failing read
Add a test for "git branch" to cover the case where .git/refs is symlinked. To check availability, refs_verify_refname_available() will run refs_read_raw_ref() on each prefix, leading to a read() from .git/refs (which is a directory). It would probably be more robust to re-issue the lstat() as a normal stat(), in which case, we would fall back to the directory case, but for now let's just test for the existing behavior as-is. This test covers a regression in a commit that only ever made it to "next", see [1]. 1. http://lore.kernel.org/git/[email protected] Signed-off-by: Han-Wen Nienhuys <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f443b22 commit aa30fe1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

t/t3200-branch.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,28 @@ test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for
731731
test_must_fail git branch -m u v
732732
'
733733

734+
test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
735+
test_when_finished "rm -rf subdir" &&
736+
git init --bare subdir &&
737+
738+
rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
739+
ln -s ../.git/refs subdir/refs &&
740+
ln -s ../.git/objects subdir/objects &&
741+
ln -s ../.git/packed-refs subdir/packed-refs &&
742+
743+
git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
744+
git rev-parse --absolute-git-dir >our.dir &&
745+
! test_cmp subdir.dir our.dir &&
746+
747+
git -C subdir log &&
748+
git -C subdir branch rename-src &&
749+
git rev-parse rename-src >expect &&
750+
git -C subdir branch -m rename-src rename-dest &&
751+
git rev-parse rename-dest >actual &&
752+
test_cmp expect actual &&
753+
git branch -D rename-dest
754+
'
755+
734756
test_expect_success 'test tracking setup via --track' '
735757
git config remote.local.url . &&
736758
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&

0 commit comments

Comments
 (0)