Git development
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Larry Martell <larry.martell@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: hook to get info on commit, and include that in a file that is part of the commit
Date: Tue, 5 Feb 2019 01:55:06 +0000	[thread overview]
Message-ID: <20190205015506.GB527887@genre.crustytoothpaste.net> (raw)
In-Reply-To: <CACwCsY5xU0pUaPZDJMqWNB0dz7DjTx3_b2Lvrft0NjA6cnPvcg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]

On Mon, Feb 04, 2019 at 08:36:10PM -0500, Larry Martell wrote:
> Is there any way using a git hook to get info on the commit (id,
> message), put that in a file, and include that file in the commit?
> 
> If I try that in a pre-commit hook I do not get the info on the
> current commit. I tried it in pre-receive but it does not seem to get
> executed at all.

You cannot include a file in the commit with that commit's ID.

The object ID of a commit is based on the data it contains, which is in
turn based on the data in its top-level tree, which is in turn based on
the data in all of its trees and blobs. If you add or change a file in a
commit (or the message of that commit), you necessarily result in that
commit having a different object ID. This is by design and is valuable
for checking the integrity of the history.

Furthermore, the hooks for a commit are designed for checking and
notification, not for editing the commit, with the exception of the
commit message hooks, which are designed only for editing the commit
message, not the contents.

The pre-receive hook runs on the server side, so if you aren't running
it there, then it won't get called at all.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

  reply	other threads:[~2019-02-05  1:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05  1:36 hook to get info on commit, and include that in a file that is part of the commit Larry Martell
2019-02-05  1:55 ` brian m. carlson [this message]
2019-02-05  2:00   ` Larry Martell
2019-02-05  2:15     ` brian m. carlson
2019-02-05  2:18       ` Larry Martell
2019-02-05  2:40         ` brian m. carlson
2019-02-05  2:42           ` Larry Martell

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=20190205015506.GB527887@genre.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=larry.martell@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