git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Andy Lowry <andy.work@nglowry.com>
Cc: Jeff King <peff@peff.net>, git <git@vger.kernel.org>
Subject: Re: BUG in git diff-index
Date: Thu, 31 Mar 2016 13:39:02 -0700	[thread overview]
Message-ID: <xmqqwpoil6vt.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <56FD7AE8.4090905@nglowry.com> (Andy Lowry's message of "Thu, 31 Mar 2016 15:30:48 -0400")

Andy Lowry <andy.work@nglowry.com> writes:

> So I think now that the script should do "update-index --refresh"
> followed by "diff-index --quiet HEAD". Sound correct?

Yes.  That has always been one of the kosher ways for any script to
make sure that the files in the working tree that are tracked have
not been modified relative to HEAD (assuming that the index matches
HEAD).  If you are fuzzy about that assumption, you would also do
"diff-index --quiet --cached HEAD" to ensure it, making the whole
thing:

	update-index --refresh
        diff-index --quiet --cached HEAD && diff-index --quiet HEAD

Our scripts traditionally do the equivalent in a slightly different
way.  require_clean_work_tree() in git-sh-setup makes sure that (1)
your working tree files match what is in your index and that (2)
your index matches the HEAD, i.e.

	update-index --refresh
        diff-files --quiet && diff-index --cached --quiet HEAD

They are equivalent in that H==I && H==W (yours) mean H==I==W, while
I==W && H==I (ours) also mean H==I==W.  Two diff-index would require
you to open the tree object of the HEAD twice, so our version may be
more efficient but you probably wouldn't be able to measure the
difference.

  reply	other threads:[~2016-03-31 20:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-31 12:39 BUG in git diff-index Andy Lowry
2016-03-31 13:57 ` Carlos Martín Nieto
2016-03-31 14:05 ` Jeff King
2016-03-31 14:12   ` Andy Lowry
2016-03-31 14:27     ` Jeff King
2016-03-31 19:30       ` Andy Lowry
2016-03-31 20:39         ` Junio C Hamano [this message]
2017-09-26 19:46           ` Marc Herbert
2017-09-26 20:11             ` Eric Wong
2017-09-26 23:27               ` Google indexing https://public-inbox.org/git (was: BUG in git diff-index) Marc Herbert
2017-09-27 21:06             ` Wrong -dirty suffix set by setlocalversion " Marc Herbert
2018-05-24 23:03               ` Mike Mason
2018-05-25  3:50                 ` Marc Herbert

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=xmqqwpoil6vt.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=andy.work@nglowry.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).