ref-filter: rename the 'strip' option to 'lstrip'

In preparation for the upcoming patch, where we introduce the 'rstrip' option. Rename the 'strip' option to 'lstrip' to remove ambiguity. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karthik Nayak committed Jan 10, 2017 at 14:19 UTC 17938f171f703c28696c7839a910565f0fb32121
4 files changed +28 -28
Documentation/git-for-each-ref.txt
+5 -5
@@ -95,9 +95,9 @@ refname::
95 The name of the ref (the part after $GIT_DIR/).
96 For a non-ambiguous short name of the ref append `:short`.
97 The option core.warnAmbiguousRefs is used to select the strict
98 - abbreviation mode. If `strip=<N>` is appended, strips `<N>`
98 + abbreviation mode. If `lstrip=<N>` is appended, strips `<N>`
99 slash-separated path components from the front of the refname
100 - (e.g., `%(refname:strip=2)` turns `refs/tags/foo` into `foo`.
100 + (e.g., `%(refname:lstrip=2)` turns `refs/tags/foo` into `foo`.
101 `<N>` must be a positive integer. If a displayed ref has fewer
102 components than `<N>`, the command aborts with an error.
103
@@ -116,7 +116,7 @@ objectname::
116
117 upstream::
118 The name of a local ref which can be considered ``upstream''
119 - from the displayed ref. Respects `:short` and `:strip` in the
119 + from the displayed ref. Respects `:short` and `:lstrip` in the
120 same way as `refname` above. Additionally respects `:track`
121 to show "[ahead N, behind M]" and `:trackshort` to show the
122 terse version: ">" (ahead), "<" (behind), "<>" (ahead and
@@ -130,7 +130,7 @@ upstream::
130
131 push::
132 The name of a local ref which represents the `@{push}`
133 - location for the displayed ref. Respects `:short`, `:strip`,
133 + location for the displayed ref. Respects `:short`, `:lstrip`,
134 `:track`, and `:trackshort` options as `upstream`
135 does. Produces an empty string if no `@{push}` ref is
136 configured.
@@ -174,7 +174,7 @@ if::
174 symref::
175 The ref which the given symbolic ref refers to. If not a
176 symbolic ref, nothing is printed. Respects the `:short` and
177 - `:strip` options in the same way as `refname` above.
177 + `:lstrip` options in the same way as `refname` above.
178
179 In addition to the above, for commit and tag objects, the header
180 field names (`tree`, `parent`, `object`, `type`, and `tag`) can
builtin/tag.c
+2 -2
@@ -45,11 +45,11 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con
45 if (!format) {
46 if (filter->lines) {
47 to_free = xstrfmt("%s %%(contents:lines=%d)",
48 - "%(align:15)%(refname:strip=2)%(end)",
48 + "%(align:15)%(refname:lstrip=2)%(end)",
49 filter->lines);
50 format = to_free;
51 } else
52 - format = "%(refname:strip=2)";
52 + format = "%(refname:lstrip=2)";
53 }
54
55 verify_ref_format(format);
ref-filter.c
+10 -10
@@ -33,8 +33,8 @@ struct if_then_else {
33 };
34
35 struct refname_atom {
36 - enum { R_NORMAL, R_SHORT, R_STRIP } option;
37 - unsigned int strip;
36 + enum { R_NORMAL, R_SHORT, R_LSTRIP } option;
37 + unsigned int lstrip;
38 };
39
40 /*
@@ -91,10 +91,10 @@ static void refname_atom_parser_internal(struct refname_atom *atom,
91 atom->option = R_NORMAL;
92 else if (!strcmp(arg, "short"))
93 atom->option = R_SHORT;
94 - else if (skip_prefix(arg, "strip=", &arg)) {
95 - atom->option = R_STRIP;
96 - if (strtoul_ui(arg, 10, &atom->strip) || atom->strip <= 0)
97 - die(_("positive value expected refname:strip=%s"), arg);
94 + else if (skip_prefix(arg, "lstrip=", &arg)) {
95 + atom->option = R_LSTRIP;
96 + if (strtoul_ui(arg, 10, &atom->lstrip) || atom->lstrip <= 0)
97 + die(_("positive value expected refname:lstrip=%s"), arg);
98 } else
99 die(_("unrecognized %%(%s) argument: %s"), name, arg);
100 }
@@ -1091,7 +1091,7 @@ static inline char *copy_advance(char *dst, const char *src)
1091 return dst;
1092 }
1093
1094 -static const char *strip_ref_components(const char *refname, unsigned int len)
1094 +static const char *lstrip_ref_components(const char *refname, unsigned int len)
1095 {
1096 long remaining = len;
1097 const char *start = refname;
@@ -1099,7 +1099,7 @@ static const char *strip_ref_components(const char *refname, unsigned int len)
1099 while (remaining) {
1100 switch (*start++) {
1101 case '\0':
1102 - die(_("ref '%s' does not have %ud components to :strip"),
1102 + die(_("ref '%s' does not have %ud components to :lstrip"),
1103 refname, len);
1104 case '/':
1105 remaining--;
@@ -1113,8 +1113,8 @@ static const char *show_ref(struct refname_atom *atom, const char *refname)
1113 {
1114 if (atom->option == R_SHORT)
1115 return shorten_unambiguous_ref(refname, warn_ambiguous_refs);
1116 - else if (atom->option == R_STRIP)
1117 - return strip_ref_components(refname, atom->strip);
1116 + else if (atom->option == R_LSTRIP)
1117 + return lstrip_ref_components(refname, atom->lstrip);
1118 else
1119 return refname;
1120 }
t/t6300-for-each-ref.sh
+11 -11
@@ -51,14 +51,14 @@ test_atom() {
51
52 test_atom head refname refs/heads/master
53 test_atom head refname:short master
54 -test_atom head refname:strip=1 heads/master
55 -test_atom head refname:strip=2 master
54 +test_atom head refname:lstrip=1 heads/master
55 +test_atom head refname:lstrip=2 master
56 test_atom head upstream refs/remotes/origin/master
57 test_atom head upstream:short origin/master
58 -test_atom head upstream:strip=2 origin/master
58 +test_atom head upstream:lstrip=2 origin/master
59 test_atom head push refs/remotes/myfork/master
60 test_atom head push:short myfork/master
61 -test_atom head push:strip=1 remotes/myfork/master
61 +test_atom head push:lstrip=1 remotes/myfork/master
62 test_atom head objecttype commit
63 test_atom head objectsize 171
64 test_atom head objectname $(git rev-parse refs/heads/master)
@@ -141,14 +141,14 @@ test_expect_success 'Check invalid atoms names are errors' '
141 test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
142 '
143
144 -test_expect_success 'arguments to :strip must be positive integers' '
145 - test_must_fail git for-each-ref --format="%(refname:strip=0)" &&
146 - test_must_fail git for-each-ref --format="%(refname:strip=-1)" &&
147 - test_must_fail git for-each-ref --format="%(refname:strip=foo)"
144 +test_expect_success 'arguments to :lstrip must be positive integers' '
145 + test_must_fail git for-each-ref --format="%(refname:lstrip=0)" &&
146 + test_must_fail git for-each-ref --format="%(refname:lstrip=-1)" &&
147 + test_must_fail git for-each-ref --format="%(refname:lstrip=foo)"
148 '
149
150 test_expect_success 'stripping refnames too far gives an error' '
151 - test_must_fail git for-each-ref --format="%(refname:strip=3)"
151 + test_must_fail git for-each-ref --format="%(refname:lstrip=3)"
152 '
153
154 test_expect_success 'Check format specifiers are ignored in naming date atoms' '
@@ -630,8 +630,8 @@ cat >expected <<EOF
630 master
631 EOF
632
633 -test_expect_success 'Verify usage of %(symref:strip) atom' '
634 - git for-each-ref --format="%(symref:strip=2)" refs/heads/sym > actual &&
633 +test_expect_success 'Verify usage of %(symref:lstrip) atom' '
634 + git for-each-ref --format="%(symref:lstrip=2)" refs/heads/sym > actual &&
635 test_cmp expected actual
636 '
637