summaryrefslogtreecommitdiff
path: root/t/t6300-for-each-ref.sh
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2017-01-10 08:49:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-31 20:38:59 (GMT)
commit1a0ca5e358c1af14160e610e346c706e5dccf535 (patch)
tree1728a6743b9b837307398d392873547b3fa84d12 /t/t6300-for-each-ref.sh
parent3a42980f9e5ecc2b74c538109d4007c630881f1c (diff)
downloadgit-1a0ca5e358c1af14160e610e346c706e5dccf535.zip
git-1a0ca5e358c1af14160e610e346c706e5dccf535.tar.gz
git-1a0ca5e358c1af14160e610e346c706e5dccf535.tar.bz2
ref-filter: modify the 'lstrip=<N>' option to work with negative '<N>'
Currently the 'lstrip=<N>' option only takes a positive value '<N>' and strips '<N>' slash-separated path components from the left. Modify the 'lstrip' option to also take a negative number '<N>' which would strip from the left as necessary and _leave_ behind only 'N' slash-separated path components from the right-most end. For e.g. %(refname:lstrip=-1) would make 'foo/goo/abc' into 'abc'. Add documentation and tests for the same. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6300-for-each-ref.sh')
-rwxr-xr-xt/t6300-for-each-ref.sh12
1 files changed, 6 insertions, 6 deletions
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index d3d1a97..203cfaa 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -53,12 +53,16 @@ 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 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 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 objecttype commit
test_atom head objectsize 171
test_atom head objectname $(git rev-parse refs/heads/master)
@@ -141,12 +145,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 :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' '
git for-each-ref --format="%(authordate)" refs/heads &&
git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads &&
@@ -624,10 +622,12 @@ test_expect_success 'Verify usage of %(symref:short) atom' '
cat >expected <<EOF
master
+heads/master
EOF
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
'