@matheusbsbs / matheus-bagliano / commits / 64da3ae5c1
Fork 0

checkout -m: do not try to fall back to --merge from an unborn branch

If switching from an unborn branch (= empty tree) to a valid commit failed without -m, it would fail with -m option as well. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 6, 2010 at 23:51 UTC 64da3ae5c188b2b09bc1ed1eedca7e84c1aff940
1 file changed +8 -2
builtin-checkout.c
+8 -2
@@ -272,7 +272,7 @@ static int merge_working_tree(struct checkout_opts *opts,
272 topts.initial_checkout = is_cache_unborn();
273 topts.update = 1;
274 topts.merge = 1;
275 - topts.gently = opts->merge;
275 + topts.gently = opts->merge && old->commit;
276 topts.verbose_update = !opts->quiet;
277 topts.fn = twoway_merge;
278 topts.dir = xcalloc(1, sizeof(*topts.dir));
@@ -294,7 +294,13 @@ static int merge_working_tree(struct checkout_opts *opts,
294 struct tree *work;
295 if (!opts->merge)
296 return 1;
297 - parse_commit(old->commit);
297 +
298 + /*
299 + * Without old->commit, the below is the same as
300 + * the two-tree unpack we already tried and failed.
301 + */
302 + if (!old->commit)
303 + return 1;
304
305 /* Do more real merge */
306