Code

Merge branch 'maint-1.6.0' into maint
[git.git] / t / t6300-for-each-ref.sh
index 26995b3cdda32b34b2ecf428e5bbf5ef2ff2fc8a..8bfae44a8392898453785f43c7e35b65e9c1f017 100755 (executable)
@@ -262,6 +262,50 @@ for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
        "
 done
 
+cat >expected <<\EOF
+master
+testtag
+EOF
+
+test_expect_success 'Check short refname format' '
+       (git for-each-ref --format="%(refname:short)" refs/heads &&
+       git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'Check for invalid refname format' '
+       test_must_fail git for-each-ref --format="%(refname:INVALID)"
+'
+
+cat >expected <<\EOF
+heads/master
+master
+EOF
+
+test_expect_success 'Check ambiguous head and tag refs' '
+       git checkout -b newtag &&
+       echo "Using $datestamp" > one &&
+       git add one &&
+       git commit -m "Branch" &&
+       setdate_and_increment &&
+       git tag -m "Tagging at $datestamp" master &&
+       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' '
+       git checkout master &&
+       git tag ambiguous testtag^0 &&
+       git branch ambiguous testtag^0 &&
+       git for-each-ref --format "%(refname:short)" refs/heads/ambiguous refs/tags/ambiguous >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'an unusual tag with an incomplete line' '
 
        git tag -m "bogo" bogo &&