]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'mh/left-right-limited'
authorJunio C Hamano <gitster@pobox.com>
Wed, 23 Apr 2025 20:58:51 +0000 (13:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Apr 2025 20:58:51 +0000 (13:58 -0700)
"git log --{left,right}-only A...B", when A and B does not share
any common ancestor, now behaves as expected.

* mh/left-right-limited:
  revision: fix --left/right-only use with unrelated histories

1  2 
revision.c
t/t6000-rev-list-misc.sh

diff --cc revision.c
Simple merge
index 33881274a41ad2eb2adfa661cea0f8ac16909315,d338f7ecb467b379afb5124de41c2f70cbf9d99f..fec16448cfddb873c1dde45975dd119bee29b989
@@@ -182,55 -182,19 +182,70 @@@ test_expect_success 'rev-list --unpacke
        test_cmp expect actual
  '
  
+ test_expect_success 'rev-list one-sided unrelated symmetric diff' '
+       test_tick &&
+       git commit --allow-empty -m xyz &&
+       git branch cmp &&
+       git rebase --force-rebase --root &&
+       git rev-list --left-only  HEAD...cmp >head &&
+       git rev-list --right-only HEAD...cmp >cmp  &&
+       sort head >head.sorted &&
+       sort cmp >cmp.sorted &&
+       comm -12 head.sorted cmp.sorted >actual &&
+       test_line_count = 0 actual
+ '
 +test_expect_success 'rev-list -z' '
 +      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) &&
 +
 +      printf "%s\0%s\0" "$oid2" "$oid1" >expect &&
 +      git -C repo rev-list -z HEAD >actual &&
 +
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'rev-list -z --objects' '
 +      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:1.t) &&
 +      oid2=$(git -C repo rev-parse HEAD:2.t) &&
 +      path1=1.t &&
 +      path2=2.t &&
 +
 +      printf "%s\0path=%s\0%s\0path=%s\0" "$oid1" "$path1" "$oid2" "$path2" \
 +              >expect &&
 +      git -C repo rev-list -z --objects HEAD:1.t HEAD:2.t >actual &&
 +
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'rev-list -z --boundary' '
 +      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) &&
 +
 +      printf "%s\0%s\0boundary=yes\0" "$oid2" "$oid1" >expect &&
 +      git -C repo rev-list -z --boundary HEAD~.. >actual &&
 +
 +      test_cmp expect actual
 +'
 +
  test_done