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

Re: [PATCH] bugreport: add tool to generate debugging info

From
Emily Shaffer <emilyshaffer@google.com>
Date
Aug 15, 2019, 21:52 UTC
Message-ID
<20190815215225.GB208753@google.com>
In-Reply-To
<xmqqzhka2tbv.fsf@gitster-ct.c.googlers.com>
On Thu, Aug 15, 2019 at 11:10:12AM -0700, Junio C Hamano wrote:
Show 37 quoted lines
> Emily Shaffer <emilyshaffer@google.com> writes:
> 
> > diff --git a/Documentation/git-bugreport.txt b/Documentation/git-bugreport.txt
> > new file mode 100644
> > index 0000000000..c5f45bbee8
> > --- /dev/null
> > +++ b/Documentation/git-bugreport.txt
> > @@ -0,0 +1,48 @@
> > +git-bugreport(1)
> > +================
> > +
> > +NAME
> > +----
> > +git-bugreport - Collect information for user to file a bug report
> > +
> > +SYNOPSIS
> > +--------
> > +[verse]
> > +'git bugreport' [-o | --output <path>]
> > +
> > +DESCRIPTION
> > +-----------
> > +Captures information about the user's machine, Git client, and repository state,
> > +as well as a form requesting information about the behavior the user observed,
> > +into a single text file which the user can then share, for example to the Git
> > +mailing list, in order to report an observed bug.
> > +
> > +The following information is requested from the user:
> > +
> > + - Reproduction steps
> > + - Expected behavior
> > + - Actual behavior
> 
> + - How the above two are different
> 
> It is often helpful to have users explain how the expected and
> actual are different in their own words.
Good point; added.
Show 6 quoted lines
> 
> > +NOTE
> > +----
> > +Bug reports can be sent to git@vger.kernel.org.
> 
> I am not sure if this belongs here.

Sure, I wasn't certain either. Would you rather I remove the "what to do with this bugreport" NOTE section entirely? I worry that folks will think this generated text file is being magically reported behind the scenes, or that they won't know what to do with the file now that it's created.

I suppose I did mention in the DESCRIPTION section that the user can share the generated text file to report a bug. Maybe I should remove "for example to the Git ML" from there as well.

Show 31 quoted lines
> 
> > diff --git a/git-bugreport.sh b/git-bugreport.sh
> > new file mode 100755
> > index 0000000000..2200703a51
> > --- /dev/null
> > +++ b/git-bugreport.sh
> > @@ -0,0 +1,86 @@
> > +#!/bin/sh
> > +
> > +print_filenames_and_content() {
> > +while read -r line; do
> > +	echo "$line";
> > +	echo "========";
> > +	cat "$line";
> > +	echo;
> > +done
> > +}
> 
> Style.
> 
>  - have SP on both sides of ()
>  - one more HT indent for the function body
>  - "do" on its own line
>  - no unnecessary semicolons when LF would do
> 
> You probably are better off asking xargs to do this instead of
> relying on "read -r".
> 
> 	find ... | xargs -n 1 sh -c 'echo "$1" && cat "$1"' -
> 
> or something like that, perhaps.

Hm. In responding to Stolee's comments, I ended up replacing "cat $line" with another function, and it seems xargs isn't happy directing to functions which haven't been exported, because it spins a new process for each argument it's passed. I had originally intended to do this with xargs but then didn't want to pack many lines into one xargs call.

The way the code is in PS1 I think it's a reasonable replacement, but the code in PS2 is less so - there's a check for whether a file given is binary or whether it exists at all (the former for hooks, which I think you were worried about, and the latter for the alternates file, which I found I do not have.)

Why is "read -r" unreliable? Is it better to export a function and use xargs, compared to using "read -r" in a loop like this? I was worried that exporting a function is similar to namespace pollution in C++, but maybe I'm mistaken.

Show 24 quoted lines
> 
> > +
> > +generate_report_text() {
> > +
> > +	# Generate a form for the user to fill out with their issue.
> > +	gettextln "Thank you for filling out a Git bug report!"
> > +	gettextln "Please answer the following questions to help us understand your issue."
> > +	echo
> > +	gettextln "What did you do before the bug happened? (Steps to reproduce your issue)"
> > +	echo
> > +	gettextln "What did you expect to happen? (Expected behavior)"
> > +	echo
> > +	gettextln "What happened instead? (Actual behavior)"
> > +	echo
> > +	gettextln "Anything else you want to add:"
> > +	echo
> > +	gettextln "Please review the rest of the bug report below."
> > +	gettextln "You can delete any lines you don't wish to send."
> > +	echo
> 
> Would we on the receiving end be able to tell these section headers
> in translated to 47 different languages?  I am sure that i18n is
> used here to encourage non-C-locale users to file bugs in their own
> languages, but are we prepared to react to them?

I hope that we could accept reports in many languages with online translation as a guide, but practically speaking, machine-learning-powered online translation may not be as good for technical topics as it is for conversational.

At the same time, it seems unnecessarily restrictive to ask for bugs to come in English. My heart thinks it's better to encourage other languages too.

Show 13 quoted lines
> 
> > +	echo "[System Information]"
> > +	git version --build-options
> > +	uname -a
> > +	curl-config --version
> > +	ldd --version
> 
> "curl-config: command not found" may be clear enough, but would
> there be a case where errors from two or more consecutive commands
> in the above sequence would make the output confusing to the person
> sitting on the receiving end?  Would it help, as a convention, to
> always ahve "echo [what am I reporting]" before each of these
> commands?
Yeah, I think that's a good point.

In responding to Stolee's review, I mentioned adding additional context to some command's output so that "those reviewing the report don't need to be intimately familiar with what the bugreport script runs". But it might actually be most useful to echo the command that's being run everywhere.

I imagine it's fine to include the [] header as well, to make it easier for the user to understand what was generated.

Show 5 quoted lines
> 
> > +# Create bugreport file
> > +BUGREPORT_FILE="$basedir/git-bugreport-$(whoami)-$(hostname)-$(date -Iminutes)"
> 
> How portable is -Iminutes?

Ah, it seems while it works in MingW and bash, it doesn't work in zsh. I'll figure something else out. Thanks.

Show 10 quoted lines
> 
> > diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh
> > new file mode 100755
> > index 0000000000..6eb2ee4f66
> > --- /dev/null
> > +++ b/t/t0091-bugreport.sh
> > @@ -0,0 +1,41 @@
> > +#!/bin/bash
> 
> Make sure /bin/sh suffices to run the test script.
Will do. Thanks.
Show 21 quoted lines
> 
> > +test_description='git bugreport'
> > +
> > +. ./test-lib.sh
> > +
> > +# Headers "[System Info]" will be followed by a non-empty line if we put some
> > +# information there; we can make sure all our headers were followed by some
> > +# information to check if the command was successful.
> > +HEADER_PATTERN="^\[.*\]$"
> > +check_all_headers_populated() {
> > +	while read -r line; do
> > +		if [$(grep $HEADER_PATTERN $line)]; then
> 
> Documentation/CodingGuidelines
> 
> I am not sure if the traits this test script checks about the
> contents of the output is all that interesting.  Whenever we add new
> sections to the main command because we want other kinds of
> information collected, we'd update this test script because
> otherwise the test would fail, but would it result in quality
> bugreport tool, or is it just additional busywork?

I'm a little confused about this - I checked for a general [...] header standing alone on a line specifically so that we wouldn't need to update the test script when adding a new section. What do you see that will grow stale?

Show 5 quoted lines
> 
> If we decide later that a header and its body needs to be separated
> with a blank line for better readablity, the check done here would
> also need to be updated, but again, that does not feel like anything
> more than just busywork to me.
Sure, I agree with that.

So, what's your suggestion? Not to check the output at all? (This may actually be fine; it occurred to me while reading your review that if a user is filing a bug report about something, one of the diagnostic commands in bugreport might be what's broken for them. So perhaps it should be tolerant to missing information...)

> 
> The tests for "-o" and unknown options do make sense, though.
> 
> Thanks.
Thanks for reviewing.
 - Emily
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 of 68 in “bugreport: add tool to generate debugging info”
  1. bugreport: add tool to generate debugging infoEmily Shaffer, Aug 15, 2019
  2. Derrick StoleeAug 15, 2019
  3. Junio C HamanoAug 15, 2019
  4. Emily ShafferAug 15, 2019
  5. Junio C HamanoAug 15, 2019
  6. Emily ShafferAug 16, 2019
  7. Junio C HamanoAug 16, 2019
  8. Emily ShafferAug 16, 2019
  9. Johannes SchindelinAug 15, 2019
  10. Emily ShafferAug 15, 2019
  11. Johannes SchindelinAug 16, 2019
  12. Emily ShafferAug 15, 2019
  13. Junio C HamanoAug 15, 2019
  14. Emily ShafferAug 15, 2019
  15. Junio C HamanoAug 15, 2019
  16. Emily ShafferAug 15, 2019
  17. 0/2 add git-bugreport toolEmily Shaffer, Aug 17, 2019
  18. 2/2 bugreport: generate config whitelist based on docsEmily Shaffer, Aug 17, 2019
  19. Martin ÅgrenAug 17, 2019
  20. Emily ShafferAug 21, 2019
  21. 1/2 bugreport: add tool to generate debugging infoEmily Shaffer, Aug 17, 2019
  22. 0/9 add git-bugreport toolEmily Shaffer, Oct 25, 2019
  23. 1/9 bugreport: add tool to generate debugging infoEmily Shaffer, Oct 25, 2019
  24. Josh SteadmonOct 29, 2019
  25. Junio C HamanoNov 16, 2019
  26. Emily ShafferNov 19, 2019
  27. Johannes SchindelinNov 19, 2019
  28. Junio C HamanoNov 20, 2019
  29. Johannes SchindelinNov 20, 2019
  30. Johannes SchindelinNov 19, 2019
  31. Junio C HamanoNov 20, 2019
  32. Emily ShafferNov 20, 2019
  33. Junio C HamanoNov 20, 2019
  34. 2/9 bugreport: generate config whitelist based on docsEmily Shaffer, Oct 25, 2019
  35. Johannes SchindelinOct 28, 2019
  36. 3/9 bugreport: add version and system informationEmily Shaffer, Oct 25, 2019
  37. Johannes SchindelinOct 28, 2019
  38. Emily ShafferNov 8, 2019
  39. Johannes SchindelinNov 11, 2019
  40. Emily ShafferNov 14, 2019
  41. Josh SteadmonOct 29, 2019
  42. 4/9 bugreport: add config values from whitelistEmily Shaffer, Oct 25, 2019
  43. Johannes SchindelinOct 28, 2019
  44. Emily ShafferDec 11, 2019
  45. Johannes SchindelinDec 15, 2019
  46. Josh SteadmonOct 29, 2019
  47. Junio C HamanoOct 30, 2019
  48. Emily ShafferNov 14, 2019
  49. 5/9 bugreport: collect list of populated hooksEmily Shaffer, Oct 25, 2019
  50. Johannes SchindelinOct 28, 2019
  51. Emily ShafferDec 11, 2019
  52. Johannes SchindelinDec 15, 2019
  53. 6/9 bugreport: count loose objectsEmily Shaffer, Oct 25, 2019
  54. Johannes SchindelinOct 28, 2019
  55. Emily ShafferDec 10, 2019
  56. Josh SteadmonOct 29, 2019
  57. 7/9 bugreport: add packed object summaryEmily Shaffer, Oct 25, 2019
  58. Johannes SchindelinOct 28, 2019
  59. Emily ShafferDec 11, 2019
  60. Johannes SchindelinDec 11, 2019
  61. Emily ShafferDec 11, 2019
  62. 8/9 bugreport: list contents of $OBJDIR/infoEmily Shaffer, Oct 25, 2019
  63. Johannes SchindelinOct 28, 2019
  64. 9/9 bugreport: print contents of alternates fileEmily Shaffer, Oct 25, 2019
  65. Johannes SchindelinOct 28, 2019
  66. Emily ShafferNov 19, 2019
  67. Junio C HamanoOct 29, 2019
  68. Johannes SchindelinOct 29, 2019

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.