Re: [bug?] checkout -m doesn't work without a base version
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 15, 2011, 17:36 UTC
- Message-ID
- <7v4nx1pwjg.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <m2vcpiw1z1.fsf@igel.home>
Andreas Schwab <schwab@linux-m68k.org> writes:
Show 8 quoted lines
> 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) {