Subject: Re: [PATCH] revision: fix --left/right-only use with unrelated histories

From: Phillip Wood <[email-masked]>
Date: Sun, 30 Mar 2025 11:11:54 +0100

Hi Matt

On 30/03/2025 06:49, Matt Hunter wrote:
> +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