Skip to content

Commit 2249d4d

Browse files
bmwillgitster
authored andcommitted
pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP
Since (ae8d082 pathspec: pass directory indicator to match_pathspec_item()) the path matching logic has been able to cope with submodules without needing to strip off a trailing slash if a path refers to a submodule. Since stripping the slash is no longer necessary, remove the PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent cbca060 commit 2249d4d

File tree

5 files changed

+6
-26
lines changed

5 files changed

+6
-26
lines changed

builtin/reset.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ static void parse_args(struct pathspec *pathspec,
236236

237237
parse_pathspec(pathspec, 0,
238238
PATHSPEC_PREFER_FULL |
239-
PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP |
240239
(patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0),
241240
prefix, argv);
242241
}

builtin/rm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
271271
die(_("index file corrupt"));
272272

273273
parse_pathspec(&pathspec, 0,
274-
PATHSPEC_PREFER_CWD |
275-
PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
274+
PATHSPEC_PREFER_CWD,
276275
prefix, argv);
277276
refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
278277

builtin/submodule--helper.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ static int module_list_compute(int argc, const char **argv,
233233
int i, result = 0;
234234
char *ps_matched = NULL;
235235
parse_pathspec(pathspec, 0,
236-
PATHSPEC_PREFER_FULL |
237-
PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
236+
PATHSPEC_PREFER_FULL,
238237
prefix, argv);
239238

240239
if (pathspec->nr)

pathspec.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,6 @@ static const char *parse_element_magic(unsigned *magic, int *prefix_len,
386386
return parse_short_magic(magic, elem);
387387
}
388388

389-
static void strip_submodule_slash_cheap(struct pathspec_item *item)
390-
{
391-
if (item->len >= 1 && item->match[item->len - 1] == '/') {
392-
int i = cache_name_pos(item->match, item->len - 1);
393-
394-
if (i >= 0 && S_ISGITLINK(active_cache[i]->ce_mode)) {
395-
item->len--;
396-
item->match[item->len] = '\0';
397-
}
398-
}
399-
}
400-
401389
/*
402390
* Perform the initialization of a pathspec_item based on a pathspec element.
403391
*/
@@ -470,9 +458,6 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
470458
item->original = xstrdup(elt);
471459
}
472460

473-
if (flags & PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP)
474-
strip_submodule_slash_cheap(item);
475-
476461
if (magic & PATHSPEC_LITERAL) {
477462
item->nowildcard_len = item->len;
478463
} else {

pathspec.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,17 @@ struct pathspec {
5858
#define PATHSPEC_PREFER_CWD (1<<0) /* No args means match cwd */
5959
#define PATHSPEC_PREFER_FULL (1<<1) /* No args means match everything */
6060
#define PATHSPEC_MAXDEPTH_VALID (1<<2) /* max_depth field is valid */
61-
/* strip the trailing slash if the given path is a gitlink */
62-
#define PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP (1<<3)
6361
/* die if a symlink is part of the given path's directory */
64-
#define PATHSPEC_SYMLINK_LEADING_PATH (1<<4)
65-
#define PATHSPEC_PREFIX_ORIGIN (1<<5)
66-
#define PATHSPEC_KEEP_ORDER (1<<6)
62+
#define PATHSPEC_SYMLINK_LEADING_PATH (1<<3)
63+
#define PATHSPEC_PREFIX_ORIGIN (1<<4)
64+
#define PATHSPEC_KEEP_ORDER (1<<5)
6765
/*
6866
* For the callers that just need pure paths from somewhere else, not
6967
* from command line. Global --*-pathspecs options are ignored. No
7068
* magic is parsed in each pathspec either. If PATHSPEC_LITERAL is
7169
* allowed, then it will automatically set for every pathspec.
7270
*/
73-
#define PATHSPEC_LITERAL_PATH (1<<7)
71+
#define PATHSPEC_LITERAL_PATH (1<<6)
7472

7573
extern void parse_pathspec(struct pathspec *pathspec,
7674
unsigned magic_mask,

0 commit comments

Comments
 (0)