When fed a non-empty argv[], get_pathspec(prefix, argv) used to always return an array of string that has the same number of elements as argv[] had, but with ":" (work at toplevel without any path limit) magic pathspec it can return zero elements. Passing the result from get_pathspec() to this function will always give the correct number of pathspec elements. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- cache.h | 3 ++- setup.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletions(-) diff --git a/cache.h b/cache.h index be6ce72..6170dce 100644 --- a/cache.h +++ b/cache.h @@ -425,7 +425,8 @@ extern void set_git_work_tree(const char *tree); #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" -extern const char **get_pathspec(const char *prefix, const char **pathspec); +extern const char **get_pathspec(const char *prefix, const char **argv); +extern int count_pathspec(const char **pathspec); extern void setup_work_tree(void); extern const char *setup_git_directory_gently(int *); extern const char *setup_git_directory(void); diff --git a/setup.c b/setup.c index c1be388..cab9ddd 100644 --- a/setup.c +++ b/setup.c @@ -287,6 +287,16 @@ const char **get_pathspec(const char *prefix, const char **pathspec) return pathspec; } +int count_pathspec(const char **pathspec) +{ + int i; + if (!pathspec) + return 0; + for (i = 0; pathspec[i]; i++) + ; /* just counting */ + return i; +} + /* * Test if it looks like we're at a git directory. * We want to see: -- 1.7.5.1.290.g1b565 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html