diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-07-29 21:20:34 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-07-29 21:20:34 +0200 |
commit | 195061fcffda8201ff80150f82ba7ee7fafaf793 (patch) | |
tree | 0bdc52cf7538942fa79bda4dfd3e1601cc8a17f3 | |
parent | b75fcd142b519865715be84315fc7517c0cb6247 (diff) |
Don't miss syntax check on initial commit
-rwxr-xr-x | git/hooks/pre-commit | 3 | ||||
-rw-r--r-- | git/hooks/puppethooks/git.py | 4 |
2 files changed, 4 insertions, 3 deletions
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') |