for-each-ref: utilize core.warnAmbiguousRefs for :short-format
core.warnAmbiguousRefs is used to select strict mode for the abbreviation for the ":short" format specifier of "refname" and "upstream". In strict mode, the abbreviated ref will never trigger the 'warn_ambiguous_refs' warning. I.e. for these refs: refs/heads/xyzzy refs/tags/xyzzy the abbreviated forms are: heads/xyzzy tags/xyzzy Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
6e7b3309d3
commit
2bb98169be
@ -301,10 +301,11 @@ test_expect_success 'Check for invalid refname format' '
|
||||
|
||||
cat >expected <<\EOF
|
||||
heads/master
|
||||
master
|
||||
tags/master
|
||||
EOF
|
||||
|
||||
test_expect_success 'Check ambiguous head and tag refs' '
|
||||
test_expect_success 'Check ambiguous head and tag refs (strict)' '
|
||||
git config --bool core.warnambiguousrefs true &&
|
||||
git checkout -b newtag &&
|
||||
echo "Using $datestamp" > one &&
|
||||
git add one &&
|
||||
@ -315,12 +316,23 @@ test_expect_success 'Check ambiguous head and tag refs' '
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
cat >expected <<\EOF
|
||||
heads/master
|
||||
master
|
||||
EOF
|
||||
|
||||
test_expect_success 'Check ambiguous head and tag refs (loose)' '
|
||||
git config --bool core.warnambiguousrefs false &&
|
||||
git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
cat >expected <<\EOF
|
||||
heads/ambiguous
|
||||
ambiguous
|
||||
EOF
|
||||
|
||||
test_expect_success 'Check ambiguous head and tag refs II' '
|
||||
test_expect_success 'Check ambiguous head and tag refs II (loose)' '
|
||||
git checkout master &&
|
||||
git tag ambiguous testtag^0 &&
|
||||
git branch ambiguous testtag^0 &&
|
||||
|
Reference in New Issue
Block a user