Re: [PATCH 14/19] Convert ce_path_match() use to match_pathspec()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 13, 2010, 19:31 UTC
- Message-ID
- <7vsjy1zcyg.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1292233616-27692-15-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 6 quoted lines
> Previously ce_path_match() is used together with tree_entry_interesting(). > Both do not support wildcards. tree_entry_interesting() understands > wildcards now, so it's time to teach ce_path_match() to do the same. > > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> > ---
This function is called from both Porcelains (e.g. "git diff" via diff-lib.c and "git status" via wt-status.c) and plumbing commands (e.g. "git update-index"), and we are changing the semantics in a big way, even though it is a huge improvement.
I am fairly excited with the progress of this series. When it gets merged to 'master', we will be declaring 1.8.0 ;-)
I imagine that eventually ce_path_match() will also take "struct pathspec *" not "const char **" when the series is completed, yes? Or there is no real need for that?
Show 39 quoted lines
> read-cache.c | 20 +-------------------
> 1 files changed, 1 insertions(+), 19 deletions(-)
>
> diff --git a/read-cache.c b/read-cache.c
> index 1f42473..cbabd8b 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -685,28 +685,10 @@ int ce_same_name(struct cache_entry *a, struct cache_entry *b)
>
> int ce_path_match(const struct cache_entry *ce, const char **pathspec)
> {
> - const char *match, *name;
> - int len;
> -
> if (!pathspec)
> return 1;
>
> - len = ce_namelen(ce);
> - name = ce->name;
> - while ((match = *pathspec++) != NULL) {
> - int matchlen = strlen(match);
> - if (matchlen > len)
> - continue;
> - if (memcmp(name, match, matchlen))
> - continue;
> - if (matchlen && name[matchlen-1] == '/')
> - return 1;
> - if (name[matchlen] == '/' || !name[matchlen])
> - return 1;
> - if (!matchlen)
> - return 1;
> - }
> - return 0;
> + return match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, NULL);
> }
>
> /*
> --
> 1.7.3.3.476.g10a82