git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/2] git-receive-pack: document push options
@ 2020-02-17 14:44 Drew DeVault
  2020-02-17 14:44 ` [PATCH 2/2] send-pack: downgrade push options error to warning Drew DeVault
  2020-02-18  5:30 ` [PATCH 1/2] git-receive-pack: document push options Jeff King
  0 siblings, 2 replies; 5+ messages in thread
From: Drew DeVault @ 2020-02-17 14:44 UTC (permalink / raw)
  To: git, Stefan Beller, Junio C Hamano; +Cc: Drew DeVault

This adds the missing documentation on how git push options are
presented to the pre-receive hook.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
---
 Documentation/git-receive-pack.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt
index 25702ed730..69b3e77776 100644
--- a/Documentation/git-receive-pack.txt
+++ b/Documentation/git-receive-pack.txt
@@ -109,6 +109,12 @@ the following environment variables:
 This hook is called before any refname is updated and before any
 fast-forward checks are performed.
 
+If the user has specified any push options (see linkgit:git-push[1]),
+`GIT_PUSH_OPTION_COUNT` is set to the number of options, and
+`GIT_PUSH_OPTION_N` is set where N is an integer from 0 thru
+`GIT_PUSH_OPTION_COUNT` - 1. In order for to receive push options,
+`receive.advertisePushOptions` must be enabled on the server.
+
 If the pre-receive hook exits with a non-zero exit status no updates
 will be performed, and the update, post-receive and post-update
 hooks will not be invoked either.  This can be useful to quickly
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] send-pack: downgrade push options error to warning
  2020-02-17 14:44 [PATCH 1/2] git-receive-pack: document push options Drew DeVault
@ 2020-02-17 14:44 ` Drew DeVault
  2020-02-18  5:40   ` Jeff King
  2020-02-18  5:30 ` [PATCH 1/2] git-receive-pack: document push options Jeff King
  1 sibling, 1 reply; 5+ messages in thread
From: Drew DeVault @ 2020-02-17 14:44 UTC (permalink / raw)
  To: git, Stefan Beller, Junio C Hamano; +Cc: Drew DeVault

Because the receiving end has to explicitly enable
receive.advertisePushOptions, and many servers don't, it doesn't make
sense to set push options globally when half of your pushes are just
going to die.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
---
 send-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/send-pack.c b/send-pack.c
index 0407841ae8..8c81825e7d 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -439,7 +439,7 @@ int send_pack(struct send_pack_args *args,
 	use_atomic = atomic_supported && args->atomic;
 
 	if (args->push_options && !push_options_supported)
-		die(_("the receiving end does not support push options"));
+		warning(_("the receiving end does not support push options"));
 
 	use_push_options = push_options_supported && args->push_options;
 
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] git-receive-pack: document push options
  2020-02-17 14:44 [PATCH 1/2] git-receive-pack: document push options Drew DeVault
  2020-02-17 14:44 ` [PATCH 2/2] send-pack: downgrade push options error to warning Drew DeVault
@ 2020-02-18  5:30 ` Jeff King
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff King @ 2020-02-18  5:30 UTC (permalink / raw)
  To: Drew DeVault; +Cc: git, Stefan Beller, Junio C Hamano

On Mon, Feb 17, 2020 at 09:44:31AM -0500, Drew DeVault wrote:

>  Documentation/git-receive-pack.txt | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt
> index 25702ed730..69b3e77776 100644
> --- a/Documentation/git-receive-pack.txt
> +++ b/Documentation/git-receive-pack.txt
> @@ -109,6 +109,12 @@ the following environment variables:
>  This hook is called before any refname is updated and before any
>  fast-forward checks are performed.
>  
> +If the user has specified any push options (see linkgit:git-push[1]),
> +`GIT_PUSH_OPTION_COUNT` is set to the number of options, and
> +`GIT_PUSH_OPTION_N` is set where N is an integer from 0 thru
> +`GIT_PUSH_OPTION_COUNT` - 1. In order for to receive push options,
> +`receive.advertisePushOptions` must be enabled on the server.

Hmm. This is covered already in the pre-receive sections of githooks(7).
I wonder if it would be worth consolidating those and having one refer
to the other.

I'd be OK just duplicating the content in the meantime, but note that
the githooks version covers some more subtleties (like setting the count
to 0 when push options are negotiated but none are sent).

If we do go with the text above, there's a typo: s/for to/to/.

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] send-pack: downgrade push options error to warning
  2020-02-17 14:44 ` [PATCH 2/2] send-pack: downgrade push options error to warning Drew DeVault
@ 2020-02-18  5:40   ` Jeff King
  2020-02-18 17:44     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2020-02-18  5:40 UTC (permalink / raw)
  To: Drew DeVault; +Cc: git, Stefan Beller, Junio C Hamano

On Mon, Feb 17, 2020 at 09:44:32AM -0500, Drew DeVault wrote:

> Because the receiving end has to explicitly enable
> receive.advertisePushOptions, and many servers don't, it doesn't make
> sense to set push options globally when half of your pushes are just
> going to die.

This makes me a little nervous, because we don't know what those push
options were supposed to do. Yet we'll proceed with the push minus the
options, which might perform an action that it's hard for the user to
undo. Imagine something as harmless as an option to suppress
notifications to your teammates about a push, or something as dangerous
as one that changes how the push will do an auto-deploy to a production
service.

That latter is probably unlikely, but it feels like we ought to be
erring on the conservative side here, especially since we've had the old
behavior for so many versions.

I do agree that setting push.pushOptions in your global gitconfig is
probably going to be annoying. Even in the repo .git/config, you might
push to multiple remotes, only some of which support the options.

So perhaps it would make sense to do one or both of:

 - allow remote.*.pushOptions for specific remotes

 - add a push.pushOptionIfAble key which behaves similarly to
   push.pushOption, but is quietly ignored if options aren't supported.
   Then you could put options there that you know are safe to be
   ignored.

I'm not sure exactly what kinds of options you want be setting globally,
so I'm not sure which of those would be more useful.

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] send-pack: downgrade push options error to warning
  2020-02-18  5:40   ` Jeff King
@ 2020-02-18 17:44     ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2020-02-18 17:44 UTC (permalink / raw)
  To: Jeff King; +Cc: Drew DeVault, git, Stefan Beller

Jeff King <peff@peff.net> writes:

> This makes me a little nervous, because we don't know what those push
> options were supposed to do.

Thanks for stopping this early.  As you said, this die() is very
much deliberate way for us to make sure that we do not damage an
receiving end that is not prepared.
          
> So perhaps it would make sense to do one or both of:
>
>  - allow remote.*.pushOptions for specific remotes
>
>  - add a push.pushOptionIfAble key which behaves similarly to
>    push.pushOption, but is quietly ignored if options aren't supported.
>    Then you could put options there that you know are safe to be
>    ignored.

Sensible suggestions.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-18 17:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 14:44 [PATCH 1/2] git-receive-pack: document push options Drew DeVault
2020-02-17 14:44 ` [PATCH 2/2] send-pack: downgrade push options error to warning Drew DeVault
2020-02-18  5:40   ` Jeff King
2020-02-18 17:44     ` Junio C Hamano
2020-02-18  5:30 ` [PATCH 1/2] git-receive-pack: document push options Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).