git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] dir.c: make last_exclude_matching_from_list() run til the end

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2015, 20:28 UTC
Message-ID
<xmqqmvxfxgdj.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1440334214-32131-2-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>

Because? Title just tells what the patch meant to do (i.e. instead of returning it keeps looping), but does not say why it is a good idea. Besides, this a no-op patch and does not make it keep looping.

Show 17 quoted lines
> ---
>  dir.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/dir.c b/dir.c
> index c00c7e2..3a7630a 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -901,6 +901,7 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
>  						       int *dtype,
>  						       struct exclude_list *el)
>  {
> +	struct exclude *exc = NULL; /* undecided */
>  	int i;
>  
>  	if (!el->nr)
> @@ -922,18 +923,22 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
Note that we are in a big for() loop that scans backwards an array.
Show 9 quoted lines
>  			if (match_basename(basename,
>  					   pathlen - (basename - pathname),
>  					   exclude, prefix, x->patternlen,
> -					   x->flags))
> -				return x;
> +					   x->flags)) {
> +				exc = x;
> +				break;
> +			}

We used to return x immediately; now we store x to exc and break, i.e. leave the loop.

Show 11 quoted lines
>  			continue;
>  		}
>  
>  		assert(x->baselen == 0 || x->base[x->baselen - 1] == '/');
>  		if (match_pathname(pathname, pathlen,
>  				   x->base, x->baselen ? x->baselen - 1 : 0,
> -				   exclude, prefix, x->patternlen, x->flags))
> -			return x;
> +				   exclude, prefix, x->patternlen, x->flags)) {
> +			exc = x;
> +			break;

We used to return x immediately; now we store x to exc and break, i.e. leave the loop.

> +		}
>  	}
> -	return NULL; /* undecided */
> +	return exc;
And then we return exc.
>  }
Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 3 of 10 in “gitignore, re-inclusion fix”
  1. 0/2 gitignore, re-inclusion fixNguyễn Thái Ngọc Duy, Aug 23, 2015
  2. 1/2 dir.c: make last_exclude_matching_from_list() run til the endNguyễn Thái Ngọc Duy, Aug 23, 2015
  3. Junio C HamanoAug 25, 2015
  4. Duy NguyenAug 31, 2015
  5. 2/2 dir.c: don't exclude whole dir prematurely if neg pattern may matchNguyễn Thái Ngọc Duy, Aug 23, 2015
  6. 0/2 gitignore, re-inclusion fixNguyễn Thái Ngọc Duy, Sep 13, 2015
  7. 1/2 dir.c: make last_exclude_matching_from_list() run til the endNguyễn Thái Ngọc Duy, Sep 13, 2015
  8. 2/2 dir.c: don't exclude whole dir prematurely if neg pattern may matchNguyễn Thái Ngọc Duy, Sep 13, 2015
  9. Junio C HamanoSep 14, 2015
  10. Duy NguyenSep 17, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.