Merge branch 'jc/symbolic-ref-no-recurse'

After checking out a "branch" that is a symbolic-ref that points at
another branch, "git symbolic-ref HEAD" reports the underlying
branch, not the symbolic-ref the user gave checkout as argument.
The command learned the "--no-recurse" option to stop after
dereferencing a symbolic-ref only once.

* jc/symbolic-ref-no-recurse:
  symbolic-ref: teach "--[no-]recurse" option
This commit is contained in:
Junio C Hamano
2022-10-21 11:37:28 -07:00
3 changed files with 35 additions and 8 deletions

View File

@ -175,4 +175,18 @@ test_expect_success 'symbolic-ref allows top-level target for non-HEAD' '
test_cmp_rev top-level HEAD
'
test_expect_success 'symbolic-ref pointing at another' '
git update-ref refs/heads/maint-2.37 HEAD &&
git symbolic-ref refs/heads/maint refs/heads/maint-2.37 &&
git checkout maint &&
git symbolic-ref HEAD >actual &&
echo refs/heads/maint-2.37 >expect &&
test_cmp expect actual &&
git symbolic-ref --no-recurse HEAD >actual &&
echo refs/heads/maint >expect &&
test_cmp expect actual
'
test_done