From cfcb8497bfbdea72d0c27676f5847bde80b5ac91 Mon Sep 17 00:00:00 2001 From: Brandon Cordell Date: Thu, 4 Dec 2014 22:23:30 -0500 Subject: [PATCH] Fix pre-commit, prepare-commit-msg hooks For users who had not overridden the `pre-commit` or `prepare-commit-msg` Git hooks, they would see `git commit` hang, with nothing happening. The command would exit without going to their editor. The bug was introduced in d7f194f94ee1ab535da18e657f0c51479c0233b4 and the fix is to return a 0 exit code when the override is not present. --- git_template/hooks/pre-commit | 5 ++++- git_template/hooks/prepare-commit-msg | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/git_template/hooks/pre-commit b/git_template/hooks/pre-commit index f50a924..39637c8 100755 --- a/git_template/hooks/pre-commit +++ b/git_template/hooks/pre-commit @@ -1,4 +1,7 @@ #!/bin/sh local_hook="$HOME"/.git_template.local/hooks/pre-commit -[ -f "$local_hook" ] && . "$local_hook" + +if [ -f "$local_hook" ]; then + . "$local_hook" +fi diff --git a/git_template/hooks/prepare-commit-msg b/git_template/hooks/prepare-commit-msg index c4dfb27..1a2c2bc 100755 --- a/git_template/hooks/prepare-commit-msg +++ b/git_template/hooks/prepare-commit-msg @@ -1,4 +1,7 @@ #!/bin/sh local_hook="$HOME"/.git_template.local/hooks/prepare-commit-msg -[ -f "$local_hook" ] && . "$local_hook" + +if [ -f "$local_hook" ]; then + . "$local_hook" +fi