Re: Strange diff-index output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]