git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Charles Bailey <charles@hashpling.org>
Cc: git@vger.kernel.org, "Eric Sunshine" <sunshine@sunshineco.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: [PATCH v3 3/3] grep: fix grepping for "intent to add" files
Date: Fri, 01 Jul 2016 13:34:06 -0700	[thread overview]
Message-ID: <xmqqpoqxw11d.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160630101348.15665-4-charles@hashpling.org> (Charles Bailey's message of "Thu, 30 Jun 2016 11:13:48 +0100")

Charles Bailey <charles@hashpling.org> writes:

> +test_expect_success 'grep can find things only in the work tree' '
> +	: >work-tree-only &&
> +	git add work-tree-only &&
> +	test_when_finished "git rm -f work-tree-only" &&

It is better to have the test_when_finished before "git add", and
possibly before the creation of the test file.

It is not worth a reroll and it is perfectly fine to leave it as a
low-hanging-fruit for later clean-up material, because this test is
not about catchign a "git add" that suddenly starts failing in a
strange way (e.g. adds to the index but exits with non-zero).

Same comment for the use of test_when_finished in the remainder of
the patch.

Thanks.

> +	echo "find in work tree" >work-tree-only &&
> +	git grep --quiet "find in work tree" &&
> +	test_must_fail git grep --quiet --cached "find in work tree" &&
> +	test_must_fail git grep --quiet "find in work tree" HEAD
> +'
> +
> +test_expect_success 'grep can find things only in the work tree (i-t-a)' '
> +	echo "intend to add this" >intend-to-add &&
> +	git add -N intend-to-add &&
> +	test_when_finished "git rm -f intend-to-add" &&
> +	git grep --quiet "intend to add this" &&
> +	test_must_fail git grep --quiet --cached "intend to add this" &&
> +	test_must_fail git grep --quiet "intend to add this" HEAD
> +'
> +
> +test_expect_success 'grep does not search work tree with assume unchanged' '
> +	echo "intend to add this" >intend-to-add &&
> +	git add -N intend-to-add &&
> +	git update-index --assume-unchanged intend-to-add &&
> +	test_when_finished "git rm -f intend-to-add" &&
> +	test_must_fail git grep --quiet "intend to add this" &&
> +	test_must_fail git grep --quiet --cached "intend to add this" &&
> +	test_must_fail git grep --quiet "intend to add this" HEAD
> +'
> +
> +test_expect_success 'grep can find things only in the index' '
> +	echo "only in the index" >cache-this &&
> +	git add cache-this &&
> +	rm cache-this &&
> +	test_when_finished "git rm --cached cache-this" &&
> +	test_must_fail git grep --quiet "only in the index" &&
> +	git grep --quiet --cached "only in the index" &&
> +	test_must_fail git grep --quiet "only in the index" HEAD
> +'
> +
> +test_expect_success 'grep does not report i-t-a with -L --cached' '
> +	echo "intend to add this" >intend-to-add &&
> +	git add -N intend-to-add &&
> +	test_when_finished "git rm -f intend-to-add" &&
> +	git ls-files | grep -v "^intend-to-add\$" >expected &&
> +	git grep -L --cached "nonexistent_string" >actual &&
> +	test_cmp expected actual
> +'
> +
> +test_expect_success 'grep does not report i-t-a and assume unchanged with -L' '
> +	echo "intend to add this" >intend-to-add-assume-unchanged &&
> +	git add -N intend-to-add-assume-unchanged &&
> +	test_when_finished "git rm -f intend-to-add-assume-unchanged" &&
> +	git update-index --assume-unchanged intend-to-add-assume-unchanged &&
> +	git ls-files | grep -v "^intend-to-add-assume-unchanged\$" >expected &&
> +	git grep -L "nonexistent_string" >actual &&
> +	test_cmp expected actual
> +'
> +
>  test_done

  reply	other threads:[~2016-07-01 20:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30 10:13 [PATCH v3 0/3] Grepping with intent to add Charles Bailey
2016-06-30 10:13 ` [PATCH v3 1/3] t7810-grep.sh: fix duplicated test name Charles Bailey
2016-07-01 20:27   ` Junio C Hamano
2016-06-30 10:13 ` [PATCH v3 2/3] t7810-grep.sh: fix a whitespace inconsistency Charles Bailey
2016-06-30 10:13 ` [PATCH v3 3/3] grep: fix grepping for "intent to add" files Charles Bailey
2016-07-01 20:34   ` Junio C Hamano [this message]
2016-07-01 20:26 ` [PATCH v3 0/3] Grepping with intent to add 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqpoqxw11d.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=charles@hashpling.org \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=sunshine@sunshineco.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).