git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Srinidhi Kaushik <shrinidhi.kaushik@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] diff-files: treat "i-t-a" files as "not-in-index"
Date: Thu, 18 Jun 2020 15:33:11 -0700	[thread overview]
Message-ID: <xmqqk104knrs.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200611161640.52156-1-shrinidhi.kaushik@gmail.com> (Srinidhi Kaushik's message of "Thu, 11 Jun 2020 21:46:40 +0530")

Srinidhi Kaushik <shrinidhi.kaushik@gmail.com> writes:

> -test_expect_success 'diff-files/diff-cached shows ita as new/not-new files' '
> +test_expect_success 'diff/diff-cached shows ita as new/not-new files' '
>  	git reset --hard &&
>  	echo new >new-ita &&
>  	git add -N new-ita &&

Interesting.  

I thought that the test originally tested "diff-files" and
"diff-index --cached" and a modernization patch forgot to update the
title when the test body was changed to use "diff" and "diff
--cached", but that is not the case here.  When 0231ae71 (diff: turn
--ita-invisible-in-index on by default, 2018-05-26) added this test,
it gave a wrong title from the beginning.

Nice catch.

> @@ -243,6 +243,29 @@ test_expect_success 'diff-files/diff-cached shows ita as new/not-new files' '
>  	test_must_be_empty actual2
>  '
>  
> +test_expect_success 'diff-files shows i-t-a files as new files' '
> +	git reset --hard &&
> +	touch empty &&

Use of "touch" gives a wrong impression that you care about the file
timestamp; use something like ": >empty &&" instead when you care
about the presence of the file and do not care about its timestamp.

> +	content="foo" &&
> +	echo $content >not-empty &&

The quoting decision is backwards in these two lines.  It is OK not
to quote when the right hand side literal is clearly a single word
without $IFS.  On the other hand, it is a good practice to always
quote when using what is in a "$variable".

> +	git add -N empty not-empty &&
> +	git diff-files -p >actual &&
> +	hash_e=$(git hash-object empty) &&
> +	hash_n=$(git hash-object not-empty) &&
> +	cat >expect <<-EOF &&
> +	diff --git a/empty b/empty
> +	new file mode 100644
> +	index 0000000..$(git rev-parse --short $hash_e)
> +	diff --git a/not-empty b/not-empty
> +	new file mode 100644
> +	index 0000000..$(git rev-parse --short $hash_n)
> +	--- /dev/null
> +	+++ b/not-empty
> +	@@ -0,0 +1 @@
> +	+$content
> +	EOF
> +	test_cmp expect actual
> +'

OK.  Do we want to show what happens when "diff" and "diff --cached"
are run with these two "added but not quite added yet" paths to
contrast with this new case?

Thanks.

  parent reply	other threads:[~2020-06-18 22:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 16:16 [PATCH] diff-files: treat "i-t-a" files as "not-in-index" Srinidhi Kaushik
2020-06-11 20:27 ` Junio C Hamano
2020-06-11 23:28   ` Srinidhi Kaushik
2020-06-18 17:58     ` Srinidhi Kaushik
2020-06-18 22:33       ` Junio C Hamano
2020-06-18 22:33 ` Junio C Hamano [this message]
2020-06-18 22:40   ` Junio C Hamano
2020-06-19  9:31     ` Srinidhi Kaushik
2020-06-19 21:43       ` Junio C Hamano
2020-06-20 16:38 ` [PATCH v2] " Srinidhi Kaushik
2020-06-20 16:54   ` Junio C Hamano
2020-06-23 15:17   ` Johannes Schindelin

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=xmqqk104knrs.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=shrinidhi.kaushik@gmail.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).