Re: [bug?] checkout -m doesn't work without a base version
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:39
Andreas Schwab [off-list ref] writes:
Junio C Hamano [off-list ref] writes:quoted
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) {