pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP

Since (ae8d08242 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>

Brandon Williams committed May 11, 2017 at 15:04 UTC 2249d4dbc197d45da5407cbc80b2461e49bb8785
5 files changed +6 -26
builtin/reset.c
-1
@@ -236,7 +236,6 @@ static void parse_args(struct pathspec *pathspec,
236
237 parse_pathspec(pathspec, 0,
238 PATHSPEC_PREFER_FULL |
239 - PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP |
239 (patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0),
240 prefix, argv);
241 }
builtin/rm.c
+1 -2
@@ -271,8 +271,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
271 die(_("index file corrupt"));
272
273 parse_pathspec(&pathspec, 0,
274 - PATHSPEC_PREFER_CWD |
275 - PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
274 + PATHSPEC_PREFER_CWD,
275 prefix, argv);
276 refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
277
builtin/submodule--helper.c
+1 -2
@@ -233,8 +233,7 @@ static int module_list_compute(int argc, const char **argv,
233 int i, result = 0;
234 char *ps_matched = NULL;
235 parse_pathspec(pathspec, 0,
236 - PATHSPEC_PREFER_FULL |
237 - PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
236 + PATHSPEC_PREFER_FULL,
237 prefix, argv);
238
239 if (pathspec->nr)
pathspec.c
-15
@@ -386,18 +386,6 @@ static const char *parse_element_magic(unsigned *magic, int *prefix_len,
386 return parse_short_magic(magic, elem);
387 }
388
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 -
389 /*
390 * Perform the initialization of a pathspec_item based on a pathspec element.
391 */
@@ -470,9 +458,6 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
458 item->original = xstrdup(elt);
459 }
460
473 - if (flags & PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP)
474 - strip_submodule_slash_cheap(item);
475 -
461 if (magic & PATHSPEC_LITERAL) {
462 item->nowildcard_len = item->len;
463 } else {
pathspec.h
+4 -6
@@ -58,19 +58,17 @@ struct pathspec {
58 #define PATHSPEC_PREFER_CWD (1<<0) /* No args means match cwd */
59 #define PATHSPEC_PREFER_FULL (1<<1) /* No args means match everything */
60 #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)
61 /* 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)
65 /*
66 * For the callers that just need pure paths from somewhere else, not
67 * from command line. Global --*-pathspecs options are ignored. No
68 * magic is parsed in each pathspec either. If PATHSPEC_LITERAL is
69 * allowed, then it will automatically set for every pathspec.
70 */
73 -#define PATHSPEC_LITERAL_PATH (1<<7)
71 +#define PATHSPEC_LITERAL_PATH (1<<6)
72
73 extern void parse_pathspec(struct pathspec *pathspec,
74 unsigned magic_mask,