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: Fri, 19 Jun 2020 14:43:46 -0700 [thread overview]
Message-ID: <xmqqftaqg299.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200619093127.GA47528@mail.clickyotomy.dev> (Srinidhi Kaushik's message of "Fri, 19 Jun 2020 15:01:27 +0530")
Srinidhi Kaushik <shrinidhi.kaushik@gmail.com> writes:
>> > + 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?
>
> I'm not sure if we want to repeat an older test. The test (which was
> renamed in this patch) in t2203-add-intent.sh: "diff/diff-cached shows
> ita as new/not-new files" is already doing that. Should the "diff" and
> "diff --cached" steps be appended here again?
No, there is no need to repeat essentially the same test that exists
elsewhere. I wonder if it reduces duplication even further if we
extend that existing test that checks "diff" and "diff --cached" so
that it also checks "diff-files" as well?, instead of adding this
new one? The existing one checks diff and diff-cached only with a
new non-empty path, and it can use tests with a new empty path at
the same time, with a unified "set up" code that is in the early
part of the test, e.g.
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 5bbe8dcce4..cfde790ac7 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -235,7 +235,8 @@ test_expect_success 'double rename detection in status' '
test_expect_success 'diff-files/diff-cached shows ita as new/not-new files' '
git reset --hard &&
echo new >new-ita &&
- git add -N new-ita &&
+ : >new-ita-empty &&
+ git add -N new-ita new-ita-empty &&
git diff --summary >actual &&
...
Then the existing tests can be updated to see not just --summary but
also for the contents like you did in the new test---and another test
that examines what "git diff-files" sees (which is what you added)
can happen in the same test (that way, the same set-up can be reused
for three tests).
Thanks.
next prev parent reply other threads:[~2020-06-19 21:43 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
2020-06-18 22:40 ` Junio C Hamano
2020-06-19 9:31 ` Srinidhi Kaushik
2020-06-19 21:43 ` Junio C Hamano [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqftaqg299.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.
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).