Re: [PATCH] Teach applymbox to keep the Subject: line.
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Aug 18, 2005, 20:07 UTC
- Message-ID
- <Pine.LNX.4.58.0508181257320.3412@g5.osdl.org>
- In-Reply-To
- <20050818172646.GA18459@mars.ravnborg.org>
On Thu, 18 Aug 2005, Sam Ravnborg wrote:
Show 5 quoted lines
> > I almost always handedit my mails and I find myself forgetting to add > "Signed-off-by" from time to time. > Is there a simple way to implment a trigger that can check that _I_ > signed off the patch before applying it?
Well, Junio has been talking about adding commit hooks. I don't think that's been done. The idea being that you could verify that the thing you're committing follows certain rules (no bad whitespace added in the diff, sign-offs in the messages, whatever).
That said, git-applypatch (which is what git-applymbox ends up calling) does not use the general "git commit" script. So it would have to have its own hook. The script is pretty easy to read, though: just look at git-applypatch, and notice that the last stages are:
... git-apply --index $PATCHFILE || exit 1 tree=$(git-write-tree) || exit 1 echo Wrote tree $tree commit=$(git-commit-tree $tree -p $(cat .git/HEAD) < $final) || exit 1 echo Committed: $commit echo $commit > .git/HEAD
and that just before this thing you could easily add some sanity checking by hand. The commit message at that point is in the "$final" file, and the patch is obviously in $PATCHFILE, so you can verify either of those to your hearts content.
The only question is what the hook/trigger should look like. just put something like
[ -x .git/hooks/applypatch-hook ] && .git/hooks/applypatch-hook "$tree" "$PATCHFILE" || exit
at the line before that "git-apply" perhaps? Then, you could install your own applypatch hook which looks at the message or the patch?
Linus