From 4db4f0fba43d7e9b9b87a3a40d85ffbdfcef2884 Mon Sep 17 00:00:00 2001
From: John Keeping <john@keeping.me.uk>
Date: Fri, 5 Apr 2013 12:37:30 +0100
Subject: [PATCH 1/2] git-merge(1): document diff-algorithm option to
 merge-recursive

Commit 07924d4 (diff: Introduce --diff-algorithm command line option
2013-01-16) added diff-algorithm as a parameter to the recursive merge
strategy but did not document it.  Do so.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/merge-strategies.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/merge-strategies.txt b/Documentation/merge-strategies.txt
index 66db80296f5..49a9a7d53f5 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -48,6 +48,12 @@ patience;;
 	this when the branches to be merged have diverged wildly.
 	See also linkgit:git-diff[1] `--patience`.
 
+diff-algorithm=[patience|minimal|histogram|myers];;
+	Tells 'merge-recursive' to use a different diff algorithm, which
+	can help avoid mismerges that occur due to unimportant matching
+	lines (such as braces from distinct functions).  See also
+	linkgit:git-diff[1] `--diff-algorithm`.
+
 ignore-space-change;;
 ignore-all-space;;
 ignore-space-at-eol;;

From 0895c6d4c09045a3faeb7b652a844fc81c774631 Mon Sep 17 00:00:00 2001
From: John Keeping <john@keeping.me.uk>
Date: Fri, 5 Apr 2013 13:19:14 +0100
Subject: [PATCH 2/2] diff: allow unstuck arguments with --diff-algorithm

The argument to --diff-algorithm is mandatory, so there is no reason to
require the argument to be stuck to the option with '='.  Change this
for consistency with other Git commands.

Note that this does not change the handling of diff-algorithm in
merge-recursive.c since the primary interface to that is via the -X
option to 'git merge' where the unstuck form does not make sense.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/diff.c b/diff.c
index 0724fa6ff6c..08e39144c2f 100644
--- a/diff.c
+++ b/diff.c
@@ -3634,8 +3634,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 		options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
 	else if (!strcmp(arg, "--histogram"))
 		options->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);
-	else if (!prefixcmp(arg, "--diff-algorithm=")) {
-		long value = parse_algorithm_value(arg+17);
+	else if ((argcount = parse_long_opt("diff-algorithm", av, &optarg))) {
+		long value = parse_algorithm_value(optarg);
 		if (value < 0)
 			return error("option diff-algorithm accepts \"myers\", "
 				     "\"minimal\", \"patience\" and \"histogram\"");
@@ -3643,6 +3643,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 		DIFF_XDL_CLR(options, NEED_MINIMAL);
 		options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
 		options->xdl_opts |= value;
+		return argcount;
 	}
 
 	/* flags options */