From 1bfd108593a268bdaf961249866f958081135ce1 Mon Sep 17 00:00:00 2001 From: Sam Duke Date: Wed, 24 Jan 2018 14:01:59 +0000 Subject: [PATCH] Properly detect if commit is a root commit Fix bad check for ancestor root commits. --- pre_commit/resources/pre-push-tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pre_commit/resources/pre-push-tmpl b/pre_commit/resources/pre-push-tmpl index f866eeff..0a3dad57 100644 --- a/pre_commit/resources/pre-push-tmpl +++ b/pre_commit/resources/pre-push-tmpl @@ -8,7 +8,8 @@ do if [ -n "$first_ancestor" ]; then # Check that the ancestor has at least one parent git rev-list --max-parents=0 "$local_sha" | grep "$first_ancestor" > /dev/null - if [ $? -ne 0 ]; then + if [ $? -eq 0 ]; then + # Pushing the whole tree, including the root commit, so run on all files args="--all-files" else source=$(git rev-parse "$first_ancestor"^)