summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pathspec.c9
-rw-r--r--pathspec.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/pathspec.c b/pathspec.c
index 06778fc756..1c07c23fe0 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -205,6 +205,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';
+ }
+
if (limit_pathspec_to_literal())
item->nowildcard_len = item->len;
else
diff --git a/pathspec.h b/pathspec.h
index aa98597bda..51448513e6 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -31,6 +31,8 @@ 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)
extern int init_pathspec(struct pathspec *, const char **);
extern void parse_pathspec(struct pathspec *pathspec,