aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-02-25 11:54:17 -0800
committerJunio C Hamano <gitster@pobox.com>2026-02-25 11:54:17 -0800
commit8d15dd1ce10f8d066ed058917f3183ec3efd7f95 (patch)
treecef824aa822c183db52f94873c382a169eb97975 /t
parent6b5ad01886b9492d8662509604277fc88e705dcb (diff)
parentb4e8f60a3c78477e1f28b052cd740ac4a43741d5 (diff)
downloadgit-8d15dd1ce10f8d066ed058917f3183ec3efd7f95.tar.xz
Merge branch 'ds/revision-maximal-only'
"git rev-list" and friends learn "--maximal-only" to show only the commits that are not reachable by other commits. * ds/revision-maximal-only: revision: add --maximal-only option
Diffstat (limited to 't')
-rwxr-xr-xt/t6000-rev-list-misc.sh15
-rwxr-xr-xt/t6600-test-reach.sh75
2 files changed, 90 insertions, 0 deletions
diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh
index fec16448cf..d0a2a86610 100755
--- a/t/t6000-rev-list-misc.sh
+++ b/t/t6000-rev-list-misc.sh
@@ -248,4 +248,19 @@ test_expect_success 'rev-list -z --boundary' '
test_cmp expect actual
'
+test_expect_success 'rev-list --boundary incompatible with --maximal-only' '
+ test_when_finished rm -rf repo &&
+
+ git init repo &&
+ test_commit -C repo 1 &&
+ test_commit -C repo 2 &&
+
+ oid1=$(git -C repo rev-parse HEAD~) &&
+ oid2=$(git -C repo rev-parse HEAD) &&
+
+ test_must_fail git -C repo rev-list --boundary --maximal-only \
+ HEAD~1..HEAD 2>err &&
+ test_grep "cannot be used together" err
+'
+
test_done
diff --git a/t/t6600-test-reach.sh b/t/t6600-test-reach.sh
index 6638d1aa1d..2613075894 100755
--- a/t/t6600-test-reach.sh
+++ b/t/t6600-test-reach.sh
@@ -762,4 +762,79 @@ test_expect_success 'for-each-ref is-base: --sort' '
--sort=refname --sort=-is-base:commit-2-3
'
+test_expect_success 'rev-list --maximal-only (all positive)' '
+ # Only one maximal.
+ cat >input <<-\EOF &&
+ refs/heads/commit-1-1
+ refs/heads/commit-4-2
+ refs/heads/commit-4-4
+ refs/heads/commit-8-4
+ EOF
+
+ cat >expect <<-EOF &&
+ $(git rev-parse refs/heads/commit-8-4)
+ EOF
+ run_all_modes git rev-list --maximal-only --stdin &&
+
+ # All maximal.
+ cat >input <<-\EOF &&
+ refs/heads/commit-5-2
+ refs/heads/commit-4-3
+ refs/heads/commit-3-4
+ refs/heads/commit-2-5
+ EOF
+
+ cat >expect <<-EOF &&
+ $(git rev-parse refs/heads/commit-5-2)
+ $(git rev-parse refs/heads/commit-4-3)
+ $(git rev-parse refs/heads/commit-3-4)
+ $(git rev-parse refs/heads/commit-2-5)
+ EOF
+ run_all_modes git rev-list --maximal-only --stdin &&
+
+ # Mix of both.
+ cat >input <<-\EOF &&
+ refs/heads/commit-5-2
+ refs/heads/commit-3-2
+ refs/heads/commit-2-5
+ EOF
+
+ cat >expect <<-EOF &&
+ $(git rev-parse refs/heads/commit-5-2)
+ $(git rev-parse refs/heads/commit-2-5)
+ EOF
+ run_all_modes git rev-list --maximal-only --stdin
+'
+
+test_expect_success 'rev-list --maximal-only (range)' '
+ cat >input <<-\EOF &&
+ refs/heads/commit-1-1
+ refs/heads/commit-2-5
+ refs/heads/commit-6-4
+ ^refs/heads/commit-4-5
+ EOF
+
+ cat >expect <<-EOF &&
+ $(git rev-parse refs/heads/commit-6-4)
+ EOF
+ run_all_modes git rev-list --maximal-only --stdin &&
+
+ # first-parent changes reachability: the first parent
+ # reduces the second coordinate to 1 before reducing the
+ # first coordinate.
+ cat >input <<-\EOF &&
+ refs/heads/commit-1-1
+ refs/heads/commit-2-5
+ refs/heads/commit-6-4
+ ^refs/heads/commit-4-5
+ EOF
+
+ cat >expect <<-EOF &&
+ $(git rev-parse refs/heads/commit-6-4)
+ $(git rev-parse refs/heads/commit-2-5)
+ EOF
+ run_all_modes git rev-list --maximal-only --stdin \
+ --first-parent --exclude-first-parent-only
+'
+
test_done