Re: is there a reason pre-commit.sample uses "git diff-index"?
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- May 31, 2018, 17:05 UTC
- Message-ID
- <CACsJy8CP=1_bHAzs+mveaJvbOOzr9vny-2xz6kM4cEcCYWmOOw@mail.gmail.com>
- In-Reply-To
- <alpine.LFD.2.21.1805311235410.15130@localhost.localdomain>
On Thu, May 31, 2018 at 6:38 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
Show 12 quoted lines
> > was going over some hooks and writing some tutorials for some of the > commit-related, client-side hooks, and was wondering (perhaps > stupidly) why the pre-commit.sample hook uses, as its last line: > > exec git diff-index --check --cached $against -- > ^^^^^^^^^^ > > as in, could this not be done equivalently with just git diff, not git > diff-index? i just did a quick test and it seems to do the same thing, > but i've never taken a close look at git diff-index before so i may > just be clueless about some important distinction.
git diff-index is "plumbing", designed for writing scripts. "git diff" on the other hand is for users and its behavior may change even if it breaks backward compatibility.
-- Duy