[PATCH] Configurable diff context in merge-tree command
From: Erik van Zijst <hidden>
Date: 2016-06-15 22:51:48
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
Added support for the -U/--unified command line arguments to the git-merge-tree command to change the number of context lines that are generated. Signed-off-by: Erik van Zijst <redacted> --- Documentation/git-merge-tree.txt | 8 +++++++- builtin/merge-tree.c | 26 +++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index c5f84b6..7a0d927 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt@@ -9,7 +9,7 @@ git-merge-tree - Show three-way merge without touching index SYNOPSIS -------- [verse] -'git merge-tree' <base-tree> <branch1> <branch2> +'git merge-tree' [-U<n> | --unified=<n>] <base-tree> <branch1> <branch2> DESCRIPTION -----------
@@ -24,6 +24,12 @@ merge results outside of the index, and stuff theresults back into the index. For this reason, the output from the command omits entries that match the <branch1> tree. +OPTIONS +------- +-U<n>:: +--unified=<n>:: + Generate diffs with <n> lines of context instead of the usual three. + GIT --- Part of the linkgit:git[1] suite
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 897a563..0a5c8c9 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c@@ -4,9 +4,15 @@ #include "blob.h" #include "exec_cmd.h" #include "merge-file.h" +#include "parse-options.h" + +static const char * const merge_tree_usage[] = { + "git merge-tree [options] <base-tree> <branch1> <branch2>", + NULL +}; -static const char merge_tree_usage[] = "git merge-tree <base-tree>
<branch1> <branch2>";
static int resolve_directories = 1;
+static long ctxlen = 3;
struct merge_list {
struct merge_list *next;@@ -108,7 +114,7 @@ static void show_diff(struct merge_list *entry) xpp.flags = 0; memset(&xecfg, 0, sizeof(xecfg)); - xecfg.ctxlen = 3; + xecfg.ctxlen = ctxlen; ecb.outf = show_outf; ecb.priv = NULL;
@@ -341,13 +347,19 @@ int cmd_merge_tree(int argc, const char **argv,const char *prefix)
{
struct tree_desc t[3];
void *buf1, *buf2, *buf3;
+ const struct option opts[] = {
+ OPT_INTEGER('U', "unified", &ctxlen, "number of diff context lines"),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, prefix, opts, merge_tree_usage, 0);
- if (argc != 4)
- usage(merge_tree_usage);
+ if (argc != 3)
+ usage(*merge_tree_usage);
- buf1 = get_tree_descriptor(t+0, argv[1]);
- buf2 = get_tree_descriptor(t+1, argv[2]);
- buf3 = get_tree_descriptor(t+2, argv[3]);
+ buf1 = get_tree_descriptor(t+0, argv[0]);
+ buf2 = get_tree_descriptor(t+1, argv[1]);
+ buf3 = get_tree_descriptor(t+2, argv[2]);
merge_trees(t, "");
free(buf1);
free(buf2);
--
1.7.1