parse_pathspec: support stripping submodule trailing slashes

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 <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2013-07-14 15:35:33 +07:00
committed by Junio C Hamano
parent 6330a17199
commit b69bb3fc27
2 changed files with 11 additions and 0 deletions

View File

@ -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