git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: 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: Sat, 17 Oct 2020 13:18:38 -0700	[thread overview]
Message-ID: <xmqqimb88v35.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20201017162111.gvisfz2daqvhnjmb@yadavpratyush.com> (Pratyush Yadav's message of "Sat, 17 Oct 2020 21:51:11 +0530")

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.



  reply	other threads:[~2020-10-17 20:19 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 [this message]
2020-10-18 16:00   ` Phillip Wood
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

  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=xmqqimb88v35.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=me@yadavpratyush.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).