ls-files: prevent prune_cache from overeagerly pruning submodules
commitcbca060e102aedcedbd1c4b5394aeed24885d5de
authorBrandon Williams <bmwill@google.com>
Thu, 11 May 2017 22:04:25 +0000 (11 15:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 May 2017 05:23:46 +0000 (12 14:23 +0900)
treec636c2a0f7f87109b54a38471b3923a9917475a3
parentc08397e3aa46fd0f0da29dfe5b257839b9c5d1c8
ls-files: prevent prune_cache from overeagerly pruning submodules

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.

ls-files is the only caller of 'parse_pathspec()' which relies on the
behavior of the PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag because it
uses the result to construct a common prefix of all provided pathspecs
which is then used to prune the index of all entries which don't have
that prefix.  Since submodules entries in the index don't have a
trailing slash 'prune_cache()' will be overeager and prune a submodule
'sub' if the common prefix is 'sub/'.  To correct this behavior, only
prune entries which don't match up to, but not including, a trailing
slash of the common prefix.

This is in preparation to remove the
PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag in a later patch.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/ls-files.c