Skip to content

Instantly share code, notes, and snippets.

@ThisIsMissEm
Created August 19, 2020 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThisIsMissEm/b4b569385806975037da1f37f92fccc1 to your computer and use it in GitHub Desktop.
Save ThisIsMissEm/b4b569385806975037da1f37f92fccc1 to your computer and use it in GitHub Desktop.
Patch with test for git pre-push hook when remote is already up to date; No stdin lines are generated
diff --git a/t/t5571-pre-push-hook.sh b/t/t5571-pre-push-hook.sh
index ac53d63869..edb619726e 100755
--- a/t/t5571-pre-push-hook.sh
+++ b/t/t5571-pre-push-hook.sh
@@ -19,14 +19,31 @@ test_expect_success 'setup' '
test_commit one &&
git push parent1 HEAD:foreign
'
+
+COMMIT1="$(git rev-parse HEAD)"
+export COMMIT1
+
+write_script "$HOOK" <<'EOF'
+echo "$1" >actual
+echo "$2" >>actual
+cat >>actual
+EOF
+
+cat >expected <<EOF
+parent1
+repo1
+EOF
+
+test_expect_success 'push with no updates' '
+ git push parent1 master:foreign &&
+ diff expected actual
+'
+
write_script "$HOOK" <<EOF
cat >/dev/null
exit 1
EOF
-COMMIT1="$(git rev-parse HEAD)"
-export COMMIT1
-
test_expect_success 'push with failing hook' '
test_commit two &&
test_must_fail git push parent1 HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment