git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: "Lindeke, Cord" <Cord.Lindeke@softwareag.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git diff-index considers touched files as dirty and changes behaviour
Date: Thu, 22 Sep 2022 16:20:11 +0100	[thread overview]
Message-ID: <9501804c-4b34-0c46-b75c-5b2eb23386b3@dunelm.org.uk> (raw)
In-Reply-To: <BEZP281MB25194116180654CE60001F6CEC4E9@BEZP281MB2519.DEUP281.PROD.OUTLOOK.COM>

Hi Cord

On 22/09/2022 15:11, Lindeke, Cord wrote:
> What did you do before the bug happened? (Steps to reproduce your issue)
>> touch README.md
>> git diff-index --exit-code HEAD
> :100644 100644 64c1efecd5716f56155b806caaf9fa6a771fae47 0000000000000000000000000000000000000000 M      README.md
>> echo $?
> 1
>> git status
> On branch master
> Your branch is up to date with 'origin/master'.
> 
> nothing to commit, working tree clean
>> git diff-index --exit-code HEAD
>> echo $?
> 0
> 
> What did you expect to happen? (Expected behavior)
> The first "git diff-index" should not detect any differences, but return 0 instead.
> 
> What happened instead? (Actual behavior)
> The first "git diff-index" considers the touched README.md as dirty and returns 1.
> Somehow, calling "git status" fixes this behaviour so that the second "git diff-index" behaves as expected.
> 
> What's different between what you expected and what actually happened?
> The result of the first "git diff-index" should have been 0.
> And the behaviour should not alter at all with calling any other git commands like "git status" or "git diff" in between.

It is working as expected. diff-files and diff-index are "plumbing" 
commands designed for use in scripts and require the index to be 
refreshed with "git update-index --refresh" before they are called. "git 
diff" and "git status" are "porcelain" commands designed for users and 
refresh the index as the first step.

Best Wishes

Phillip


> Anything else you want to add:
> The same issue holds true for "git diff-files".
> 
> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.
> 
> 
> [System Info]
> git version:
> git version 2.37.3
> cpu: x86_64
> no commit associated with this build
> sizeof-long: 8
> sizeof-size_t: 8
> shell-path: /bin/sh
> uname: Linux 4.15.0-193-generic #204-Ubuntu SMP Fri Aug 26 19:20:21 UTC 2022 x86_64
> compiler info: gnuc: 7.5
> libc info: glibc: 2.27
> $SHELL (typically, interactive shell): /bin/bash
> 
> 
> [Enabled Hooks]
> 
> Best regards
> Cord Lindeke
> Sr. Software Specialist
> cord.lindeke@softwareag.com
> Software AG, Uhlandstrasse 12, 64297 Darmstadt, Germany
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Sanjay Brahmawar (Vorsitzender/Chairman), Dr. Elke Frank, Dr. Matthias Heiden, Dr. Stefan Sigg, Dr. Benno Quade, Joshua Husk - Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Christian Lucas - https://www.softwareag.com

      reply	other threads:[~2022-09-22 15:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 14:11 git diff-index considers touched files as dirty and changes behaviour Lindeke, Cord
2022-09-22 15:20 ` Phillip Wood [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=9501804c-4b34-0c46-b75c-5b2eb23386b3@dunelm.org.uk \
    --to=phillip.wood123@gmail.com \
    --cc=Cord.Lindeke@softwareag.com \
    --cc=git@vger.kernel.org \
    --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.
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).