git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 1/1] t3301: fix false negative
Date: Tue, 09 Apr 2019 20:33:10 +0900	[thread overview]
Message-ID: <xmqq4l775s7d.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: a01a8c704ba03213aa59c59384dba46502089522.1554806481.git.gitgitgadget@gmail.com

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> In 6956f858f6 (notes: implement helpers needed for note copying during
> rewrite, 2010-03-12), we introduced a test case that verifies that the
> config setting `notes.rewriteRef` can be overridden via the environment
> variable `GIT_NOTES_REWRITE_REF`.
>
> Back when it was introduced, it relied on a side effect of an earlier
> test case that configured `core.noteRef` to point to `refs/notes/other`.
>
> In 908a320363 (t3301: modernize style, 2014-11-12), this side effect was
> removed.
>
> The test case *still* passed, but for the wrong reason: we no longer
> overrode the rewrite ref, but there simply was nothing to rewrite
> anymore, as the overridden notes ref was "modernized" away.

Wow.  Thanks for digging thru this

> Let's let that test case pass for the correct reason again.
>
> To make sure of that, let's change the idea of the original test case:
> it configured `notes.rewriteRef` to point to the actual notes ref,
> forced that to be ignored and then verified that the notes were *not*
> rewritten.
>
> By turning that idea upside down (configure the `notes.rewriteRef` to
> another notes ref, override it via the environment variable to force the
> notes to be copied, and then verify that the notes *were* rewritten), we
> make it much harder for that test case to pass for the wrong reason.

Yup.  I agree that testing positive side, expressing what we want to
happen in a more explicit manner, is always a better alternative.

Will queue.  Thanks.

> index 84bbf88cf9..704bbc6541 100755
> --- a/t/t3301-notes.sh
> +++ b/t/t3301-notes.sh
> @@ -1120,9 +1120,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
>  	test_config notes.rewriteMode overwrite &&
>  	test_config notes.rewriteRef refs/notes/other &&
>  	echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
> -	GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
> +	GIT_NOTES_REWRITE_REF=refs/notes/commits \
> +		git notes copy --for-rewrite=foo &&
>  	git log -1 >actual &&
> -	test_cmp expect actual
> +	grep "replacement note 3" actual
>  '
>  
>  test_expect_success 'git notes copy diagnoses too many or too few parameters' '

      reply	other threads:[~2019-04-09 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 10:41 [PATCH 0/1] Fix a false negative in t3301-notes.sh Johannes Schindelin via GitGitGadget
2019-04-09 10:41 ` [PATCH 1/1] t3301: fix false negative Johannes Schindelin via GitGitGadget
2019-04-09 11:33   ` Junio C Hamano [this message]

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=xmqq4l775s7d.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    /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).