summaryrefslogtreecommitdiff
path: root/range-diff.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2021-02-05 14:46:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-02-07 05:14:31 (GMT)
commit1e79f973266cfe0e3bab0e26e869b682078e457d (patch)
tree419e8d3df016350fa2867d2be741f90385b94fa4 /range-diff.c
parent3e6046edadf409537cc9e991d1df628fa96953ba (diff)
downloadgit-1e79f973266cfe0e3bab0e26e869b682078e457d.zip
git-1e79f973266cfe0e3bab0e26e869b682078e457d.tar.gz
git-1e79f973266cfe0e3bab0e26e869b682078e457d.tar.bz2
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>
Diffstat (limited to 'range-diff.c')
-rw-r--r--range-diff.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/range-diff.c b/range-diff.c
index 514125b..0a0d9ed 100644
--- a/range-diff.c
+++ b/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);