ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()
[gitweb.git] / t / t6300-for-each-ref.sh
index e67c694c35a2a5ed9cc77fb02d6d03d3eaa42f57..c538084245a7bd7208514ce591b95e361f9e1923 100755 (executable)
@@ -38,6 +38,7 @@ test_atom() {
        case "$1" in
                head) ref=refs/heads/master ;;
                 tag) ref=refs/tags/testtag ;;
+                sym) ref=refs/heads/sym ;;
                   *) ref=$1 ;;
        esac
        printf '%s\n' "$3" >expected
@@ -54,8 +55,10 @@ test_atom head refname:strip=1 heads/master
 test_atom head refname:strip=2 master
 test_atom head upstream refs/remotes/origin/master
 test_atom head upstream:short origin/master
+test_atom head upstream:strip=2 origin/master
 test_atom head push refs/remotes/myfork/master
 test_atom head push:short myfork/master
+test_atom head push:strip=1 remotes/myfork/master
 test_atom head objecttype commit
 test_atom head objectsize 171
 test_atom head objectname $(git rev-parse refs/heads/master)
@@ -372,6 +375,8 @@ test_expect_success 'setup for upstream:track[short]' '
 
 test_atom head upstream:track '[ahead 1]'
 test_atom head upstream:trackshort '>'
+test_atom head upstream:track,nobracket 'ahead 1'
+test_atom head upstream:nobracket,track 'ahead 1'
 test_atom head push:track '[ahead 1]'
 test_atom head push:trackshort '>'
 
@@ -382,7 +387,7 @@ test_expect_success 'Check that :track[short] cannot be used with other atoms' '
 
 test_expect_success 'Check that :track[short] works when upstream is invalid' '
        cat >expected <<-\EOF &&
-
+       [gone]
 
        EOF
        test_when_finished "git config branch.master.merge refs/heads/master" &&
@@ -564,6 +569,7 @@ test_expect_success 'Verify sort with multiple keys' '
        test_cmp expected actual
 '
 
+
 test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
        test_when_finished "git checkout master" &&
        git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
@@ -598,4 +604,35 @@ test_expect_success 'basic atom: head contents:trailers' '
        test_cmp expect actual.clean
 '
 
+test_expect_success 'Add symbolic ref for the following tests' '
+       git symbolic-ref refs/heads/sym refs/heads/master
+'
+
+cat >expected <<EOF
+refs/heads/master
+EOF
+
+test_expect_success 'Verify usage of %(symref) atom' '
+       git for-each-ref --format="%(symref)" refs/heads/sym >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<EOF
+heads/master
+EOF
+
+test_expect_success 'Verify usage of %(symref:short) atom' '
+       git for-each-ref --format="%(symref:short)" refs/heads/sym >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<EOF
+master
+EOF
+
+test_expect_success 'Verify usage of %(symref:strip) atom' '
+       git for-each-ref --format="%(symref:strip=2)" refs/heads/sym > actual &&
+       test_cmp expected actual
+'
+
 test_done