This flag is equivalent to builtin/ls-files.c:strip_trailing_slashes()
and is intended to replace that function when ls-files is converted to
use parse_pathspec.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 cache.h | 1 +
 setup.c | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/cache.h b/cache.h
index 32231d8..611a410 100644
--- a/cache.h
+++ b/cache.h
@@ -505,6 +505,7 @@ struct pathspec {
 
 /* parse_pathspec flags */
 #define PATHSPEC_EMPTY_MATCH_ALL (1<<0) /* No args means match everything */
+#define PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP (1<<1)
 
 extern int init_pathspec(struct pathspec *, const char **);
 extern void parse_pathspec(struct pathspec *pathspec, unsigned magic_mask,
diff --git a/setup.c b/setup.c
index d0b1d1f..a1aabc2 100644
--- a/setup.c
+++ b/setup.c
@@ -250,6 +250,15 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
        *raw = item->match = match;
        item->original = elt;
        item->len = strlen(item->match);
+
+       if ((flags & PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP) &&
+           (item->len >= 1 && item->match[item->len - 1] == '/') &&
+           (i = cache_name_pos(item->match, item->len - 1)) >= 0 &&
+           S_ISGITLINK(active_cache[i]->ce_mode)) {
+               item->len--;
+               match[item->len] = '\0';
+       }
+
        item->flags = 0;
        if (limit_pathspec_to_literal())
                item->nowildcard_len = item->len;
-- 
1.8.0.rc2.23.g1fb49df

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to