Re: Determining if a tree is clean

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

 



Adam Mercer <ramercer@xxxxxxxxx> writes:

> git diff-index --quiet HEAD

It is expected that a Porcelain script that implements a custom feature
may call diff-files, diff-index and other plumbing commands many times
during its lifetime, and that it knows what it is doing (namely, when
it touches the working tree itself and why).

For this reason, most plumbing commands do not refresh the cached stat
information in the index.  A Porcelain script is responsible for running
"update-index --refresh" once before it makes a call that cached stat
information matters, and as long as it doesn't touch the files in the
working tree, it doesn't have to run it again and again.

Porcelain commands like "git diff" that are expected to be run directly by
the end user cannot assume that, so they do not optimize---they typically
refresh the cached stat information by themselves internally whey they
start up.

Your Porcelain script should look something like:

    git update-index --refresh
    git diff-files -q || { echo "modified working tree"; exit 1 }
    git diff-index --cached -q HEAD || { echo "modified index"; exit 2 }

See contrib/examples/*.sh for examples.
--
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]