git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: pre-commit hook

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 20, 2009, 16:25 UTC
Message-ID
<7v63j5t6r3.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090220091127.GA7415@b2j>
bill lam <cbill.lam@gmail.com> writes:
> The pre-commit hooks as follows.
>
>  10 # This is slightly modified from Andrew Morton's Perfect Patch.
>  11 # Lines you introduce should not have trailing whitespace.

That's a sample hook from an ancient version of git. We do not ship that version anymore since late last June. You should be able to replace it with the version shipped with v1.6.0 or later if your git is recent enough.

    #!/bin/sh
    #
    # An example hook script to verify what is about to be committed.
    # Called by git-commit with no arguments.  The hook should
    # exit with non-zero status after issuing an appropriate message if
    # it wants to stop the commit.
    #
    # To enable this hook, rename this file to "pre-commit".
    if git-rev-parse --verify HEAD 2>/dev/null
    then
            against=HEAD
    else
            # Initial commit: diff against an empty tree object
            against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
    fi
    exec git diff-index --check --cached $against --

Perhaps a time to upgrade? People should be running at least 1.6.0 these days ;-).

Previous: bill lamNext: bill lam
Message 2 of 7 in “pre-commit hook”
  1. bill lamFeb 20, 2009
  2. Junio C HamanoFeb 20, 2009
  3. bill lamFeb 21, 2009
  4. Michael J GruberFeb 21, 2009
  5. bill lamFeb 22, 2009
  6. Sverre RabbelierFeb 22, 2009
  7. bill lamFeb 22, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.