Re: [PATCH v6 03/15] bugreport: add tool to generate debugging info
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 7, 2020, 18:51 UTC
- Message-ID
- <xmqq5zgi44em.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20200207141802.GE2868@szeder.dev>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 34 quoted lines
> On Wed, Feb 05, 2020 at 04:40:56PM -0800, Emily Shaffer wrote:
>> diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh
>> new file mode 100755
>> index 0000000000..451badff0c
>> --- /dev/null
>> +++ b/t/t0091-bugreport.sh
>> @@ -0,0 +1,49 @@
>> +#!/bin/sh
>> +
>> +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 test "$(grep "$HEADER_PATTERN" "$line")"; then
>> + echo "$line"
>> + read -r nextline
>> + if test -z "$nextline"; then
>> + return 1;
>> + fi
>> + fi
>> + done
>> +}
>> +
>> +test_expect_success 'creates a report with content in the right places' '
>> + git bugreport &&
>> + REPORT="$(ls git-bugreport-*)" &&
>
> What if the globbing were to match more than one file?An often-useful pattern is to make the command report the output filename, i.e.
REPORT=$(git butreport) &&
if the design insists that "git bugreport" should allocate a filename in order to make it easy to guarantee uniqueness.
Of course, we can make the invoker supply filename, e.g.
REPORT=$(generate-output-filename) && git bugreport -o "$REPORT" ;# or git bugreport >"$REPORT"