From 195061fcffda8201ff80150f82ba7ee7fafaf793 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 29 Jul 2011 21:20:34 +0200 Subject: Don't miss syntax check on initial commit --- git/hooks/pre-commit | 3 +-- git/hooks/puppethooks/git.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'git') diff --git a/git/hooks/pre-commit b/git/hooks/pre-commit index cd031c3..8e758e8 100755 --- a/git/hooks/pre-commit +++ b/git/hooks/pre-commit @@ -27,7 +27,6 @@ debug = True def main(): ret = 0 - zero = '0000000000000000000000000000000000000000' try: os.environ['GIT_DIR'] @@ -37,7 +36,7 @@ def main(): rev = 'HEAD' if not git.verify_rev(rev): - rev=zero + rev=None for old_mode, new_mode, old_sha, new_sha, status, name in git.diff_cached(rev): if debug: diff --git a/git/hooks/puppethooks/git.py b/git/hooks/puppethooks/git.py index b2cf81c..450bbd7 100644 --- a/git/hooks/puppethooks/git.py +++ b/git/hooks/puppethooks/git.py @@ -35,7 +35,9 @@ def diff_tree(oldrev, newrev): def diff_cached(rev): """Check the index against the given commit""" # We use -z to handle filenames with spaces, tabs, etc. - cmd = ['git', 'diff', '--cached', '--diff-filter=AM', '--raw', '-z', rev ] + cmd = ['git', 'diff', '--cached', '--diff-filter=AM', '--raw', '-z' ] + if rev: + cmd.append(rev) popen = subprocess.Popen(cmd, stdout=subprocess.PIPE) # Parse the '\0' terminated filenames out of the metadata output = popen.communicate()[0].split('\0') -- cgit v1.2.3