aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-01-06 23:51:47 -0800
committerJunio C Hamano <gitster@pobox.com>2010-01-06 23:51:47 -0800
commit64da3ae5c188b2b09bc1ed1eedca7e84c1aff940 (patch)
tree6db42f5bc203bf29dff7e12c25cf6e481b7947ff
parent6e8f993a5a17f71edfd26a026bbc83cbbd3c0638 (diff)
downloadgit-64da3ae5c188b2b09bc1ed1eedca7e84c1aff940.tar.gz
git-64da3ae5c188b2b09bc1ed1eedca7e84c1aff940.tar.xz
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>
-rw-r--r--builtin-checkout.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index c107fd643..b76cd2277 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -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));
@@ -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 */