[PATCH v2 1/4] pathspec: use is_dir_sep() to check for trailing slashes
- From
John Keeping <john@keeping.me.uk>
- Date
- Sep 12, 2013, 19:24 UTC
- Message-ID
- <88455dac2dce36135c070cff01215e9ae0259635.1379013786.git.john@keeping.me.uk>
- In-Reply-To
- <cover.1379013786.git.john@keeping.me.uk>
This allows us to correctly removing trailing backslashes on Windows when checking for submodules.
Signed-off-by: John Keeping <john@keeping.me.uk> --- pathspec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/pathspec.c b/pathspec.c index ad1a9f5..7c6963b 100644 --- a/pathspec.c +++ b/pathspec.c @@ -252,7 +252,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item, item->prefix = prefixlen; if ((flags & PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP) && - (item->len >= 1 && item->match[item->len - 1] == '/') && + (item->len >= 1 && is_dir_sep(item->match[item->len - 1])) && (i = cache_name_pos(item->match, item->len - 1)) >= 0 && S_ISGITLINK(active_cache[i]->ce_mode)) { item->len--; @@ -267,7 +267,8 @@ static unsigned prefix_pathspec(struct pathspec_item *item, if (!S_ISGITLINK(ce->ce_mode)) continue; - if (item->len <= ce_len || match[ce_len] != '/' || + if (item->len <= ce_len || + !is_dir_sep(match[ce_len]) || memcmp(ce->name, match, ce_len)) continue; if (item->len == ce_len + 1) {
-- 1.8.4.277.gfbd6843.dirty