git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Oussama Ghorbel <oussama.ghorbel@iopsys.eu>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: strange behavior of git diff-index
Date: Wed, 22 May 2019 15:27:53 +0000	[thread overview]
Message-ID: <1b86251f-1b64-dfdf-7e40-e8a0c1e42e55@iopsys.eu> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.1905221651270.46@tvgsbejvaqbjf.bet>

Hi Johannes,

Thanks a lot for the clarification!

Regards,
Oussama
On 5/22/19 4:54 PM, Johannes Schindelin wrote:
> Hi Oussama,
>
> On Wed, 22 May 2019, Oussama Ghorbel wrote:
>
>> git diff-index is giving me incorrect information, however if I run git diff, then git diff-index again it will show the correct information.
>> The steps are the following:
>> $ git diff-index --name-only HEAD
>> git appears to list all files in the project irrespective if they modified or not
>> $ git diff
>> $ git diff --cached
>> will show nothing. So I don't have any modification.
>> Now strangely if I run git diff-index, it will also show nothing which is correction behavior.
>>
>> my git version is 2.7.4
>> Any explanation?
> The low-level `diff-index` command is meant to be used in scripts, and
> does specifically *not* refresh the index before running. Meaning that it
> could possibly mistake a file for being modified even if it is not
> modified, just because it is marked "modified" in the index [*1*].
>
> Short answer: use the high-level command `git diff` that is intended for
> human consumption.
>
> Ciao,
> Johannes
>
> Footnote *1*: It is actually a bit more complicated than that: the index
> stores metadata such as mtime, size, uid, etc, and compares that to the
> metadata on disk. If there is any mismatch, or if everything matches but
> the mtime *also* matches the index file's itself, the file is considered
> not up to date, i.e. marked as modified.

      reply	other threads:[~2019-05-22 15:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 10:00 strange behavior of git diff-index Oussama Ghorbel
2019-05-22 14:54 ` Johannes Schindelin
2019-05-22 15:27   ` Oussama Ghorbel [this message]

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=1b86251f-1b64-dfdf-7e40-e8a0c1e42e55@iopsys.eu \
    --to=oussama.ghorbel@iopsys.eu \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /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).