mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <>
To: "Simon Gerber via GitGitGadget" <>
Cc:, Simon Gerber <>
Subject: Re: [PATCH 1/2] tests: add test case for autocorrect in work tree for bare clone
Date: Fri, 28 Oct 2022 12:28:41 -0700	[thread overview]
Message-ID: <xmqq4jvniw7q.fsf@gitster.g> (raw)
In-Reply-To: <> (Simon Gerber via GitGitGadget's message of "Fri, 28 Oct 2022 15:24:04 +0000")

"Simon Gerber via GitGitGadget" <> writes:

>  t/ | 29 ++++++++++++++++++++++++++++

Don't we have existing test script for auto-correction?  Is it
sensible to waste a new fail for this single test?  I doubt it.

Perhaps appending after 9003 a new test instead?

> diff --git a/t/ b/t/
> new file mode 100755
> index 00000000000..4fecc8a8e01
> --- /dev/null
> +++ b/t/
> @@ -0,0 +1,29 @@
> +#!/bin/sh
> +
> +test_description='test autocorrect in work tree based on bare repository'
> +. ./
> +
> +test_expect_success 'setup non-bare' '
> +	echo one >file &&
> +	git add file &&
> +	git commit -m one &&
> +	echo two >file &&
> +	git commit -a -m two
> +'

Wouldn't "test_commit" be simpler to use than rolling our own here?
If we piggy-back on set-up in an existing test script, there
probably is already a history the single test to attempt running
'git staut' can use.  After all, that test does not care an iota
what is in the history.

> +
> +test_expect_success 'setup bare' '
> +	git clone --bare . bare.git &&
> +	cd bare.git

Do not chdir around in a test script, especially in separate steps.

> +'
> +
> +test_expect_success 'setup worktree from bare' '
> +	git worktree add ../bare-wt &&
> +	cd ../bare-wt
> +'


Either do it in a subshell in a single step, or

		git clone --bare . bare.git &&
		cd bare.git &&
		git worktree add ../worktree &&
		cd ../worktree &&
		git -c help.autocorrect=immediate staut

use "git -C <over-there>" form, e.g.

	git clone --bare . bare.git &&
	git -C bare.git worktree add ../worktree &&
	git -C worktree -c help.autocorrect=immediate staut

> +test_expect_success 'autocorrect works in work tree created from bare repo' '

When patch 1/2 is applied without 2/2, this test_expect_success will
not be satisfied, breaking future bisection.

For a small change like this, have the code change *and* test that
verifies the new behaviour in a single step.  That way

 * you do not break bisection.

 * if somebody wants to cherry-pick the fix to an older maintenance
   tracks, they can do so by picking a single unit, fix and
   verification combined together.

 * acceptance or review can be done by checking the end-result and
   then tentatively reverting only the code change with something

	$ git show -- ':!t/' | git apply -R

   and see the test that expects success actually fails without the fix.

  reply	other threads:[~2022-10-28 19:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 15:24 [PATCH 0/2] Fix autocorrect in work tree for bare repository Simon Gerber via GitGitGadget
2022-10-28 15:24 ` [PATCH 1/2] tests: add test case for autocorrect in work tree for bare clone Simon Gerber via GitGitGadget
2022-10-28 19:28   ` Junio C Hamano [this message]
2022-10-29  8:07     ` Simon Gerber
2022-10-28 15:24 ` [PATCH 2/2] help.c: don't call git_default_config in git_unknown_cmd_config Simon Gerber via GitGitGadget
2022-10-29 19:56 ` [PATCH v2] help.c: fix autocorrect in work tree for bare repository Simon Gerber via GitGitGadget
2022-12-12 16:38   ` Simon Gerber
2022-12-13  1:37   ` Junio C Hamano
2022-12-13  9:48     ` Simon Gerber

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:

  List information:

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

  git send-email \
    --in-reply-to=xmqq4jvniw7q.fsf@gitster.g \ \ \ \ \

* 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.
Code repositories for project(s) associated with this public inbox

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 read-only IMAP folder(s) and NNTP newsgroup(s).