git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Vilain <sam.vilain@catalyst.net.nz>
To: git@vger.kernel.org
Cc: Sam Vilain <sam.vilain@catalyst.net.nz>
Subject: [PATCH] git-merge: run commit hooks when making merge commits
Date: Wed, 11 Jul 2007 22:32:00 +1200	[thread overview]
Message-ID: <11841499201242-git-send-email-sam.vilain@catalyst.net.nz> (raw)

git-merge.sh was not running the commit hooks, so run them in the two
places where we go to commit.

Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
---
   Not sure if it should call these or some specialist hooks, like
   git-am does.

 git-merge.sh |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/git-merge.sh b/git-merge.sh
index 981d69d..ef4f51b 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -117,6 +117,29 @@ merge_name () {
 	fi
 }
 
+call_pre_hooks () {
+	message="$1"
+	if test -x "$GIT_DIR"/hooks/pre-commit
+	then
+		"$GIT_DIR"/hooks/pre-commit || exit 1
+	fi
+	if test -x "$GIT_DIR"/hooks/commit-msg
+	then
+		printf '%s\n' "$message" > "$GIT_DIR"/MERGE_MSG
+		"$GIT_DIR"/hooks/commit-msg "$GIT_DIR"/MERGE_MSG || exit 1
+		cat "$GIT_DIR"/MERGE_MSG
+	else
+		echo "$message"
+	fi
+}
+
+call_post_hook () {
+	if test -x "$GIT_DIR"/hooks/post-commit
+	then
+		"$GIT_DIR"/hooks/post-commit
+	fi
+}
+
 case "$#" in 0) usage ;; esac
 
 have_message=
@@ -334,11 +357,13 @@ f,*)
 		   result_tree=$(git-write-tree)
 		then
 			echo "Wonderful."
+			merge_msg=$(call_pre_hooks "$merge_msg")
 			result_commit=$(
 				printf '%s\n' "$merge_msg" |
 				git-commit-tree $result_tree -p HEAD -p "$1"
 			) || exit
 			finish "$result_commit" "In-index merge"
+			call_post_hook
 			dropsave
 			exit 0
 		fi
@@ -440,8 +465,10 @@ done
 if test '' != "$result_tree"
 then
     parents=$(git-show-branch --independent "$head" "$@" | sed -e 's/^/-p /')
+    merge_msg=$(call_pre_hooks "$merge_msg")
     result_commit=$(printf '%s\n' "$merge_msg" | git-commit-tree $result_tree $parents) || exit
     finish "$result_commit" "Merge made by $wt_strategy."
+    call_post_hook
     dropsave
     exit 0
 fi
-- 
1.5.2.1.1131.g3b90

             reply	other threads:[~2007-07-11 10:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-11 10:32 Sam Vilain [this message]
2007-07-11 21:26 ` [PATCH] git-merge: run commit hooks when making merge commits Junio C Hamano
2007-07-11 23:21   ` Sam Vilain
2007-07-12  8:03   ` Andy Parkins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11841499201242-git-send-email-sam.vilain@catalyst.net.nz \
    --to=sam.vilain@catalyst.net.nz \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).