From d8e47e7d5c62e46c517cd56737f8fcb55ccf4c8f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 2 Jun 2016 08:59:29 -0700 Subject: pathspec: disable preload-index when attribute pathspec magic is in use The recent addition of the pathspec magic that requires a path to have certain attributes set is not yet compatible with the preload index codepath (e.g. "git status ':(attr:VAR=VAL)'") because the attribute subsystem is not thread-ready. For now, disable preload-index when such a pathspec magic is in use, until the attribute subsystem learns how to better cope with threading, to ease the development of the parts of the system that want to utilize the pathspec magic. Signed-off-by: Junio C Hamano --- pathspec.c | 12 ++++++++++++ pathspec.h | 2 ++ preload-index.c | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/pathspec.c b/pathspec.c index 08e6c523e7..a32e379e6f 100644 --- a/pathspec.c +++ b/pathspec.c @@ -251,6 +251,18 @@ static void eat_long_magic(struct pathspec_item *item, const char *elt, *copyfrom_ = copyfrom; } +int pathspec_is_non_threadable(const struct pathspec *pathspec) +{ + int i; + + for (i = 0; i < pathspec->nr; i++) { + const struct pathspec_item *item = &pathspec->items[i]; + if (item->attr_check) + return 1; + } + return 0; +} + /* * Take an element of a pathspec and check for magic signatures. * Append the result to the prefix. Return the magic bitmap. diff --git a/pathspec.h b/pathspec.h index 5308137485..07d21f01b6 100644 --- a/pathspec.h +++ b/pathspec.h @@ -115,4 +115,6 @@ extern void add_pathspec_matches_against_index(const struct pathspec *pathspec, extern const char *check_path_for_gitlink(const char *path); extern void die_if_path_beyond_symlink(const char *path, const char *prefix); +extern int pathspec_is_non_threadable(const struct pathspec *); + #endif /* PATHSPEC_H */ diff --git a/preload-index.c b/preload-index.c index c1fe3a3ef9..af468789f5 100644 --- a/preload-index.c +++ b/preload-index.c @@ -76,6 +76,10 @@ static void preload_index(struct index_state *index, if (!core_preload_index) return; + /* Do not preload when pathspec uses non-threadable subsystems */ + if (pathspec && pathspec_is_non_threadable(pathspec)) + return; /* for now ... */ + threads = index->cache_nr / THREAD_COST; if (threads < 2) return; -- cgit v1.2.1