git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Pratyush Yadav <me@yadavpratyush.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: Why does git diff-index show intent-to-add file as "Added"?
Date: Sun, 18 Oct 2020 17:00:57 +0100	[thread overview]
Message-ID: <55ed2ace-5dfd-55f9-d9a6-da71ff795716@gmail.com> (raw)
In-Reply-To: <xmqqimb88v35.fsf@gitster.c.googlers.com>

On 17/10/2020 21:18, Junio C Hamano wrote:
> Pratyush Yadav <me@yadavpratyush.com> writes:
> 
>> In this case, running diff-files gives:
>>
>>    :000000 100644 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 A	foo
> 
> Yes, it says "when comparing the index and the working tree, working
> tree side has it, and the index side does not, so it is an addition".
> 
> Of course, if it is truly a new file that the index does not even
> know about, we'd stay silent, but a path that are marked with i-t-a
> bit is what the user told us to keey an eye on, so that is what you
> would get.
> 
>> Running diff-index gives:
>>
>>    :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A	foo
> 
> If this is "diff-index HEAD", then I think it is expected.  "when
> comparing the HEAD and the working tree, working tree side has it,
> and the tree side does not, so it is an addition."  Exactly the same
> story as "diff-files".
> 
> What should happen in "diff-index --cached HEAD", I offhand do not
> know.  "diff-index --cached HEAD" is a request to compare two trees,
> i.e. the tree that _would_ be produced if you wrote the index out as
> a tree (i.e. "git write-tree") right now, and the tree of HEAD.  So
> I think it may be sensible for the command to behave as if the i-t-a
> path does not even exist in the index when it is run with "--cached";
> I may be missing some subtleties that require us to do something
> different, but that is what I would think.

If a user runs `add -N file` then if they run `git reset -p` (which runs 
`git diff-index --cached HEAD`) it will ask them if they want to remove 
`file` from the index. If `diff-index --cached` hid i-t-a entries we'd 
lose that or have to get the i-t-a entries another way. Having said that 
it does seem strange for `diff-index --cached` to be showing i-t-a 
entries. Perhaps `diff-index --cached` should default to 
--ita-invisible-in-index?

Best Wishes

Phillip


  reply	other threads:[~2020-10-18 16:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-17 16:21 Why does git diff-index show intent-to-add file as "Added"? Pratyush Yadav
2020-10-17 20:18 ` Junio C Hamano
2020-10-18 16:00   ` Phillip Wood [this message]
2020-10-18 20:07     ` Junio C Hamano
2020-10-27 12:09   ` Pratyush Yadav
2020-10-27 20:06     ` 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

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

  git send-email \
    --in-reply-to=55ed2ace-5dfd-55f9-d9a6-da71ff795716@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=me@yadavpratyush.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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).