Re: [PATCH v2] test-chmtime: use parse_options() to parse command-line flags
- From
- Cynthia Uche <herroyalpriestess@gmail.com>
- Date
- Nov 2, 2026, 02:46 UTC
- Message-ID
- <20261102024623.24897-1-herroyalpriestess@gmail.com>
- In-Reply-To
- <pull.2280.v2.git.1793350341743.gitgitgadget@gmail.com>
Hi Shashank,
I built v2 (43c96de13e) with NO_RUST=1 and compared it with a build of the base commit (7e34d8174d). t0082 passes 3 of 3. Thanks for taking Junio's three suggestions from v1.
> instead. Pass PARSE_OPT_KEEP_UNKNOWN_OPT so that negative relative time > offsets (such as '-86400') are not rejected as unknown short options > and remain in argv for timespec_arg() to parse.
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 '
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?
Cynthia