Skip to content

Commit

Permalink
checkout -m: do not try to fall back to --merge from an unborn branch
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jan 7, 2010
1 parent 6e8f993 commit 64da3ae
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions builtin-checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static int merge_working_tree(struct checkout_opts *opts,
topts.initial_checkout = is_cache_unborn();
topts.update = 1;
topts.merge = 1;
topts.gently = opts->merge;
topts.gently = opts->merge && old->commit;
topts.verbose_update = !opts->quiet;
topts.fn = twoway_merge;
topts.dir = xcalloc(1, sizeof(*topts.dir));
Expand All @@ -294,7 +294,13 @@ static int merge_working_tree(struct checkout_opts *opts,
struct tree *work;
if (!opts->merge)
return 1;
parse_commit(old->commit);

/*
* Without old->commit, the below is the same as
* the two-tree unpack we already tried and failed.
*/
if (!old->commit)
return 1;

/* Do more real merge */

Expand Down

0 comments on commit 64da3ae

Please sign in to comment.