ref-filter: Do not abruptly die when using the 'lstrip=<N>' option
[gitweb.git] / t / t6300-for-each-ref.sh
index 7663a3661f999f17e66766ea67279f9d350cd29c..d3d1a97db9709c29b829cf64df4fa6cce04ed6fe 100755 (executable)
@@ -51,12 +51,14 @@ test_atom() {
 
 test_atom head refname refs/heads/master
 test_atom head refname:short master
-test_atom head refname:strip=1 heads/master
-test_atom head refname:strip=2 master
+test_atom head refname:lstrip=1 heads/master
+test_atom head refname:lstrip=2 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 push refs/remotes/myfork/master
 test_atom head push:short myfork/master
+test_atom head push:lstrip=1 remotes/myfork/master
 test_atom head objecttype commit
 test_atom head objectsize 171
 test_atom head objectname $(git rev-parse refs/heads/master)
@@ -139,14 +141,10 @@ 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 'arguments to :lstrip must be positive integers' '
+       test_must_fail git for-each-ref --format="%(refname:lstrip=0)" &&
+       test_must_fail git for-each-ref --format="%(refname:lstrip=-1)" &&
+       test_must_fail git for-each-ref --format="%(refname:lstrip=foo)"
 '
 
 test_expect_success 'Check format specifiers are ignored in naming date atoms' '
@@ -624,4 +622,13 @@ test_expect_success 'Verify usage of %(symref:short) atom' '
        test_cmp expected actual
 '
 
+cat >expected <<EOF
+master
+EOF
+
+test_expect_success 'Verify usage of %(symref:lstrip) atom' '
+       git for-each-ref --format="%(symref:lstrip=2)" refs/heads/sym > actual &&
+       test_cmp expected actual
+'
+
 test_done