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
11
range-diff.c
11
range-diff.c
@ -513,7 +513,8 @@ static void output(struct string_list *a, struct string_list *b,
|
||||
|
||||
/* Show unmatched LHS commit whose predecessors were shown. */
|
||||
if (i < a->nr && a_util->matching < 0) {
|
||||
output_pair_header(&opts, patch_no_width,
|
||||
if (!range_diff_opts->right_only)
|
||||
output_pair_header(&opts, patch_no_width,
|
||||
&buf, &dashes, a_util, NULL);
|
||||
i++;
|
||||
continue;
|
||||
@ -521,7 +522,8 @@ static void output(struct string_list *a, struct string_list *b,
|
||||
|
||||
/* Show unmatched RHS commits. */
|
||||
while (j < b->nr && b_util->matching < 0) {
|
||||
output_pair_header(&opts, patch_no_width,
|
||||
if (!range_diff_opts->left_only)
|
||||
output_pair_header(&opts, patch_no_width,
|
||||
&buf, &dashes, NULL, b_util);
|
||||
b_util = ++j < b->nr ? b->items[j].util : NULL;
|
||||
}
|
||||
@ -551,7 +553,10 @@ int show_range_diff(const char *range1, const char *range2,
|
||||
struct string_list branch1 = STRING_LIST_INIT_DUP;
|
||||
struct string_list branch2 = STRING_LIST_INIT_DUP;
|
||||
|
||||
if (read_patches(range1, &branch1, range_diff_opts->other_arg))
|
||||
if (range_diff_opts->left_only && range_diff_opts->right_only)
|
||||
res = error(_("--left-only and --right-only are mutually exclusive"));
|
||||
|
||||
if (!res && read_patches(range1, &branch1, range_diff_opts->other_arg))
|
||||
res = error(_("could not parse log for '%s'"), range1);
|
||||
if (!res && read_patches(range2, &branch2, range_diff_opts->other_arg))
|
||||
res = error(_("could not parse log for '%s'"), range2);
|
||||
|
Reference in New Issue
Block a user