There is currently a bug in refs.c:shorten_unambiguous_ref() that causes "refs/remotes/origin/HEAD" to be shortened to "origin/HEAD" instead of "origin" (which is expected from matching against the "refs/remotes/%.*s" pattern from refs.c:ref_rev_parse_rules). Signed-off-by: Johan Herland <johan@xxxxxxxxxxx> --- t/t1514-rev-parse-shorten_unambiguous_ref.sh | 8 ++++++-- t/t6300-for-each-ref.sh | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/t/t1514-rev-parse-shorten_unambiguous_ref.sh b/t/t1514-rev-parse-shorten_unambiguous_ref.sh index 41e0162..ad75436 100755 --- a/t/t1514-rev-parse-shorten_unambiguous_ref.sh +++ b/t/t1514-rev-parse-shorten_unambiguous_ref.sh @@ -20,6 +20,7 @@ test_expect_success 'setup' ' test_commit master_d && git update-ref refs/master master_d && test_commit master_e + git update-ref refs/remotes/origin/HEAD master_e && test_commit master_f ' @@ -27,6 +28,7 @@ cat > expect.show-ref << EOF $(git rev-parse master_f) refs/heads/master $(git rev-parse master_b) refs/heads/origin/master $(git rev-parse master_d) refs/master +$(git rev-parse master_e) refs/remotes/origin/HEAD $(git rev-parse master_a) refs/remotes/origin/master $(git rev-parse master_c) refs/tags/master $(git rev-parse master_a) refs/tags/master_a @@ -56,18 +58,20 @@ test_shortname () { test_cmp expect.sha1 actual.sha1 } -test_expect_success 'shortening refnames in strict mode' ' +test_expect_failure 'shortening refnames in strict mode' ' test_shortname refs/heads/master strict heads/master master_f && test_shortname refs/heads/origin/master strict heads/origin/master master_b && test_shortname refs/master strict refs/master master_d && + test_shortname refs/remotes/origin/HEAD strict origin master_e && test_shortname refs/remotes/origin/master strict remotes/origin/master master_a && test_shortname refs/tags/master strict tags/master master_c ' -test_expect_success 'shortening refnames in loose mode' ' +test_expect_failure 'shortening refnames in loose mode' ' test_shortname refs/heads/master loose heads/master master_f && test_shortname refs/heads/origin/master loose origin/master master_b && test_shortname refs/master loose master master_d && + test_shortname refs/remotes/origin/HEAD loose origin master_e && test_shortname refs/remotes/origin/master loose remotes/origin/master master_a && test_shortname refs/tags/master loose tags/master master_c ' diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index 752f5cb..5d716c8 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -466,4 +466,16 @@ test_expect_success 'Verify sort with multiple keys' ' refs/tags/bogo refs/tags/master > actual && test_cmp expected actual ' + +cat >expected <<\EOF +origin +origin/master +EOF + +test_expect_failure 'Check refs/remotes/origin/HEAD shortens to origin' ' + git remote set-head origin master && + git for-each-ref --format="%(refname:short)" refs/remotes >actual && + test_cmp expected actual +' + test_done -- 1.8.1.3.704.g33f7d4f -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html