Re: [PATCH v2 05/21] commit: convert to use parse_pathspec
- From
Martin von Zweigbergk <martinvonz@gmail.com>
- Date
- Jan 12, 2013, 22:54 UTC
- Message-ID
- <CANiSa6hSgYcGAYCfWu5wkQyaKF9R2SME2LmJ-Qt+uvpBQU2qBw@mail.gmail.com>
- In-Reply-To
- <1357903275-16804-6-git-send-email-pclouds@gmail.com>
On Fri, Jan 11, 2013 at 3:20 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 29 quoted lines
>
> 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.