All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH 1/2] dir.c: make last_exclude_matching_from_list() run til the end
Date: Tue, 25 Aug 2015 13:28:08 -0700	[thread overview]
Message-ID: <xmqqmvxfxgdj.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1440334214-32131-2-git-send-email-pclouds@gmail.com> ("Nguyễn	Thái Ngọc Duy"'s message of "Sun, 23 Aug 2015 19:50:13 +0700")

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.

> ---
>  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.

>  			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.

>  			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.

>  }

  reply	other threads:[~2015-08-25 20:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-23 12:50 [PATCH 0/2] gitignore, re-inclusion fix Nguyễn Thái Ngọc Duy
2015-08-23 12:50 ` [PATCH 1/2] dir.c: make last_exclude_matching_from_list() run til the end Nguyễn Thái Ngọc Duy
2015-08-25 20:28   ` Junio C Hamano [this message]
2015-08-31 10:13     ` Duy Nguyen
2015-08-23 12:50 ` [PATCH 2/2] dir.c: don't exclude whole dir prematurely if neg pattern may match Nguyễn Thái Ngọc Duy
2015-09-13  1:18 ` [PATCH v2 0/2] gitignore, re-inclusion fix Nguyễn Thái Ngọc Duy
2015-09-13  1:19   ` [PATCH v2 1/2] dir.c: make last_exclude_matching_from_list() run til the end Nguyễn Thái Ngọc Duy
2015-09-13  1:19   ` [PATCH v2 2/2] dir.c: don't exclude whole dir prematurely if neg pattern may match Nguyễn Thái Ngọc Duy
2015-09-14 17:15     ` Junio C Hamano
2015-09-17 13:21       ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqmvxfxgdj.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.