Re: [PATCH] git-commit: add a prepare-commit-msg hook

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Johannes Schindelin <Johannes.Schindelin@...>, Git Mailing List <git@...>
Date: Friday, January 18, 2008 - 12:37 pm

> In the message hook, just grep if the template was already added.  If it 

Ah, so you want me to always type ":q!" to exit and unnecessarily 
complicate the commit-msg hook.  Cunning, but no, thanks.

I'll make an example.  This is my prepare-commit-msg hook:

diff_collect_changelog ()
{
   git diff "$@" -- \
    `git diff "$@" --name-status -r | \
         awk '/ChangeLog/ { print substr ($0, 3) }'` | sed -n \
     -e '/^@@/,/^+/ {' \
     -e '  s/^ //p' \
     -e '  t' \
     -e '}' \
     -e '/^diff/,/^@@/ {' \
     -e '  s/^diff --git a\/\(.*\)\/ChangeLog[^ ]* b\/.*/\1:/p' \
     -e '  tdummy' \
     -e '  :dummy' \
     -e '  d' \
     -e '}' \
     -e 's/^+//p' \
     -e 't'
}

diff_collect_changelog --cached > /tmp/foo$$
cat "$GIT_COMMIT_MSG" >> /tmp/foo$$ && \
   mv /tmp/foo$$ "$GIT_COMMIT_MSG"
rm -f /tmp/foo$$

or something like that.  The alternative I see would be to start the vi 
editing session with "!!make_changelog --cached".  So I thought about 
having an hook that runs the command for me.  Do you have better ideas?

Paolo
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 10:51 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Junio C Hamano, (Fri Jan 18, 6:05 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Sat Jan 19, 5:32 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Johannes Schindelin, (Sat Jan 19, 7:20 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Sat Jan 19, 12:04 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Benoit Sigoure, (Sat Jan 19, 11:41 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Alex Riesen, (Fri Jan 18, 3:05 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 3:46 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Alex Riesen, (Fri Jan 18, 5:08 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Johannes Schindelin, (Fri Jan 18, 11:47 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 11:51 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Johannes Schindelin, (Fri Jan 18, 12:06 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 12:37 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Johannes Schindelin, (Fri Jan 18, 2:06 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Benoit Sigoure, (Fri Jan 18, 3:01 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 2:51 pm)