From: Jeff King <peff@peff.net>
To: James Pickens <jepicken@gmail.com>
Cc: Git ML <git@vger.kernel.org>
Subject: Re: Disallow amending published commits?
Date: Sat, 21 Mar 2009 22:42:26 -0400 [thread overview]
Message-ID: <20090322024226.GA6766@coredump.intra.peff.net> (raw)
In-Reply-To: <885649360903211056u38ff6cabxbe1a17d57faaa0c4@mail.gmail.com>
On Sat, Mar 21, 2009 at 10:56:26AM -0700, James Pickens wrote:
> I wanted to have a pre-commit hook that would prevent users from
> amending a commit that had already been published, but I couldn't
> find any way in the pre-commit hook to figure out if --amend was
> used. Is there a way to do that? Or any better way to disallow
> amending published commits?
I don't think so; as somebody already mentioned, the usual time to
resolve such issues is at push-time. However, I can see how it would be
convenient to catch such a problem early, since by the time you push, it
may be much later and you don't remember exactly why you amended instead
of building on top (or as you indicated, your workflow may involve
pulling).
I suspect the right way to go about this is to inform the pre-commit
hook about the parents of the proposed commit. It already knows the
current branch (since it is in HEAD), and from there you should be able
to implement any policy logic regarding changing the shape of history
(including your request).
Right now that information is totally contained within the git-commit
process; probably the simplest thing would be to export a
space-separated list of SHA-1's to the hook.
-Peff
prev parent reply other threads:[~2009-03-22 2:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-21 17:56 Disallow amending published commits? James Pickens
2009-03-21 18:46 ` Peter Harris
2009-03-21 22:49 ` James Pickens
2009-03-22 1:53 ` Peter Harris
2009-03-22 2:57 ` Peter Harris
2009-03-22 4:09 ` James Pickens
2009-03-22 14:19 ` Peter Harris
2009-03-22 15:15 ` Nicolas Sebrecht
2009-03-22 2:42 ` Jeff King [this message]
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=20090322024226.GA6766@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=jepicken@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;
as well as URLs for NNTP newsgroup(s).