From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] rerere: fix an off-by-one non-bug
Date: Sun, 28 Jun 2015 14:47:02 -0700 [thread overview]
Message-ID: <xmqqa8vjeca1.fsf@gitster.dls.corp.google.com> (raw)
When ac49f5ca (rerere "remaining", 2011-02-16) created a new helper
function check_one_conflict() out of find_conflict() function, and
made the latter use the returned value from the new helper to update
the loop control variable that is an index into the active_cache[],
the new variable was incremented by one too many when it pointed at
a path with only stage #1 entry at the very end of the cache.
This "strange" return value does not have any effect on the loop
control of two callers of this function, as they all notice that
active_nr+2 is larger than active_nr just like active_nr+1 is, but
nevertheless it puzzles the readers when they are trying to figure
out what the function is trying to do.
Help future readers from unnecessary confusion by dropping an
unnecessary +1 from the returned value..
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
rerere.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rerere.c b/rerere.c
index 31644de..543df47 100644
--- a/rerere.c
+++ b/rerere.c
@@ -371,7 +371,7 @@ static int check_one_conflict(int i, int *type)
*type = PUNTED;
if (ce_stage(e) == 1) {
if (active_nr <= ++i)
- return i + 1;
+ return i;
}
/* Only handle regular files with both stages #2 and #3 */
--
2.5.0-rc0-168-g2f1df93
next reply other threads:[~2015-06-28 21:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-28 21:47 Junio C Hamano [this message]
2015-06-28 22:26 ` [PATCH v2] rerere: fix an off-by-one non-bug Junio C Hamano
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=xmqqa8vjeca1.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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.