Merge branch 'jc/config-case-cmdline-take-2'
[gitweb.git] / t / t6300-for-each-ref.sh
index 18a9e2565cf0a5f5838aaf2acffdd1b39957ebd1..c87dc1f8bc92c13e11e8f8d8cd1468beb6669cba 100755 (executable)
@@ -51,12 +51,34 @@ test_atom() {
 
 test_atom head refname refs/heads/master
 test_atom head refname:short master
+test_atom head refname:lstrip=1 heads/master
+test_atom head refname:lstrip=2 master
+test_atom head refname:lstrip=-1 master
+test_atom head refname:lstrip=-2 heads/master
+test_atom head refname:rstrip=1 refs/heads
+test_atom head refname:rstrip=2 refs
+test_atom head refname:rstrip=-1 refs
+test_atom head refname:rstrip=-2 refs/heads
 test_atom head refname:strip=1 heads/master
 test_atom head refname:strip=2 master
+test_atom head refname:strip=-1 master
+test_atom head refname:strip=-2 heads/master
 test_atom head upstream refs/remotes/origin/master
 test_atom head upstream:short origin/master
+test_atom head upstream:lstrip=2 origin/master
+test_atom head upstream:lstrip=-2 origin/master
+test_atom head upstream:rstrip=2 refs/remotes
+test_atom head upstream:rstrip=-2 refs/remotes
+test_atom head upstream:strip=2 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:lstrip=1 remotes/myfork/master
+test_atom head push:lstrip=-1 master
+test_atom head push:rstrip=1 refs/remotes/myfork
+test_atom head push:rstrip=-1 refs
+test_atom head push:strip=1 remotes/myfork/master
+test_atom head push:strip=-1 master
 test_atom head objecttype commit
 test_atom head objectsize 171
 test_atom head objectname $(git rev-parse refs/heads/master)
@@ -139,16 +161,6 @@ test_expect_success 'Check invalid atoms names are errors' '
        test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
 '
 
-test_expect_success 'arguments to :strip must be positive integers' '
-       test_must_fail git for-each-ref --format="%(refname:strip=0)" &&
-       test_must_fail git for-each-ref --format="%(refname:strip=-1)" &&
-       test_must_fail git for-each-ref --format="%(refname:strip=foo)"
-'
-
-test_expect_success 'stripping refnames too far gives an error' '
-       test_must_fail git for-each-ref --format="%(refname:strip=3)"
-'
-
 test_expect_success 'Check format specifiers are ignored in naming date atoms' '
        git for-each-ref --format="%(authordate)" refs/heads &&
        git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads &&
@@ -626,10 +638,27 @@ test_expect_success 'Verify usage of %(symref:short) atom' '
 
 cat >expected <<EOF
 master
+heads/master
 EOF
 
-test_expect_success 'Verify usage of %(symref:strip) atom' '
+test_expect_success 'Verify usage of %(symref:lstrip) atom' '
+       git for-each-ref --format="%(symref:lstrip=2)" refs/heads/sym > actual &&
+       git for-each-ref --format="%(symref:lstrip=-2)" refs/heads/sym >> actual &&
+       test_cmp expected actual &&
+
        git for-each-ref --format="%(symref:strip=2)" refs/heads/sym > actual &&
+       git for-each-ref --format="%(symref:strip=-2)" refs/heads/sym >> actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<EOF
+refs
+refs/heads
+EOF
+
+test_expect_success 'Verify usage of %(symref:rstrip) atom' '
+       git for-each-ref --format="%(symref:rstrip=2)" refs/heads/sym > actual &&
+       git for-each-ref --format="%(symref:rstrip=-2)" refs/heads/sym >> actual &&
        test_cmp expected actual
 '