git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] merge-file: add option to specify the marker size

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Feb 28, 2010, 19:56 UTC
Message-ID
<972adf380be481b5e8d031481586e9c34da2cbb7.1267385538.git.bert.wesarg@googlemail.com>
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---

This can probably improved in a way, that the marker size will be taken from attributes. This could be done by an explicit --marker-size-by-path option or an option which names one of the three input files as a git path.

For example:
 $ echo "foo conflict-marker-size=32" > .gitattributes
 $ git merge-file --marker-size-by-path=foo fileA fileB fileC
=> marker size would be 32
Or:
 $ echo "fileC conflict-marker-size=32" > .gitattributes
 $ git merge-file --marker-size-by-source=theirs fileA fileB fileC
=> marker size would be 32
 Documentation/git-merge-file.txt |    5 +++--
 builtin-merge-file.c             |    1 +
 t/t6023-merge-file.sh            |   37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt
index 234269a..a5b9c1f 100644
--- a/Documentation/git-merge-file.txt
+++ b/Documentation/git-merge-file.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git merge-file' [-L <current-name> [-L <base-name> [-L <other-name>]]]
-	[--ours|--theirs] [-p|--stdout] [-q|--quiet]
+	[--ours|--theirs] [-p|--stdout] [-q|--quiet] [--marker-size=<n>]
 	<current-file> <base-file> <other-file>
 
 
@@ -37,7 +37,8 @@ normally outputs a warning and brackets the conflict with lines containing
 If there are conflicts, the user should edit the result and delete one of
 the alternatives.  When `--ours` or `--theirs` option is in effect, however,
 these conflicts are resolved favouring lines from `<current-file>` or
-lines from `<other-file>` respectively.
+lines from `<other-file>` respectively.  The length of the conflict markers
+can be given with the `--marker-size` option.
 
 The exit value of this program is negative on error, and the number of
 conflicts otherwise. If the merge was clean, the exit value is 0.
diff --git a/builtin-merge-file.c b/builtin-merge-file.c
index 1e70073..57d757c 100644
--- a/builtin-merge-file.c
+++ b/builtin-merge-file.c
@@ -39,6 +39,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 			    XDL_MERGE_FAVOR_OURS),
 		OPT_SET_INT(0, "theirs", &favor, "for conflicts, use their version",
 			    XDL_MERGE_FAVOR_THEIRS),
+		OPT_INTEGER(0, "marker-size", &xmp.marker_size, "for conflicts, use this marker size"),
 		OPT__QUIET(&quiet),
 		OPT_CALLBACK('L', NULL, names, "name",
 			     "set labels for file1/orig_file/file2", &label_cb),
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index d605024..5034dd1 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -215,4 +215,41 @@ test_expect_success '"diff3 -m" style output (2)' '
 	test_cmp expect actual
 '
 
+cat >expect <<\EOF
+Dominus regit me,
+<<<<<<<<<< new8.txt
+et nihil mihi deerit;
+
+
+
+
+In loco pascuae ibi me collocavit;
+super aquam refectionis educavit me.
+||||||||||
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+==========
+et nihil mihi deerit,
+
+
+
+
+In loco pascuae ibi me collocavit --
+super aquam refectionis educavit me,
+>>>>>>>>>> new9.txt
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+Nam et si ambulavero in medio umbrae mortis,
+non timebo mala, quoniam TU mecum es:
+virga tua et baculus tuus ipsa me consolata sunt.
+EOF
+
+test_expect_success 'marker size' '
+	test_must_fail git merge-file -p --marker-size=10 \
+		new8.txt new5.txt new9.txt >actual &&
+	test_cmp expect actual
+'
+
 test_done
-- 
1.7.0.584.g2da2b
Next: Bert Wesarg
Message 1 of 10 in “merge-file: add option to specify the marker size”
  1. 1/3 merge-file: add option to specify the marker sizeBert Wesarg, Feb 28, 2010
  2. 2/3 make union merge an xdl merge favorBert Wesarg, Feb 28, 2010
  3. Junio C HamanoFeb 28, 2010
  4. Bert WesargMar 1, 2010
  5. Junio C HamanoMar 1, 2010
  6. Bert WesargMar 1, 2010
  7. Junio C HamanoMar 1, 2010
  8. 3/3 refactor merge flags into xmparam_tBert Wesarg, Feb 28, 2010
  9. Junio C HamanoFeb 28, 2010
  10. Bert WesargMar 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.