summaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-09-01 02:32:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-09-01 03:09:21 (GMT)
commiteac5a401512181cd315a1031af2b8a25430e335a (patch)
tree246e7b22c653c94af9a0cd615281b92e39fda902 /builtin-checkout.c
parent0cf8581e330e7140c9f5c94a53d441187c0f8ff9 (diff)
downloadgit-eac5a401512181cd315a1031af2b8a25430e335a.zip
git-eac5a401512181cd315a1031af2b8a25430e335a.tar.gz
git-eac5a401512181cd315a1031af2b8a25430e335a.tar.bz2
checkout --conflict=<style>: recreate merge in a non-default style
This new option does essentially the same thing as -m option when checking unmerged paths out of the index, but it uses the specified style instead of configured merge.conflictstyle. Setting "merge.conflictstyle" to "diff3" is usually less useful than using the default "merge" style, because the latter allows a conflict that results by both sides changing the same region in a very similar way to get simplified substancially by reducing the common lines. However, when one side removed a group of lines (perhaps a function was moved to some other file) while the other side modified it, the default "merge" style does not give any clue as to why the hunk is left conflicting. You would need the original to understand what is going on. The recommended use would be not to set merge.conflictstyle variable so that you would usually use the default "merge" style conflict, and when the result in a path in a particular merge is too hard to understand, use "git checkout --conflict=diff3 $path" to check it out with the original to review what is going on. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index b957193..7921432 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -580,6 +580,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
const char *arg;
struct branch_info new;
struct tree *source_tree = NULL;
+ char *conflict_style = NULL;
struct option options[] = {
OPT__QUIET(&opts.quiet),
OPT_STRING('b', NULL, &opts.new_branch, "new branch", "branch"),
@@ -591,7 +592,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
OPT_SET_INT('3', "theirs", &opts.writeout_stage, "stage",
3),
OPT_BOOLEAN('f', NULL, &opts.force, "force"),
- OPT_BOOLEAN('m', NULL, &opts.merge, "merge"),
+ OPT_BOOLEAN('m', "merge", &opts.merge, "merge"),
+ OPT_STRING(0, "conflict", &conflict_style, "style",
+ "conflict style (merge or diff3)"),
OPT_END(),
};
int has_dash_dash;
@@ -606,6 +609,11 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, options, checkout_usage,
PARSE_OPT_KEEP_DASHDASH);
+ if (conflict_style) {
+ opts.merge = 1; /* implied */
+ git_xmerge_config("merge.conflictstyle", conflict_style, NULL);
+ }
+
if (!opts.new_branch && (opts.track != git_branch_track))
die("git checkout: --track and --no-track require -b");