From: Junio C Hamano <gitster@pobox.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Michael Schubert <mschub@elegosoft.com>,
Pete Harlan <pgit@pcharlan.com>,
git@vger.kernel.org
Subject: Re: [bug?] checkout -m doesn't work without a base version
Date: Thu, 15 Dec 2011 09:36:03 -0800 [thread overview]
Message-ID: <7v4nx1pwjg.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <m2vcpiw1z1.fsf@igel.home> (Andreas Schwab's message of "Thu, 15 Dec 2011 11:42:10 +0100")
Andreas Schwab <schwab@linux-m68k.org> writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> The variable "mode" is assigned to when we see an stage #2 entry in the
>> loop, and we should have updated threeway[1] immediately before doing so.
>> If threeway[1] is not updated, we would have already returned before using
>> the variable in make_cache_entry().
>
> How can you be sure that ce_stage(ce) ever returns 2?
You cannot and and there are cases where you exit the loop without finding
a stage #2 entry. But in that case threeway[1] stays 0{40} and control is
returned to the caller without ever getting to the place where the
variable is used.
You could do the usual "unnecessary initialization" trick, though.
builtin/checkout.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 31aa248..064e7a1 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -152,7 +152,7 @@ static int checkout_merged(int pos, struct checkout *state)
unsigned char sha1[20];
mmbuffer_t result_buf;
unsigned char threeway[3][20];
- unsigned mode;
+ unsigned mode = 0;
memset(threeway, 0, sizeof(threeway));
while (pos < active_nr) {
next prev parent reply other threads:[~2011-12-15 17:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-04 22:31 [bug?] checkout -m doesn't work without a base version Pete Harlan
2011-12-05 18:58 ` Junio C Hamano
2011-12-07 7:30 ` Pete Harlan
2011-12-08 18:27 ` Junio C Hamano
2011-12-12 1:48 ` Pete Harlan
2011-12-12 5:29 ` Junio C Hamano
2011-12-20 20:37 ` [PATCH] t/t2023-checkout-m.sh: fix use of test_must_fail Ævar Arnfjörð Bjarmason
2011-12-20 21:23 ` Junio C Hamano
2011-12-14 10:19 ` [bug?] checkout -m doesn't work without a base version Michael Schubert
2011-12-14 17:54 ` Junio C Hamano
2011-12-15 4:20 ` Miles Bader
2011-12-15 10:11 ` Michael Schubert
2011-12-15 10:42 ` Andreas Schwab
2011-12-15 17:36 ` Junio C Hamano [this message]
2011-12-16 22:38 ` Ramsay Jones
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=7v4nx1pwjg.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mschub@elegosoft.com \
--cc=pgit@pcharlan.com \
--cc=schwab@linux-m68k.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).