]> git.ipfire.org Git - thirdparty/git.git/commit
push: disallow --all and refspecs when remote.<name>.mirror is set
authorThomas Gummerer <t.gummerer@gmail.com>
Mon, 2 Sep 2019 18:08:28 +0000 (19:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Sep 2019 18:16:54 +0000 (11:16 -0700)
commit8e4c8af058d7eb1b887184deb3bf79f3818b3a65
tree50b4cd6f2d271ec19feb3aa8c831a628fce46f61
parent0d0ac3826a3bbb9247e39e12623bbcfdd722f24c
push: disallow --all and refspecs when remote.<name>.mirror is set

Pushes with --all, or refspecs are disallowed when --mirror is given
to 'git push', or when 'remote.<name>.mirror' is set in the config of
the repository, because they can have surprising
effects. 800a4ab399 ("push: check for errors earlier", 2018-05-16)
refactored this code to do that check earlier, so we can explicitly
check for the presence of flags, instead of their sideeffects.

However when 'remote.<name>.mirror' is set in the config, the
TRANSPORT_PUSH_MIRROR flag would only be set after we calling
'do_push()', so the checks would miss it entirely.

This leads to surprises for users [*1*].

Fix this by making sure we set the flag (if appropriate) before
checking for compatibility of the various options.

*1*: https://twitter.com/FiloSottile/status/1163918701462249472

Reported-by: Filippo Valsorda <filippo@ml.filippo.io>
Helped-by: Saleem Rashid
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c
t/t5517-push-mirror.sh