From: Dennis Kaarsemaker <dennis@kaarsemaker.net>
To: git@vger.kernel.org
Cc: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Subject: [PATCH 3/3] send-pack: propagate --force and --quiet to remote hooks
Date: Sat, 30 Jan 2016 19:28:10 +0100 [thread overview]
Message-ID: <1454178490-17873-4-git-send-email-dennis@kaarsemaker.net> (raw)
In-Reply-To: <1454178490-17873-1-git-send-email-dennis@kaarsemaker.net>
When a server supports hook options, we send it options for quiet and
force if the user used push --force/--quiet.
Signed-off-by: Dennis Kaarsemaker <git@vger.kernel.org>
---
send-pack.c | 10 ++++++++++
t/t5544-push-hook-options.sh | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
create mode 100755 t/t5544-push-hook-options.sh
diff --git a/send-pack.c b/send-pack.c
index 047bd18..5630327 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -371,6 +371,8 @@ int send_pack(struct send_pack_args *args,
int agent_supported = 0;
int use_atomic = 0;
int atomic_supported = 0;
+ int hook_options_supported = 0;
+ int hook_options_seen = 0;
unsigned cmds_sent = 0;
int ret;
struct async demux;
@@ -393,6 +395,8 @@ int send_pack(struct send_pack_args *args,
args->use_thin_pack = 0;
if (server_supports("atomic"))
atomic_supported = 1;
+ if (server_supports("hook-options"))
+ hook_options_supported = 1;
if (args->push_cert != SEND_PACK_PUSH_CERT_NEVER) {
int len;
@@ -429,6 +433,12 @@ int send_pack(struct send_pack_args *args,
strbuf_addstr(&cap_buf, " atomic");
if (agent_supported)
strbuf_addf(&cap_buf, " agent=%s", git_user_agent_sanitized());
+ if (hook_options_supported) {
+ if (args->quiet)
+ strbuf_addf(&cap_buf, "%squiet", hook_options_seen++ ? "," : " hook-options=");
+ if (args->force_update)
+ strbuf_addf(&cap_buf, "%sforce", hook_options_seen++ ? "," : " hook-options=");
+ }
/*
* NEEDSWORK: why does delete-refs have to be so specific to
diff --git a/t/t5544-push-hook-options.sh b/t/t5544-push-hook-options.sh
new file mode 100755
index 0000000..6d52ad1
--- /dev/null
+++ b/t/t5544-push-hook-options.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+test_description='pushing to a repository with hook options'
+
+. ./test-lib.sh
+
+test_expect_success 'hook options are passed on to hooks' '
+ git init --bare remote.git &&
+ write_script remote.git/hooks/post-receive <<-\EOF &&
+ echo "post-receive-hook"
+ echo $GIT_HOOK_OPTIONS
+ EOF
+ (
+ test_commit one &&
+ git push remote/ master:test 2> actual &&
+ test_commit two &&
+ git push --quiet remote/ master:test 2>> actual &&
+ test_commit three &&
+ git push --force remote/ master:test 2>> actual &&
+ test_commit four &&
+ git push --quiet --force remote/ master:test 2>> actual
+ ) &&
+ sed -ne "s/remote: \([^ ]*\).*/\1/p" -i actual &&
+ cat > expected <<-\EOF &&
+ post-receive-hook
+
+ post-receive-hook
+ quiet
+ post-receive-hook
+ force
+ post-receive-hook
+ quiet,force
+ EOF
+ test_cmp expected actual
+'
+
+test_done
--
2.7.0-91-gf04ef09
prev parent reply other threads:[~2016-01-30 18:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-30 18:28 [PATCH 0/3] Propagating push options to remote hooks Dennis Kaarsemaker
2016-01-30 18:28 ` [PATCH 1/3] connect.[ch]: make parse_feature_value non-static Dennis Kaarsemaker
2016-01-30 18:28 ` [PATCH 2/3] receive-pack: add a capability for hook options Dennis Kaarsemaker
2016-01-30 18:28 ` Dennis Kaarsemaker [this message]
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=1454178490-17873-4-git-send-email-dennis@kaarsemaker.net \
--to=dennis@kaarsemaker.net \
--cc=git@vger.kernel.org \
/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).