autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

prepare-commit-msg hook for autoconf


From: Paolo Bonzini
Subject: prepare-commit-msg hook for autoconf
Date: Thu, 16 Oct 2008 18:43:04 +0200
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

Here is a prepare-commit-msg hook to make commit messages from ChangeLog
entries.

Paolo
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by git-commit with the name of the file that has the
# commit message, followed by the description of the commit
# message's source.  The hook's purpose is to edit the commit
# message file.  If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, make this file executable.

make_changelog ()
{
  git diff "$@" -- ChangeLog | sed -n \
    -e '/^@@/,/^+/ {' \
    -e '  s/^   //p' \
    -e '  t' \
    -e '}' \
    -e '/^diff/,/^@@/ d' \
    -e 's/^+    //p' \
    -e t | sed -e '1,/^./!b' -e '//!b' -e '/^\*/{;x;p;p;x;b;}' -e 'p;x;p;x;d'
}

case "$2${3+ }$3" in
  merge)
    sed -i '/^Conflicts:/,/#/!b;s/^/# &/;s/^# #/#/' "$1" ;;

  "")
    (echo; echo; make_changelog --cached; grep '^.' "$1") > "$1".tmp
    mv "$1".tmp "$1" ;;

  *) ;;
esac

reply via email to

[Prev in Thread] Current Thread [Next in Thread]