git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Ilya K <me@0upti.me>
Subject: Re: [PATCH] hook API: don't segfault on strbuf_addf() to NULL "out"
Date: Fri, 05 Aug 2022 17:51:17 +0200	[thread overview]
Message-ID: <220805.86v8r6r8in.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <Yu08MCCoGwTxeM+g@danh.dev>


On Fri, Aug 05 2022, Đoàn Trần Công Danh wrote:

> On 2022-08-05 16:15:33+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> [...]
>> +test_expect_success 'git hook run a hook with a bad shebang' '
>> +	test_when_finished "rm -rf bad-hooks" &&
>> +	mkdir bad-hooks &&
>> +	write_script bad-hooks/test-hook "/bad/path/no/spaces" </dev/null &&
>> +
>> +	# TODO: We should emit the same (or at least a more similar)
>> +	# error on Windows and !Windows. See the OS-specific code in
>> +	# start_command()
>> +	if test_have_prereq !WINDOWS
>> +	then
>> +		cat >expect <<-\EOF
>> +		fatal: cannot run bad-hooks/test-hook: ...
>> +		EOF
>> +	else
>> +		cat >expect <<-\EOF
>> +		error: cannot spawn bad-hooks/test-hook: ...
>> +		EOF
>> +	fi &&
>> +	test_expect_code 1 git \
>> +		-c core.hooksPath=bad-hooks \
>> +		hook run test-hook >out 2>err &&
>> +	test_must_be_empty out &&
>> +	sed -e "s/test-hook: .*/test-hook: .../" <err >actual &&
>
> If we're using "sed" here, can we also s/cannot run/cannot spawn/
> in order to have the same expectation?
>
> Otherwise, the fix looks sane to me (obviously, since I also suggest
> removing the line entirely).

We could, but then we'd miss some weird regression where we changed the
non-Windows message to "fatal: cannot spawn", which neither emit now.

We could of course do the "sed"-ing in an identical "test_have_prereq"
block, but I think we'd just be back to square one then, and it would be
more readable to just "cat" what we expect to happen there.

So I think I'd prefer to keep it as-is, it also makes a subsequent
change where we unify these error messages more obvious, i.e. we'd keep
the !WINDOWS branch of that if/else in thath case.

> Reviewed-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>

Thanks!

  reply	other threads:[~2022-08-05 15:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0015309-00f1-9b44-023c-001ee3f242e4@0upti.me>
2022-08-05 14:15 ` [PATCH] hook API: don't segfault on strbuf_addf() to NULL "out" Ævar Arnfjörð Bjarmason
2022-08-05 15:50   ` Đoàn Trần Công Danh
2022-08-05 15:51     ` Ævar Arnfjörð Bjarmason [this message]
2022-08-05 21:09   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=220805.86v8r6r8in.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=congdanhqx@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@0upti.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).