summaryrefslogtreecommitdiff
path: root/builtin-merge-file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-08-28 01:10:04 -0700
committerJunio C Hamano <gitster@pobox.com>2008-08-30 19:41:43 -0700
commite0af48e49682ea3345f932f6b9e7fa7c5e5e611a (patch)
tree43cd383edc42ef508071fa6886a9e1fe10a7d281 /builtin-merge-file.c
parentf2b25dd81f4ccbf42700bd15feeb2becf10331ab (diff)
downloadgit-e0af48e49682ea3345f932f6b9e7fa7c5e5e611a.tar.gz
xdiff-merge: optionally show conflicts in "diff3 -m" style
When showing conflicting merges, we traditionally followed RCS's merge output format. The output shows: <<<<<<< postimage from one side; ======= postimage of the other side; and >>>>>>> Some poeple find it easier to be able to understand what is going on when they can view the common ancestor's version, which is used by "diff3 -m", which shows: <<<<<<< postimage from one side; ||||||| shared preimage; ======= postimage of the other side; and >>>>>>> This is an initial step to bring that as an optional feature to git. Only "git merge-file" has been converted, with "--diff3" option. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-merge-file.c')
-rw-r--r--builtin-merge-file.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin-merge-file.c b/builtin-merge-file.c
index 3605960c2d..5b4f020e38 100644
--- a/builtin-merge-file.c
+++ b/builtin-merge-file.c
@@ -4,7 +4,7 @@
#include "xdiff-interface.h"
static const char merge_file_usage[] =
-"git merge-file [-p | --stdout] [-q | --quiet] [-L name1 [-L orig [-L name2]]] file1 orig_file file2";
+"git merge-file [-p | --stdout] [--diff3] [-q | --quiet] [-L name1 [-L orig [-L name2]]] file1 orig_file file2";
int cmd_merge_file(int argc, const char **argv, const char *prefix)
{
@@ -13,6 +13,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
mmbuffer_t result = {NULL, 0};
xpparam_t xpp = {XDF_NEED_MINIMAL};
int ret = 0, i = 0, to_stdout = 0;
+ int merge_level = XDL_MERGE_ZEALOUS_ALNUM;
+ int merge_style = 0;
while (argc > 4) {
if (!strcmp(argv[1], "-L") && i < 3) {
@@ -25,6 +27,10 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
else if (!strcmp(argv[1], "-q") ||
!strcmp(argv[1], "--quiet"))
freopen("/dev/null", "w", stderr);
+ else if (!strcmp(argv[1], "--diff3")) {
+ merge_style = XDL_MERGE_DIFF3;
+ merge_level = XDL_MERGE_EAGER;
+ }
else
usage(merge_file_usage);
argc--;
@@ -46,7 +52,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
}
ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
- &xpp, XDL_MERGE_ZEALOUS_ALNUM, &result);
+ &xpp, merge_level | merge_style, &result);
for (i = 0; i < 3; i++)
free(mmfs[i].ptr);