summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 52229a2)
raw | patch | inline | side by side (parent: 52229a2)
author | Junio C Hamano <gitster@pobox.com> | |
Sat, 23 Feb 2008 23:45:19 +0000 (15:45 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 24 Feb 2008 08:36:31 +0000 (00:36 -0800) |
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>
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>
builtin-checkout.c | patch | blob | history |
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 283831e8af93ede033bfe8eb27ae609e31638051..d5f093094c4c76bc7fb1378ffb70e4a553654da8 100644 (file)
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
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