summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-03-05 12:30:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-03-06 23:02:21 (GMT)
commitdf84a436270ff44d32c085976bea17175aa7077b (patch)
tree2f769e4d7e472c0cbdc73fad9cd120361ec9e43f /diff.c
parent10f35b1cc01875e5fc2c02698f0e724578b38a53 (diff)
downloadgit-df84a436270ff44d32c085976bea17175aa7077b.zip
git-df84a436270ff44d32c085976bea17175aa7077b.tar.gz
git-df84a436270ff44d32c085976bea17175aa7077b.tar.bz2
diff-parseopt: convert --anchored
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/diff.c b/diff.c
index 8d08795..5195526 100644
--- a/diff.c
+++ b/diff.c
@@ -4839,6 +4839,19 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_anchored(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
+ ALLOC_GROW(options->anchors, options->anchors_nr + 1,
+ options->anchors_alloc);
+ options->anchors[options->anchors_nr++] = xstrdup(arg);
+ return 0;
+}
+
static int diff_opt_break_rewrites(const struct option *opt,
const char *arg, int unset)
{
@@ -5175,6 +5188,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_CALLBACK_F(0, "diff-algorithm", options, N_("<algorithm>"),
N_("choose a diff algorithm"),
PARSE_OPT_NONEG, diff_opt_diff_algorithm),
+ OPT_CALLBACK_F(0, "anchored", options, N_("<text>"),
+ N_("generate diff using the \"anchored diff\" algorithm"),
+ PARSE_OPT_NONEG, diff_opt_anchored),
OPT_GROUP(N_("Diff other options")),
OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
@@ -5212,16 +5228,8 @@ int diff_opt_parse(struct diff_options *options,
if (ac)
return ac;
- /* xdiff options */
- if (skip_prefix(arg, "--anchored=", &arg)) {
- options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
- ALLOC_GROW(options->anchors, options->anchors_nr + 1,
- options->anchors_alloc);
- options->anchors[options->anchors_nr++] = xstrdup(arg);
- }
-
/* flags options */
- else if (!strcmp(arg, "--binary")) {
+ if (!strcmp(arg, "--binary")) {
enable_patch_output(&options->output_format);
options->flags.binary = 1;
}