range-diff: offer --left-only/--right-only options
When comparing commit ranges, one is frequently interested only in one side, such as asking the question "Has this patch that I submitted to the Git mailing list been applied?": one would only care about the part of the output that corresponds to the commits in a local branch. To make that possible, imitate the `git rev-list` options `--left-only` and `--right-only`. This addresses https://github.com/gitgitgadget/git/issues/206 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
3e6046edad
commit
1e79f97326
@ -20,7 +20,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
|
||||
.diffopt = &diffopt,
|
||||
.other_arg = &other_arg
|
||||
};
|
||||
int simple_color = -1;
|
||||
int simple_color = -1, left_only = 0, right_only = 0;
|
||||
struct option range_diff_options[] = {
|
||||
OPT_INTEGER(0, "creation-factor",
|
||||
&range_diff_opts.creation_factor,
|
||||
@ -30,6 +30,10 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
|
||||
OPT_PASSTHRU_ARGV(0, "notes", &other_arg,
|
||||
N_("notes"), N_("passed to 'git log'"),
|
||||
PARSE_OPT_OPTARG),
|
||||
OPT_BOOL(0, "left-only", &left_only,
|
||||
N_("only emit output related to the first range")),
|
||||
OPT_BOOL(0, "right-only", &right_only,
|
||||
N_("only emit output related to the second range")),
|
||||
OPT_END()
|
||||
};
|
||||
struct option *options;
|
||||
@ -87,6 +91,8 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
|
||||
FREE_AND_NULL(options);
|
||||
|
||||
range_diff_opts.dual_color = simple_color < 1;
|
||||
range_diff_opts.left_only = left_only;
|
||||
range_diff_opts.right_only = right_only;
|
||||
res = show_range_diff(range1.buf, range2.buf, &range_diff_opts);
|
||||
|
||||
strvec_clear(&other_arg);
|
||||
|
Reference in New Issue
Block a user