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:
Johannes Schindelin
2021-02-05 14:46:13 +00:00
committed by Junio C Hamano
parent 3e6046edad
commit 1e79f97326
5 changed files with 40 additions and 4 deletions

View File

@ -717,4 +717,19 @@ test_expect_success 'format-patch --range-diff with multiple notes' '
test_cmp expect actual
'
test_expect_success '--left-only/--right-only' '
git switch --orphan left-right &&
test_commit first &&
test_commit unmatched &&
test_commit common &&
git switch -C left-right first &&
git cherry-pick common &&
git range-diff -s --left-only ...common >actual &&
head_oid=$(git rev-parse --short HEAD) &&
common_oid=$(git rev-parse --short common) &&
echo "1: $head_oid = 2: $common_oid common" >expect &&
test_cmp expect actual
'
test_done