Re: [PATCH v2 05/21] commit: convert to use parse_pathspec
From: Martin von Zweigbergk <hidden>
Date: 2016-06-15 22:55:44
On Fri, Jan 11, 2013 at 3:20 AM, Nguyễn Thái Ngọc Duy [off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/cache.h b/cache.h index e52365d..a3c316f 100644 --- a/cache.h +++ b/cache.h@@ -476,6 +476,9 @@ extern int ie_modified(const struct index_state *, struct cache_entry *, struct /* Pathspec magic */ #define PATHSPEC_FROMTOP (1<<0) +/* Pathspec flags */ +#define PATHSPEC_EMPTY_MATCH_ALL (1<<0) /* No args means match everything */ + struct pathspec { const char **raw; /* get_pathspec() result, not freed by free_pathspec() */ int nr;diff --git a/setup.c b/setup.c index 6e960b9..a26b6c0 100644 --- a/setup.c +++ b/setup.c@@ -280,6 +280,9 @@ void parse_pathspec(struct pathspec *pathspec, if (!entry && !prefix) return; + if (!*argv && (flags & PATHSPEC_EMPTY_MATCH_ALL)) + return; + /* No arguments with prefix -> prefix pathspec */ if (!entry) { static const char *raw[2];
I was surprised not to find these two hunks in 02/21. If they were there, you wouldn't have to explain in the log message of that patch that "flags" is for future-proofing. Also, "*argv" is written "entry" in the surrounding conditions.