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

Re: [PATCH v3] bugreport: reject positional arguments

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Oct 27, 2023, 14:41 UTC
Message-ID
<3e15f266-c790-4b71-84b6-1328339425c1@gmail.com>
In-Reply-To
<CAPig+cTmYtWR=QN3LeN9yw3HmsKEmD2fUiRjKf=eJHhAZyT-yA@mail.gmail.com>
On 26/10/2023 18:18, Eric Sunshine wrote:
Show 33 quoted lines
> On Thu, Oct 26, 2023 at 11:55 AM <emilyshaffer@google.com> wrote:
>> git-bugreport already rejected unrecognized flag arguments, like
>> `--diaggnose`, but this doesn't help if the user's mistake was to forget
>> the `--` in front of the argument. This can result in a user's intended
>> argument not being parsed with no indication to the user that something
>> went wrong. Since git-bugreport presently doesn't take any positionals
>> at all, let's reject all positionals and give the user a usage hint.
>>
>> Signed-off-by: Emily Shaffer <nasamuffin@google.com>
>> ---
>> Per Eric's and Dragan's comments, dropped the null checking for argv[0].
>> No point in being too paranoid, I suppose :)
>>
>> Note that after this morning it's not likely that I'll be able to find
>> time to update this again so quickly, so if there are other nits,
>> reviewers can feel free to send their own rerolls rather than waiting
>> for me to see it and turn the patch around.
> 
> Thanks. This version looks good enough to me. Just one minor comment below...
> 
>> diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh
>> @@ -69,6 +69,13 @@ test_expect_success 'incorrect arguments abort with usage' '
>> +test_expect_success 'incorrect positional arguments abort with usage and hint' '
>> +       test_must_fail git bugreport false 2>output &&
>> +       test_i18ngrep usage output &&
>> +       test_i18ngrep false output &&
>> +       test_path_is_missing git-bugreport-*
>> +'
> 
> I didn't really pay attention to the test in earlier rounds so didn't
> notice this, but these days we just use 'grep' rather than
> 'test_i18ngrep'. (Indeed, the existing tests in this script use
> 'grep'.)

It is rather unfortunate that test_i18ngrep was deprecated without providing an alternative that offers the same debugging experience. When test_i18ngrep fails it prints a message with the pattern and text that failed to match so it is easy to see where the test failed. If grep fails there is no output and so unless the test is run with "-x" it can be hard to see which command caused the test to fail.

Best Wishes
Phillip
Previous: Eric SunshineNext: Junio C Hamano
Message 11 of 28 in “git bugreport with invalid CLI argument does not report error”
  1. SheikOct 25, 2023
  2. Emily ShafferOct 25, 2023
  3. Eric SunshineOct 25, 2023
  4. bugreport: reject positional argumentsemilyshaffer@google.com, Oct 26, 2023
  5. Eric SunshineOct 26, 2023
  6. Dragan SimicOct 26, 2023
  7. Eric SunshineOct 26, 2023
  8. Dragan SimicOct 26, 2023
  9. bugreport: reject positional argumentsemilyshaffer@google.com, Oct 26, 2023
  10. Eric SunshineOct 26, 2023
  11. Phillip WoodOct 27, 2023
  12. Junio C HamanoOct 30, 2023
  13. Junio C HamanoOct 30, 2023
  14. Junio C HamanoOct 30, 2023
  15. Junio C HamanoOct 30, 2023
  16. Phillip WoodOct 30, 2023
  17. Junio C HamanoOct 30, 2023
  18. Junio C HamanoOct 31, 2023
  19. 0/2 Deprecate test_i18ngrep furtherJunio C Hamano, Oct 31, 2023
  20. 1/2 test framework: further deprecate test_i18ngrepJunio C Hamano, Oct 31, 2023
  21. 2/2 tests: teach callers of test_i18ngrep to use test_grepJunio C Hamano, Oct 31, 2023
  22. Phillip WoodNov 1, 2023
  23. Junio C HamanoNov 1, 2023
  24. 0/2 bugreport: reject positional argumentsemilyshaffer@google.com, Oct 26, 2023
  25. Eric SunshineOct 26, 2023
  26. 1/2 t0091-bugreport: stop using i18ngrepemilyshaffer@google.com, Oct 26, 2023
  27. Junio C HamanoOct 29, 2023
  28. 2/2 bugreport: reject positional argumentsemilyshaffer@google.com, Oct 26, 2023

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.