[Cmake-commits] CMake branch, hooks, updated. 5ebbe2daccbb2fc20aa8a43bf872dd2a722156b6

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Mar 1 11:37:46 EST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, hooks has been updated
       via  5ebbe2daccbb2fc20aa8a43bf872dd2a722156b6 (commit)
       via  b966ceb43755028720f56948e45db0c3bdcda500 (commit)
      from  ad08c2091c710f886c2d8a827bb3c90d8b8a9d03 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5ebbe2daccbb2fc20aa8a43bf872dd2a722156b6
commit 5ebbe2daccbb2fc20aa8a43bf872dd2a722156b6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Feb 29 16:26:33 2012 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Feb 29 16:32:01 2012 -0500

    Set GIT_DIR if not already set
    
    Although it seems reasonable to expect GIT_DIR to be set when
    hooks are invoked, the "git help hooks" documentation does not
    guarantee it.  On msysGit 1.7.8 (and perhaps others) "git gui"
    runs prepare-commit-msg without setting GIT_DIR.  Set GIT_DIR
    at the beginning of each commit hook if it is not already set.

diff --git a/commit-msg b/commit-msg
index 8c0562e..8570266 100755
--- a/commit-msg
+++ b/commit-msg
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #=============================================================================
-# Copyright 2010-2011 Kitware, Inc.
+# Copyright 2010-2012 Kitware, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
 # limitations under the License.
 #=============================================================================
 
+. "${BASH_SOURCE%/*}/hooks-config.bash"
+
 # Prepare a copy of the message:
 #  - strip comment lines
 #  - stop at "diff --git" (git commit -v)
@@ -35,8 +37,6 @@ die() {
 	exit 1
 }
 
-. "$GIT_DIR/hooks/hooks-config.bash"
-
 #-----------------------------------------------------------------------------
 # Check the commit message layout with a simple state machine.
 
diff --git a/hooks-config.bash b/hooks-config.bash
index a25d7d1..a12ad96 100644
--- a/hooks-config.bash
+++ b/hooks-config.bash
@@ -1,5 +1,5 @@
 #=============================================================================
-# Copyright 2010-2011 Kitware, Inc.
+# Copyright 2010-2012 Kitware, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -14,6 +14,11 @@
 # limitations under the License.
 #=============================================================================
 
+# Make sure GIT_DIR is set.
+if test -z "$GIT_DIR"; then
+	export GIT_DIR=$(git rev-parse --git-dir)
+fi
+
 # Load hooks configuration from source tree.
 config=".hooks-config.bash" && test -r "$config" && . "$config"
 
diff --git a/pre-commit b/pre-commit
index b2cfe2d..834c3fe 100755
--- a/pre-commit
+++ b/pre-commit
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #=============================================================================
-# Copyright 2010-2011 Kitware, Inc.
+# Copyright 2010-2012 Kitware, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
 # limitations under the License.
 #=============================================================================
 
+. "${BASH_SOURCE%/*}/hooks-config.bash"
+
 die() {
 	echo 'pre-commit hook failure' 1>&2
 	echo '-----------------------' 1>&2
@@ -23,8 +25,6 @@ die() {
 	exit 1
 }
 
-. "$GIT_DIR/hooks/hooks-config.bash"
-
 zero='0000000000000000000000000000000000000000'
 
 #-----------------------------------------------------------------------------
diff --git a/prepare-commit-msg b/prepare-commit-msg
index aa86d6d..035677f 100755
--- a/prepare-commit-msg
+++ b/prepare-commit-msg
@@ -15,7 +15,7 @@
 # limitations under the License.
 #=============================================================================
 
-. "$GIT_DIR/hooks/hooks-config.bash"
+. "${BASH_SOURCE%/*}/hooks-config.bash"
 
 # Invoke the Gerrit Change-Id hook here for "git merge" because
 # it does not run the normal commit-msg hook.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b966ceb43755028720f56948e45db0c3bdcda500
commit b966ceb43755028720f56948e45db0c3bdcda500
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Feb 6 14:39:18 2012 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Feb 6 14:39:18 2012 -0500

    prepare-commit-msg: Add Gerrit Change-Id to merges
    
    The "git merge" command generates its own commit message and does not
    invoke the commit-msg hook.  Fortunately it invokes prepare-commit-msg
    so teach it to call the gerrit/commit-msg hook for merges.
    
    Suggested-by: Chris Harris <chris.harris at kitware.com>

diff --git a/prepare-commit-msg b/prepare-commit-msg
index f2bd2ab..aa86d6d 100755
--- a/prepare-commit-msg
+++ b/prepare-commit-msg
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #=============================================================================
-# Copyright 2010-2011 Kitware, Inc.
+# Copyright 2010-2012 Kitware, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -17,6 +17,14 @@
 
 . "$GIT_DIR/hooks/hooks-config.bash"
 
+# Invoke the Gerrit Change-Id hook here for "git merge" because
+# it does not run the normal commit-msg hook.
+hooks_GerritId=$(git config --get hooks.GerritId)
+case "$hooks_GerritId,$2,$3" in
+	true,merge,) "$GIT_DIR/hooks/gerrit/commit-msg" "$1" ;;
+	*) ;;
+esac
+
 #-----------------------------------------------------------------------------
 # Chain to project-specific hook.
 . "$GIT_DIR/hooks/hooks-chain.bash"

-----------------------------------------------------------------------

Summary of changes:
 commit-msg         |    6 +++---
 hooks-config.bash  |    7 ++++++-
 pre-commit         |    6 +++---
 prepare-commit-msg |   12 ++++++++++--
 4 files changed, 22 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list