From: Junio C Hamano Date: Wed, 10 Nov 2010 19:57:11 GMT Subject: Re: is it kosher for pre-commit to change what's staged? Message-ID: <7v1v6thrzc.fsf@alter.siamese.dyndns.org> In-Reply-To: <20101110170819.GA3031@gnu.kitenet.net> Joey Hess writes: > I've noticed that if I make a pre-commit hook change the files that are > staged, those changes are not reflected in the commit message. For > example, if a pre-commit hook git add's somefile, the commit message > won't reflect that. I guess prepare-commit-msg is being run before > pre-commit for some reason? My intention was that Documentation/githooks.txt would document things that are allowed (e.g. "applypatch-msg" explicitly says "The hook is allowed to edit the message"), and anything that is not specifically allowed is not. "Is it kosher" is a difficult question to answer, as something may not be allowed but there may not be an enforcement mechanism to deny it, iow, it may happen to work by accident. In general, pre-anything is about checking and denying and is supposed to be free of side effects.