diff.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/diff.c b/diff.c index 895951b849..cf168e727d 100644 --- a/diff.c +++ b/diff.c @@ -5000,6 +5000,17 @@ static int diff_opt_char(const struct option *opt, return 0; } +static int diff_opt_no_char(const struct option *opt, + const char *arg, int unset) +{ + char *value = opt->value; + + BUG_ON_OPT_NEG(unset); + BUG_ON_OPT_ARG(arg); + *value = 0; + return 0; +} + static int diff_opt_color_moved(const struct option *opt, const char *arg, int unset) { @@ -5493,6 +5504,14 @@ static void prep_parse_options(struct diff_options *options) N_(""), N_("specify the character to indicate a context instead of ' '"), PARSE_OPT_NONEG, diff_opt_char), + OPT_CALLBACK_F(0, "new-only", + &options->output_indicators[OUTPUT_INDICATOR_OLD], NULL, + N_("show only new lines in diff"), + PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_no_char), + OPT_CALLBACK_F(0, "old-only", + &options->output_indicators[OUTPUT_INDICATOR_NEW], NULL, + N_("show only old lines in diff"), + PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_no_char), OPT_GROUP(N_("Diff rename options")), OPT_CALLBACK_F('B', "break-rewrites", &options->break_opt, N_("[/]"),