Skip to content

Commit 17938f1

Browse files
KarthikNayakgitster
authored andcommitted
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>
1 parent 3ba308c commit 17938f1

4 files changed

Lines changed: 28 additions & 28 deletions

File tree

Documentation/git-for-each-ref.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ refname::
9595
The name of the ref (the part after $GIT_DIR/).
9696
For a non-ambiguous short name of the ref append `:short`.
9797
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>`
9999
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`.
101101
`<N>` must be a positive integer. If a displayed ref has fewer
102102
components than `<N>`, the command aborts with an error.
103103

@@ -116,7 +116,7 @@ objectname::
116116

117117
upstream::
118118
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
120120
same way as `refname` above. Additionally respects `:track`
121121
to show "[ahead N, behind M]" and `:trackshort` to show the
122122
terse version: ">" (ahead), "<" (behind), "<>" (ahead and
@@ -130,7 +130,7 @@ upstream::
130130

131131
push::
132132
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`,
134134
`:track`, and `:trackshort` options as `upstream`
135135
does. Produces an empty string if no `@{push}` ref is
136136
configured.
@@ -174,7 +174,7 @@ if::
174174
symref::
175175
The ref which the given symbolic ref refers to. If not a
176176
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.
178178

179179
In addition to the above, for commit and tag objects, the header
180180
field names (`tree`, `parent`, `object`, `type`, and `tag`) can

builtin/tag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con
4545
if (!format) {
4646
if (filter->lines) {
4747
to_free = xstrfmt("%s %%(contents:lines=%d)",
48-
"%(align:15)%(refname:strip=2)%(end)",
48+
"%(align:15)%(refname:lstrip=2)%(end)",
4949
filter->lines);
5050
format = to_free;
5151
} else
52-
format = "%(refname:strip=2)";
52+
format = "%(refname:lstrip=2)";
5353
}
5454

5555
verify_ref_format(format);

ref-filter.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ struct if_then_else {
3333
};
3434

3535
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;
3838
};
3939

4040
/*
@@ -91,10 +91,10 @@ static void refname_atom_parser_internal(struct refname_atom *atom,
9191
atom->option = R_NORMAL;
9292
else if (!strcmp(arg, "short"))
9393
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);
9898
} else
9999
die(_("unrecognized %%(%s) argument: %s"), name, arg);
100100
}
@@ -1091,15 +1091,15 @@ static inline char *copy_advance(char *dst, const char *src)
10911091
return dst;
10921092
}
10931093

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)
10951095
{
10961096
long remaining = len;
10971097
const char *start = refname;
10981098

10991099
while (remaining) {
11001100
switch (*start++) {
11011101
case '\0':
1102-
die(_("ref '%s' does not have %ud components to :strip"),
1102+
die(_("ref '%s' does not have %ud components to :lstrip"),
11031103
refname, len);
11041104
case '/':
11051105
remaining--;
@@ -1113,8 +1113,8 @@ static const char *show_ref(struct refname_atom *atom, const char *refname)
11131113
{
11141114
if (atom->option == R_SHORT)
11151115
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);
11181118
else
11191119
return refname;
11201120
}

t/t6300-for-each-ref.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ test_atom() {
5151

5252
test_atom head refname refs/heads/master
5353
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
5656
test_atom head upstream refs/remotes/origin/master
5757
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
5959
test_atom head push refs/remotes/myfork/master
6060
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
6262
test_atom head objecttype commit
6363
test_atom head objectsize 171
6464
test_atom head objectname $(git rev-parse refs/heads/master)
@@ -141,14 +141,14 @@ test_expect_success 'Check invalid atoms names are errors' '
141141
test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
142142
'
143143

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)"
148148
'
149149

150150
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)"
152152
'
153153

154154
test_expect_success 'Check format specifiers are ignored in naming date atoms' '
@@ -630,8 +630,8 @@ cat >expected <<EOF
630630
master
631631
EOF
632632

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 &&
635635
test_cmp expected actual
636636
'
637637

0 commit comments

Comments
 (0)