Fix prepare-commit-msg hook and replace in-place sed
authorMarcel Koeppen <git-dev@marzelpan.de>
Wed, 21 May 2008 16:25:54 +0000 (18:25 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 May 2008 16:45:53 +0000 (09:45 -0700)
The patterns to the case statement could never be matched, so the hook
was a noop. This patch also replaces the non-portable use of in-place sed.

Signed-off-by: Marcel Koeppen <git-dev@marzelpan.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
templates/hooks--prepare-commit-msg
index ff0f42a1d984cdcd4b647e713eaec668177fb1f6..d3c1da34d2c7cbdd66ca142b5bf0ec5b877e1baa 100644 (file)
 # The third example adds a Signed-off-by line to the message, that can
 # still be edited.  This is rarely a good idea.
 
-case "$2 $3" in
-  merge)
-    sed -i '/^Conflicts:/,/#/!b;s/^/# &/;s/^# #/#/' "$1" ;;
+case "$2,$3" in
+  merge,)
+    perl -i -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
 
-# ""|template)
+# ,|template,)
 #   perl -i -pe '
 #      print "\n" . `git diff --cached --name-status -r`
 #       if /^#/ && $first++ == 0' "$1" ;;