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

Re: [PATCH] diagnose: require repository

From
Victoria Dye <vdye@github.com>
Date
Oct 19, 2023, 18:16 UTC
Message-ID
<01569dd1-f807-d56d-a123-5e8f3c930503@github.com>
In-Reply-To
<CAN0heSqmZ7QXJbet2Tp=YYCjBLToOHtNy+n=zcf29XYaukYN0w@mail.gmail.com>
Martin Ågren wrote:
Show 28 quoted lines
>>> behavior, it seems more helpful to bail out clearly and early with a
>>> succinct error message.
>>
>> Without having thought things through, offhand I agree with your "no
>> repository?  there is nothing worth tarring up then" assessment.
>>
>> Because "git bugreport --diag" unconditionally spawns "git
>> diagnose", the former may also want to be extra careful, perhaps
>> like the attached patch.
> 
> Good point. TBH, I had no idea about `git bugreport --diagnose`.
> 
>> +       if (!startup_info->have_repository && diagnose != DIAGNOSE_NONE) {
>> +               warning(_("no repository--diagnostic output disabled"));
>> +               diagnose = DIAGNOSE_NONE;
>> +       }
>> +
> 
> When the user explicitly provides that option, it seems unfortunate to
> me to drop it. Yes, we'd warn, but `git bugreport` then pops a text
> editor, so you would only see the warning after finishing up the report.
> (Maybe. By the time you quit your editor, you might not consider
> checking the terminal for warnings and such.)
> 
> So I'm inclined to instead just die if we see the option outside a repo.
> If `diagnose` the command fundamentally requires a repo (as with my
> patch) it seems surprising to me to not have `--diagnose` the option
> behave the same.

I agree - it was an oversight on my part to not firmly require the existence of a repository with 'git diagnose', and the same applies to 'bugreport --diagnose'.

For reference, there is one other usage of 'git diagnose' (in 'scalar diagnose'). However, it's already guarded by 'setup_git_directory()' so it shouldn't need to be updated.

> 
> Martin
Previous: Junio C HamanoNext: Christian Couder
Message 7 of 8 in “Bug: git diagnose crashes with Segmentation fault outside of git repository”
  1. ks1322 ks1322Oct 14, 2023
  2. diagnose: require repositoryMartin Ågren, Oct 14, 2023
  3. Kristoffer HaugsbakkOct 14, 2023
  4. Junio C HamanoOct 14, 2023
  5. Martin ÅgrenOct 19, 2023
  6. Junio C HamanoOct 19, 2023
  7. Victoria DyeOct 19, 2023
  8. Christian CouderOct 14, 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.