summaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-02-23 23:45:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-02-24 08:36:31 (GMT)
commit04c9e11f2cffaf84dd20602f811bf377f6033cb6 (patch)
treed208cc09f78b3467718c499fca7b50c03b0c9f87 /builtin-checkout.c
parent52229a29c78df2e48de23ed70ab1934667971d3c (diff)
downloadgit-04c9e11f2cffaf84dd20602f811bf377f6033cb6.zip
git-04c9e11f2cffaf84dd20602f811bf377f6033cb6.tar.gz
git-04c9e11f2cffaf84dd20602f811bf377f6033cb6.tar.bz2
checkout: error out when index is unmerged even with -m
Even when -m is given to allow fallilng back to 3-way merge while switching branches, we should refuse if the original index is unmerged. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 283831e..d5f0930 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -226,24 +226,25 @@ static int merge_working_tree(struct checkout_opts *opts,
refresh_cache(REFRESH_QUIET);
if (unmerged_cache()) {
- ret = opts->merge ? -1 :
- error("you need to resolve your current index first");
- } else {
- topts.update = 1;
- topts.merge = 1;
- topts.gently = opts->merge;
- topts.verbose_update = !opts->quiet;
- topts.fn = twoway_merge;
- topts.dir = xcalloc(1, sizeof(*topts.dir));
- topts.dir->show_ignored = 1;
- topts.dir->exclude_per_dir = ".gitignore";
- tree = parse_tree_indirect(old->commit->object.sha1);
- init_tree_desc(&trees[0], tree->buffer, tree->size);
- tree = parse_tree_indirect(new->commit->object.sha1);
- init_tree_desc(&trees[1], tree->buffer, tree->size);
- ret = unpack_trees(2, trees, &topts);
+ error("you need to resolve your current index first");
+ return 1;
}
- if (ret) {
+
+ /* 2-way merge to the new branch */
+ topts.update = 1;
+ topts.merge = 1;
+ topts.gently = opts->merge;
+ topts.verbose_update = !opts->quiet;
+ topts.fn = twoway_merge;
+ topts.dir = xcalloc(1, sizeof(*topts.dir));
+ topts.dir->show_ignored = 1;
+ topts.dir->exclude_per_dir = ".gitignore";
+ tree = parse_tree_indirect(old->commit->object.sha1);
+ init_tree_desc(&trees[0], tree->buffer, tree->size);
+ tree = parse_tree_indirect(new->commit->object.sha1);
+ init_tree_desc(&trees[1], tree->buffer, tree->size);
+
+ if (unpack_trees(2, trees, &topts)) {
/*
* Unpack couldn't do a trivial merge; either
* give up or do a real merge, depending on