All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Ch'Gans <chgans@gna.org>
Cc: David Turner <dturner@twopensource.com>, git@vger.kernel.org
Subject: Re: Strange diff-index output
Date: Wed, 4 Nov 2015 01:38:04 -0500	[thread overview]
Message-ID: <20151104063803.GA16605@sigill.intra.peff.net> (raw)
In-Reply-To: <CABxGUTihNmHqp-RovCVreTRqoK_sj+KCjRQE_YOVZ8OQzOHHoA@mail.gmail.com>

On Tue, Nov 03, 2015 at 02:00:33PM +1300, Ch'Gans wrote:

> I first tried "git update-index" but it didn't work. However "git
> update-index --refresh" seems to fix our problem.
> I didn't get why "--refresh" is needed thought, I'm really not
> familiar with the caching aspect of git.

It is because update-index is a general command for manipulating the
index. For example, you can add, delete, or change entries without
regard to what is in the working tree.

One of the manipulations is "refresh the index based on what is in the
working tree", and that is spelled "--refresh". Most porcelain-level git
commands (like "git diff") will do this for you automatically and
transparently. But when using the scriptable plumbing (like diff-index),
git gives you more control. This lets you do things more efficiently
(e.g,. you might refresh once and then issue several low-level
commands), at the cost of convenience.

You could also have used "git diff-index --cached HEAD", which instructs
diff-index not to look at the working tree at all (so you would compare
whatever is in the index, whether it is up to date with what is in the
working tree or not). Depending on what you are trying to achieve, that
might be fine (it's also more efficient in general, as it does not
require an lstat() of every file in the working tree).

-Peff

      reply	other threads:[~2015-11-04  6:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 23:59 Strange diff-index output Ch'Gans
2015-11-03  0:27 ` David Turner
2015-11-03  1:00   ` Ch'Gans
2015-11-04  6:38     ` Jeff King [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

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

  git send-email \
    --in-reply-to=20151104063803.GA16605@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=chgans@gna.org \
    --cc=dturner@twopensource.com \
    --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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.