pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP
authorBrandon Williams <bmwill@google.com>
Thu, 11 May 2017 22:04:26 +0000 (15:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 May 2017 05:23:46 +0000 (14:23 +0900)
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>
builtin/reset.c
builtin/rm.c
builtin/submodule--helper.c
pathspec.c
pathspec.h
index fc3b906c47bbcbefdc35b178016c031e46c06691..5db2adc4c4839b5f79351358f3115bbf74f6cf53 100644 (file)
@@ -236,7 +236,6 @@ static void parse_args(struct pathspec *pathspec,
 
        parse_pathspec(pathspec, 0,
                       PATHSPEC_PREFER_FULL |
-                      PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP |
                       (patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0),
                       prefix, argv);
 }
index fb79dcab181558e79e3934363cac3c712ffbd3aa..7c323d01235bf8bbb341004c843761dad99590d2 100644 (file)
@@ -271,8 +271,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                die(_("index file corrupt"));
 
        parse_pathspec(&pathspec, 0,
-                      PATHSPEC_PREFER_CWD |
-                      PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+                      PATHSPEC_PREFER_CWD,
                       prefix, argv);
        refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
 
index 566a5b6a6f8937742e83577918a94f0dcb20c66c..8cc648d85b586752d39079e75cf81a4ee685b622 100644 (file)
@@ -233,8 +233,7 @@ static int module_list_compute(int argc, const char **argv,
        int i, result = 0;
        char *ps_matched = NULL;
        parse_pathspec(pathspec, 0,
-                      PATHSPEC_PREFER_FULL |
-                      PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+                      PATHSPEC_PREFER_FULL,
                       prefix, argv);
 
        if (pathspec->nr)
index e424312786e2c428735923ae7a45e82aa147ffdc..1e5df2316e6624f6e9dd9b6aaa25a874b5409525 100644 (file)
@@ -386,18 +386,6 @@ static const char *parse_element_magic(unsigned *magic, int *prefix_len,
                return parse_short_magic(magic, elem);
 }
 
-static void strip_submodule_slash_cheap(struct pathspec_item *item)
-{
-       if (item->len >= 1 && item->match[item->len - 1] == '/') {
-               int i = cache_name_pos(item->match, item->len - 1);
-
-               if (i >= 0 && S_ISGITLINK(active_cache[i]->ce_mode)) {
-                       item->len--;
-                       item->match[item->len] = '\0';
-               }
-       }
-}
-
 /*
  * Perform the initialization of a pathspec_item based on a pathspec element.
  */
@@ -470,9 +458,6 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
                item->original = xstrdup(elt);
        }
 
-       if (flags & PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP)
-               strip_submodule_slash_cheap(item);
-
        if (magic & PATHSPEC_LITERAL) {
                item->nowildcard_len = item->len;
        } else {
index 3729efa85cd147891064fdf29a0c4bd29e9ed401..6671b95770f5abf74fd97bd86e447bd20b04502e 100644 (file)
@@ -58,19 +58,17 @@ struct pathspec {
 #define PATHSPEC_PREFER_CWD (1<<0) /* No args means match cwd */
 #define PATHSPEC_PREFER_FULL (1<<1) /* No args means match everything */
 #define PATHSPEC_MAXDEPTH_VALID (1<<2) /* max_depth field is valid */
-/* strip the trailing slash if the given path is a gitlink */
-#define PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP (1<<3)
 /* die if a symlink is part of the given path's directory */
-#define PATHSPEC_SYMLINK_LEADING_PATH (1<<4)
-#define PATHSPEC_PREFIX_ORIGIN (1<<5)
-#define PATHSPEC_KEEP_ORDER (1<<6)
+#define PATHSPEC_SYMLINK_LEADING_PATH (1<<3)
+#define PATHSPEC_PREFIX_ORIGIN (1<<4)
+#define PATHSPEC_KEEP_ORDER (1<<5)
 /*
  * For the callers that just need pure paths from somewhere else, not
  * from command line. Global --*-pathspecs options are ignored. No
  * magic is parsed in each pathspec either. If PATHSPEC_LITERAL is
  * allowed, then it will automatically set for every pathspec.
  */
-#define PATHSPEC_LITERAL_PATH (1<<7)
+#define PATHSPEC_LITERAL_PATH (1<<6)
 
 extern void parse_pathspec(struct pathspec *pathspec,
                           unsigned magic_mask,