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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:06:18

Nguyễn Thái Ngọc Duy  [off-list ref] writes:
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
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.
quoted hunk
---
 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.
 }

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

From: Duy Nguyen <hidden>
Date: 2016-06-15 23:06:21

On Wed, Aug 26, 2015 at 3:28 AM, Junio C Hamano [off-list ref] wrote:
Nguyễn Thái Ngọc Duy  [off-list ref] writes:
quoted
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
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.
Because the next patch adds some post processing before returning the
value. Having all the paths come to the same point would simplify the
code. Will update the commit message.
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help