Re: [PATCH] revision: fix --left/right-only use with unrelated histories
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Mar 30, 2025, 10:11 UTC
- Message-ID
- <f8a7d089-3150-4212-8ad0-c9bbb3858776@gmail.com>
- In-Reply-To
- <20250330055809.1019090-1-m@lfurio.us>
Hi Matt
On 30/03/2025 06:49, Matt Hunter wrote:
Show 10 quoted lines
> +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 && > + > + test $(comm -12 <(sort head) <(sort cmp) | wc -l) = "0"
Thank you for adding a test. We have a helper function test_line_count which provides a helpful debugging message if the comparison fails. Using that and avoiding process substitutions we'd write
sort head >sorted_head && sort cmp >sorted_cmp && comm -12 sorted_head sorted_cmp >actual && test_line_count = 0 actual
Thanks
Phillip
> + > test_done > > base-commit: 683c54c999c301c2cd6f715c411407c413b1d84e