summaryrefslogtreecommitdiff
path: root/t/t4068-diff-symmetric-merge-base.sh
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2020-09-14 11:36:52 -0700
committerJunio C Hamano <gitster@pobox.com>2020-09-21 13:37:03 -0700
commit3d09c22869a7bd47f1683031937af0ed93b2fa3b (patch)
tree045ced9ffc692b665a5eec38611e9f75755399e4 /t/t4068-diff-symmetric-merge-base.sh
parent0f5a1d449b9538c2765de9d6683abbb83a7fb4e2 (diff)
downloadgit-3d09c22869a7bd47f1683031937af0ed93b2fa3b.tar.gz
builtin/diff-tree: learn --merge-base
The previous commit introduced ---merge-base a way to take the diff between the working tree or index and the merge base between an arbitrary commit and HEAD. It makes sense to extend this option to support the case where two commits are given too and behave in a manner identical to `git diff A...B`. Introduce the --merge-base flag as an alternative to triple-dot notation. Thus, we would be able to write the above as `git diff --merge-base A B`. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4068-diff-symmetric-merge-base.sh')
-rwxr-xr-xt/t4068-diff-symmetric-merge-base.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/t/t4068-diff-symmetric-merge-base.sh b/t/t4068-diff-symmetric-merge-base.sh
index 49432379cb..03487cc945 100755
--- a/t/t4068-diff-symmetric-merge-base.sh
+++ b/t/t4068-diff-symmetric-merge-base.sh
@@ -156,4 +156,38 @@ do
'
done
+for cmd in diff-tree diff
+do
+ test_expect_success "$cmd --merge-base with two commits" '
+ git $cmd commit-C master >expect &&
+ git $cmd --merge-base br2 master >actual &&
+ test_cmp expect actual
+ '
+
+ test_expect_success "$cmd --merge-base commit and non-commit" '
+ test_must_fail git $cmd --merge-base br2 master^{tree} 2>err &&
+ test_i18ngrep "fatal: --merge-base only works with commits" err
+ '
+
+ test_expect_success "$cmd --merge-base with no merge bases and two commits" '
+ test_must_fail git $cmd --merge-base br2 br3 2>err &&
+ test_i18ngrep "fatal: no merge base found" err
+ '
+
+ test_expect_success "$cmd --merge-base with multiple merge bases and two commits" '
+ test_must_fail git $cmd --merge-base master br1 2>err &&
+ test_i18ngrep "fatal: multiple merge bases found" err
+ '
+done
+
+test_expect_success 'diff-tree --merge-base with one commit' '
+ test_must_fail git diff-tree --merge-base master 2>err &&
+ test_i18ngrep "fatal: --merge-base only works with two commits" err
+'
+
+test_expect_success 'diff --merge-base with range' '
+ test_must_fail git diff --merge-base br2..br3 2>err &&
+ test_i18ngrep "fatal: --merge-base does not work with ranges" err
+'
+
test_done