summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-01-26 13:47:38 -0500
committerBrad King <brad.king@kitware.com>2011-01-26 13:47:38 -0500
commitf635fab3cc88bbba7fc4b58e8def08a630346237 (patch)
tree11d04126a872e1e7b4c1cd7d61404784b533e6e7
parent5d4166083669297e2930ad6d23150e17edcb4eac (diff)
downloadcmake-f635fab3cc88bbba7fc4b58e8def08a630346237.tar.gz
pre-commit: Allow merged submodule updates
If "git merge" brings in a submodule update then allow it without requiring the extra step added in commit 48e72dd1 (Check submodules staged with other changes, 2010-08-10).
-rwxr-xr-xpre-commit8
1 files changed, 8 insertions, 0 deletions
diff --git a/pre-commit b/pre-commit
index d6aedb2522..3b90108999 100755
--- a/pre-commit
+++ b/pre-commit
@@ -56,6 +56,9 @@ else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
+# Merge ("git commit" after "git merge" with conflicts or --no-commit)
+merge_head=$(git rev-parse -q --verify MERGE_HEAD) || merge_head=''
+
# Disallow non-ascii file names. The printable range starts at the
# space character and ends with tilde.
if test "$(git diff --cached --name-only --diff-filter=A -z $against |
@@ -209,6 +212,11 @@ check_module() {
enabled=$(git config --get --bool hooks.submodule) || enabled=true
test "$enabled" = "false" && return
+ # Allow merged submodule updates.
+ test -n "$merge_head" &&
+ merge_obj=$(git rev-parse -q --verify "$merge_head:$file") &&
+ test "$merge_obj" = "$dst_obj" && return
+
# Allow module-only commits without extra work.
test -z "$diffs_normal" && return