Git development
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Git Mailing list <git@vger.kernel.org>
Subject: Re: is there a reason pre-commit.sample uses "git diff-index"?
Date: Thu, 31 May 2018 13:27:20 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.2.21.1805311323220.17047@localhost.localdomain> (raw)
In-Reply-To: <CACsJy8CP=1_bHAzs+mveaJvbOOzr9vny-2xz6kM4cEcCYWmOOw@mail.gmail.com>

On Thu, 31 May 2018, Duy Nguyen wrote:

> On Thu, May 31, 2018 at 6:38 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
> >
> >   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.

  ah, this was a philosophical underpinning i was unaware of. i see
occasional explanations of git porcelain versus plumbing, but i don't
recall anyone simply stating that the plumbing is meant to have a
long-term stability that is not guaranteed for the porcelain.

  in any event, this does mean that, stability issues aside, "git
diff" would apparently have worked just fine for that hook.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

  reply	other threads:[~2018-05-31 17:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 16:38 is there a reason pre-commit.sample uses "git diff-index"? Robert P. J. Day
2018-05-31 17:05 ` Duy Nguyen
2018-05-31 17:27   ` Robert P. J. Day [this message]
2018-05-31 17:41     ` Duy Nguyen
2018-05-31 23:08     ` Johannes Sixt
2018-05-31 23:09       ` Robert P. J. Day
2018-05-31 23:25         ` Stefan Beller
2018-06-01  2:23           ` Junio C Hamano

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=alpine.LFD.2.21.1805311323220.17047@localhost.localdomain \
    --to=rpjday@crashcourse.ca \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox