git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Pphillip.wood123@gmail.com <phillip.wood123@gmail.com>
Date
Apr 2, 2025, 13:12 UTC
Message-ID
<63e79534-db09-444f-8e82-8e01d914182d@gmail.com>
In-Reply-To
<D8TJMUMOGLBC.3FR8DHTTUN4M9@lfurio.us>
Hi Matt
On 30/03/2025 11:54, Matt Hunter wrote:
Show 24 quoted lines
> On Sun Mar 30, 2025 at 6:11 AM EDT, Phillip Wood wrote:
>> 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 for that helper tip.  I was just about to send a v2 when your
> message came in, so I'm getting that incorporated now.
> 
> By the way, I had originally wanted to write test assertions that
> checked the actual number of commit ids returned from each of the two
> calls to rev-list - something like:
> 
>      git rev-list --X-only HEAD...cmp >file &&
>      test_line_count = N file
> 
> But since I'm not very familiar with this test harness yet, I couldn't
> actually figure the correct value for N.  It's not 1 (the commit made in
> my test body), and it's not 2 (that commit, plus the one from the setup
> case at the top of the file).  Any appropriate higher value wasn't
> obvious.

Each test in a given file runs in the same repository (this is a performance optimization) so the number of commits will depend on what the previous tests have done. Usually there is a setup test at the start of the file which creates some commits with tags. Individual tests can then use those tags to establish a known state.

Best Wishes
Phillip
> So I switched to what you saw in my v1.  Maybe this "no commit ids in
> common" test is actually the stronger assertion?
Previous: Matt HunterNext: Matt Hunter
Message 6 of 9 in “revision: fix --left/right-only use with unrelated histories”
  1. revision: fix --left/right-only use with unrelated historiesMatt Hunter, Mar 30, 2025
  2. Johannes SixtMar 30, 2025
  3. Junio C HamanoApr 1, 2025
  4. Phillip WoodMar 30, 2025
  5. Matt HunterMar 30, 2025
  6. phillip.wood123@gmail.comApr 2, 2025
  7. Matt HunterApr 4, 2025
  8. revision: fix --left/right-only use with unrelated historiesMatt Hunter, Mar 30, 2025
  9. Junio C HamanoApr 11, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.