Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Patch with test for git pre-push hook when remote is already up to date; No stdin lines are generated
diff --git a/t/ b/t/
index ac53d63869..edb619726e 100755
--- a/t/
+++ b/t/
@@ -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
+cat >expected <<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
-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