git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Buchacher <clemens.buchacher@intel.com>
To: git@vger.kernel.org
Cc: junio@pobox.com
Subject: Re: [PATCH] allow hooks to ignore their standard input stream
Date: Wed, 11 Nov 2015 15:42:22 +0100	[thread overview]
Message-ID: <20151111144222.GA24717@musxeris015.imu.intel.com> (raw)
In-Reply-To: <20151111143920.GA30409@musxeris015.imu.intel.com>

On Wed, Nov 11, 2015 at 03:39:20PM +0100, Clemens Buchacher wrote:
> +		if (write_in_full(proc.in, buf.buf, buf.len) < 0) {
> +			/* We do not mind if a hook does not read all refs. */
> +			if (errno != EPIPE)
> +				ret = -1;

I can reproduce the pipe error reliably with the test below. I did not
include it in the patch since I am in doubt if we should add an optional
sleep to the code.

-->o--
diff --git a/t/t5571-pre-push-hook.sh b/t/t5571-pre-push-hook.sh
index 6f9916a..8cfe59a 100755
--- a/t/t5571-pre-push-hook.sh
+++ b/t/t5571-pre-push-hook.sh
@@ -109,23 +109,13 @@ test_expect_success 'push to URL' '
        diff expected actual
 '

-# Test that filling pipe buffers doesn't cause failure
-# Too slow to leave enabled for general use
-if false
-then
-       printf 'parent1\nrepo1\n' >expected
-       nr=1000
-       while test $nr -lt 2000
-       do
-               nr=$(( $nr + 1 ))
-               git branch b/$nr $COMMIT3
-               echo "refs/heads/b/$nr $COMMIT3 refs/heads/b/$nr $_z40" >>expected
-       done
-
-       test_expect_success 'push many refs' '
-               git push parent1 "refs/heads/b/*:refs/heads/b/*" &&
-               diff expected actual
-       '
-fi
+write_script "$HOOK" <<\EOF
+exit 0
+EOF
+
+test_expect_success 'hook does not consume input' '
+    git branch noinput &&
+    GIT_TEST_SIGPIPE=t git push parent1 noinput
+'

 test_done
diff --git a/transport.c b/transport.c
index 23b2ed6..d83ef1c 100644
--- a/transport.c
+++ b/transport.c
@@ -1129,6 +1129,8 @@ static int run_pre_push_hook(struct transport *transport,

        strbuf_init(&buf, 256);

+       if (getenv("GIT_TEST_SIGPIPE"))
+               sleep_millisec(10);
        for (r = remote_refs; r; r = r->next) {
                if (!r->peer_ref) continue;
                if (r->status == REF_STATUS_REJECT_NONFASTFORWARD) continue;

  reply	other threads:[~2015-11-11 14:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 14:39 [PATCH] allow hooks to ignore their standard input stream Clemens Buchacher
2015-11-11 14:42 ` Clemens Buchacher [this message]
2015-11-13  6:17   ` Jeff King
2015-11-13  9:33     ` Clemens Buchacher
2015-11-13 23:23       ` Jeff King
2015-11-16  8:05         ` Clemens Buchacher
2015-11-16 13:59           ` Jeff King
2015-11-13  6:18 ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151111144222.GA24717@musxeris015.imu.intel.com \
    --to=clemens.buchacher@intel.com \
    --cc=git@vger.kernel.org \
    --cc=junio@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).