git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] merge-recursive: configurable 'merge' program
@ 2006-12-04 11:36 Sam Vilain
  2006-12-05  0:01 ` Jakub Narebski
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Vilain @ 2006-12-04 11:36 UTC (permalink / raw)
  To: git

For those who like to spawn interactive merge tools on a merge failure
or otherwise run some kind of script, allow a "merge.tool" repo-config
option that will take arguments as merge(1) does.
---
 merge-recursive.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

Here's the script I use:

#!/bin/sh

output=`mktemp -p . .merge_file_XXXXXX`
branch1="$7"
branch2="$9"
ancestor="$8"

cp $branch1 $output

if merge -L $2 -L $4 -L $6 $output $ancestor $branch2
then
    mv $output $branch1
    exit 0
else

    rm $output

    emacs --eval "(ediff-merge-files-with-ancestor \"${branch1}\" 
\"${branch2}\" \"${ancestor}\" nil \"${output}\")"

    if [ -s "$output" ]
    then
        mv $output $branch1
        exit 0
    else
        exit 1
    fi
fi

diff --git a/merge-recursive.c b/merge-recursive.c
index 5a70a5c..0e2da57 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -627,6 +627,8 @@ static char *git_unpack_file(const unsigned char *sha1, char *path)
 	return path;
 }
 
+static char* merge_tool = "merge";
+
 static struct merge_file_info merge_file(struct diff_filespec *o,
 		struct diff_filespec *a, struct diff_filespec *b,
 		const char *branch1, const char *branch2)
@@ -661,12 +663,14 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
 			char src1[PATH_MAX];
 			char src2[PATH_MAX];
 			const char *argv[] = {
-				"merge", "-L", NULL, "-L", NULL, "-L", NULL,
+				NULL, "-L", NULL, "-L", NULL, "-L", NULL,
 				NULL, NULL, NULL,
 				NULL
 			};
 			char *la, *lb, *lo;
 
+			argv[0] = merge_tool;
+
 			git_unpack_file(o->sha1, orig);
 			git_unpack_file(a->sha1, src1);
 			git_unpack_file(b->sha1, src2);
@@ -1134,6 +1138,21 @@ static int process_entry(const char *path, struct stage_data *entry,
 	return clean_merge;
 }
 
+static int
+git_merge_config(const char *key, const char *val)
+{
+	char merge_key[] = "merge.";
+	if (strncmp( key, merge_key, sizeof merge_key - 1 ))
+		return 0;
+	key += sizeof merge_key - 1;
+
+	if (!strcmp( "tool", key )) {
+	    merge_tool = xstrdup(val);
+	}
+
+	return 0;
+}
+
 static int merge_trees(struct tree *head,
 		       struct tree *merge,
 		       struct tree *common,
@@ -1148,6 +1167,8 @@ static int merge_trees(struct tree *head,
 		return 1;
 	}
 
+	git_config( git_merge_config );
+
 	code = git_merge_trees(index_only, common, head, merge);
 
 	if (code != 0)
-- 
1.4.4.1.ge918e-dirty

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-12-05 14:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-04 11:36 [PATCH] merge-recursive: configurable 'merge' program Sam Vilain
2006-12-05  0:01 ` Jakub Narebski
2006-12-05  7:38   ` Johannes Schindelin
2006-12-05 10:23     ` Jakub Narebski
2006-12-05 14:07       ` Johannes Schindelin
2006-12-05 14:26         ` Jakub Narebski
2006-12-05 14:48           ` Johannes Schindelin
2006-12-05 15:01             ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).