summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-03-24 08:20:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-03-24 13:21:23 (GMT)
commit11c659d89089ca236c65a1b824e85a27d9f09bcd (patch)
treedd1a3c9774617164fbeeb6b12aad717ca7d5a1e4 /diff.c
parent2f81cf9895fedb864477f9fb318c9ec7dc0a17ab (diff)
downloadgit-11c659d89089ca236c65a1b824e85a27d9f09bcd.zip
git-11c659d89089ca236c65a1b824e85a27d9f09bcd.tar.gz
git-11c659d89089ca236c65a1b824e85a27d9f09bcd.tar.bz2
diff-parseopt: convert --no-prefix
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.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index e1675a3..6029f8d 100644
--- a/diff.c
+++ b/diff.c
@@ -5022,6 +5022,18 @@ static int diff_opt_line_prefix(const struct option *opt,
return 0;
}
+static int diff_opt_no_prefix(const struct option *opt,
+ const char *optarg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ BUG_ON_OPT_ARG(optarg);
+ options->a_prefix = "";
+ options->b_prefix = "";
+ return 0;
+}
+
static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
const struct option *opt,
const char *arg, int unset)
@@ -5276,6 +5288,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_CALLBACK_F(0, "line-prefix", options, N_("<prefix>"),
N_("prepend an additional prefix to every line of output"),
PARSE_OPT_NONEG, diff_opt_line_prefix),
+ OPT_CALLBACK_F(0, "no-prefix", options, NULL,
+ N_("do not show any source or destination prefix"),
+ PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_no_prefix),
OPT_CALLBACK_F(0, "output-indicator-new",
&options->output_indicators[OUTPUT_INDICATOR_NEW],
N_("<char>"),
@@ -5468,8 +5483,6 @@ int diff_opt_parse(struct diff_options *options,
}
/* misc options */
- else if (!strcmp(arg, "--no-prefix"))
- options->a_prefix = options->b_prefix = "";
else if (opt_arg(arg, '\0', "inter-hunk-context",
&options->interhunkcontext))
;