ref-filter: resurrect "strip" as a synonym to "lstrip"

We forgot that "strip" was introduced at 0571979bd6 ("tag: do not show ambiguous tag names as "tags/foo"", 2016-01-25) as part of Git 2.8 (and 2.7.1) when we started calling this "lstrip" to make it easier to explain the new "rstrip" operation. We shouldn't have renamed the existing one; "lstrip" should have been a new synonym that means the same thing as "strip". Scripts in the wild are surely using the original form already. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Feb 7, 2017 at 11:50 UTC 44a6b6ce1777f587c318008fe59b901a296f5326
3 files changed +16 -1
Documentation/git-for-each-ref.txt
+2
@@ -107,6 +107,8 @@ refname::
107 enough components, the result becomes an empty string if
108 stripping with positive <N>, or it becomes the full refname if
109 stripping with negative <N>. Neither is an error.
110 ++
111 +`strip` can be used as a synomym to `lstrip`.
112
113 objecttype::
114 The type of the object (`blob`, `tree`, `commit`, `tag`).
ref-filter.c
+2 -1
@@ -112,7 +112,8 @@ static void refname_atom_parser_internal(struct refname_atom *atom,
112 atom->option = R_NORMAL;
113 else if (!strcmp(arg, "short"))
114 atom->option = R_SHORT;
115 - else if (skip_prefix(arg, "lstrip=", &arg)) {
115 + else if (skip_prefix(arg, "lstrip=", &arg) ||
116 + skip_prefix(arg, "strip=", &arg)) {
117 atom->option = R_LSTRIP;
118 if (strtol_i(arg, 10, &atom->lstrip))
119 die(_("Integer value expected refname:lstrip=%s"), arg);
t/t6300-for-each-ref.sh
+12
@@ -59,18 +59,26 @@ test_atom head refname:rstrip=1 refs/heads
59 test_atom head refname:rstrip=2 refs
60 test_atom head refname:rstrip=-1 refs
61 test_atom head refname:rstrip=-2 refs/heads
62 +test_atom head refname:strip=1 heads/master
63 +test_atom head refname:strip=2 master
64 +test_atom head refname:strip=-1 master
65 +test_atom head refname:strip=-2 heads/master
66 test_atom head upstream refs/remotes/origin/master
67 test_atom head upstream:short origin/master
68 test_atom head upstream:lstrip=2 origin/master
69 test_atom head upstream:lstrip=-2 origin/master
70 test_atom head upstream:rstrip=2 refs/remotes
71 test_atom head upstream:rstrip=-2 refs/remotes
72 +test_atom head upstream:strip=2 origin/master
73 +test_atom head upstream:strip=-2 origin/master
74 test_atom head push refs/remotes/myfork/master
75 test_atom head push:short myfork/master
76 test_atom head push:lstrip=1 remotes/myfork/master
77 test_atom head push:lstrip=-1 master
78 test_atom head push:rstrip=1 refs/remotes/myfork
79 test_atom head push:rstrip=-1 refs
80 +test_atom head push:strip=1 remotes/myfork/master
81 +test_atom head push:strip=-1 master
82 test_atom head objecttype commit
83 test_atom head objectsize 171
84 test_atom head objectname $(git rev-parse refs/heads/master)
@@ -636,6 +644,10 @@ EOF
644 test_expect_success 'Verify usage of %(symref:lstrip) atom' '
645 git for-each-ref --format="%(symref:lstrip=2)" refs/heads/sym > actual &&
646 git for-each-ref --format="%(symref:lstrip=-2)" refs/heads/sym >> actual &&
647 + test_cmp expected actual &&
648 +
649 + git for-each-ref --format="%(symref:strip=2)" refs/heads/sym > actual &&
650 + git for-each-ref --format="%(symref:strip=-2)" refs/heads/sym >> actual &&
651 test_cmp expected actual
652 '
653