Sending multiple options via "--push-option=" in "git push"

Viewed 5605

With Git 2.10 a new option came [--push-option=]. When a bare repository is created a post-receive.sample is auto created inside hooks directory, which saying following:

#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".

I tried following steps

  1. Renaming the file to pre-receive
  2. Clone the repository to a local machine
  3. tried git push --push-option=echoback=Hello_world

As the sample says it put back the Hello_world in my terminal.

Git Hook Manual says that i could send multiple options via --push-option= which will be available via GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,... as the manual suggests.

My Question is How should i pass multiple options ? which could be passed via --push-option=

Tried options:

  1. git push --push-option="echoback=Hello echoback=World"
  2. git push --push-option="echoback=Hello;echoback=World"
  3. git push --push-option="echoback=Hello&echoback=World"
  4. git push --push-option="echoback=Hello%echoback=World"
  5. git push --push-option="echoback=Hello,echoback=World"
2 Answers

Git 2.15.x/2.16 (Q1 2018) clarifies the multiple push-options usage, adding the "--push-option=<string>" option to "git push" now defaults to a list of strings configured via push.pushOption variable.

So you can either use multiple push options:

git push --push-option="a" --push-option="b"

Or use multiple configuration string

~/.gitconfig
  push.pushoption = a
  push.pushoption = b

See commit d805275 (23 Oct 2017) by Marius Paliga (``).
(Merged by Junio C Hamano -- gitster -- in commit c692fe2, 06 Nov 2017)

builtin/push.c: add push.pushOption config

Push options need to be given explicitly, via the command line as "git push --push-option <option>".
Add the config option push.pushOption, which is a multi-valued option, containing push options that are sent by default.

When push options are set in the lower-priority configulation file (e.g. /etc/gitconfig, or $HOME/.gitconfig), they can be unset later in the more specific repository config by the empty string.

Related