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

Re: [PATCH v2] test-chmtime: use parse_options() to parse command-line flags

From
SSShashank S <shashu8660@gmail.com>
Date
Nov 2, 2026, 04:56 UTC
Message-ID
<CANHmUQS15GGDOXm-WZ9M-UyKf2N0K+VixowL_heNKW0vjE0vJw@mail.gmail.com>
In-Reply-To
<20261102024623.24897-1-herroyalpriestess@gmail.com>
On Mon, 2 Nov 2026 at 08:17, Cynthia Uche <herroyalpriestess@gmail.com> wrote:
Hi Cynthia,
Thank you so much for taking the time to test and review this
Show 14 quoted lines
>
> Hi Shashank
> No test covers this. With that argument set to 0, t0082 still passed
> 3 of 3, while "test-tool chmtime --get -86400 file" failed with
> "unknown switch `8'" (exit 129). Could you add a test like this one?
> It passes with v2 and fails without the flag:
>
>   test_expect_success 'negative offset is not taken as an option' '
>         test-tool chmtime =1000000000 file &&
>         test-tool chmtime --get -86400 file >actual &&
>         echo 999913600 >expect &&
>         test_cmp expect actual
>   '
>

This is an excellent catch. Adding a dedicated test to prevent a regression here is a great idea, and I appreciate you providing the snippet. I will include this test in the v3 iteration.

Show 12 quoted lines
> Compared with the base build, I also saw three changes that the
> commit message does not mention:
>
>   - "+0 --get f": base tried to stat "--get"; v2 accepts the flag
>     after the timespec and prints the mtime.
>   - "-g -v f": base tried to stat "-v" [and still printed the mtime]
>     and exited 0; v2 dies (exit 128).
>   - usage errors exit with 129 instead of 1.
>
> Could you mention them in the commit message, or let me know if any
> of them is not intended?
>

All of these behavioral shifts are intended! Since `parse_options()` handles arguments independent of their position and uses standard error codes (129 for usage, 128 for `die`), the tool now behaves much more like a standard Git command. You are completely right that I should document these side-effects explicitly in the commit message.

I will add a breakdown of these behavioral improvements to the commit message in v3. Thanks again for the meticulous review!

Shashank S Mogaveera
Previous: Cynthia UcheNext: Shashank S via GitGitGadget
Message 8 of 9 in “test-chmtime: use parse_options() to parse command-line flags”
  1. test-chmtime: use parse_options() to parse command-line flagsShashank S via GitGitGadget, Oct 27, 2026
  2. Junio C HamanoOct 27, 2026
  3. Shashank SOct 29, 2026
  4. Junio C HamanoOct 27, 2026
  5. Shashank SOct 29, 2026
  6. test-chmtime: use parse_options() to parse command-line flagsShashank S via GitGitGadget, Oct 30, 2026
  7. Cynthia UcheNov 2, 2026
  8. Shashank SNov 2, 2026
  9. test-chmtime: use parse_options() to parse command-line flagsShashank S via GitGitGadget, Nov 2, 2026

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.