From: Junio C Hamano Date: Fri, 21 Oct 2022 18:37:28 +0000 (-0700) Subject: Merge branch 'jc/symbolic-ref-no-recurse' X-Git-Tag: v2.39.0-rc0~92 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4a48c7d25f941532befaf3320f95f16d3c62b530;p=thirdparty%2Fgit.git 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 --- 4a48c7d25f941532befaf3320f95f16d3c62b530 diff --cc t/t1401-symbolic-ref.sh index 0c204089b8,773a6e8e01..d708acdb81 --- a/t/t1401-symbolic-ref.sh +++ b/t/t1401-symbolic-ref.sh @@@ -165,14 -163,18 +165,28 @@@ test_expect_success 'symbolic-ref can r test_cmp expect actual ' +test_expect_success 'symbolic-ref refuses invalid target for non-HEAD' ' + test_must_fail git symbolic-ref refs/heads/invalid foo..bar +' + +test_expect_success 'symbolic-ref allows top-level target for non-HEAD' ' + git symbolic-ref refs/heads/top-level FETCH_HEAD && + git update-ref FETCH_HEAD 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