From: "Filippo Valsorda" <filippo@ml.filippo.io>
To: git@vger.kernel.org
Subject: Bug: git push in a --mirror repository deletes all refs
Date: Tue, 20 Aug 2019 20:05:20 -0400 [thread overview]
Message-ID: <4d995a0b-0ac4-45a0-9ead-1bc76bd720c7@www.fastmail.com> (raw)
When used in a repository cloned with --mirror, git push with refs on
the command line deletes all unmentioned refs.
This was investigated by @saleemrash1d on Twitter. I'm reporting
their findings here and a reproduction below.
> seems to be a regression.
> TRANSPORT_PUSH_MIRROR is set by remote->mirror
> (https://github.com/git/git/blob/5fa0f5238b0/builtin/push.c#L410)
> AFTER the check for refspecs provided on the command-line
> (https://github.com/git/git/blob/5fa0f5238/builtin/push.c#L615).
> introduced by 800a4ab399e954b8970897076b327bf1cf18c0ac.
> it's mirroring only the refspecs you provided on the command-line to
> the server. i.e. all local refs that aren't stated on the command-line
> will still be deleted
> this unexpected behaviour is why --mirror isn't allowed to be used
> when refspecs are specified on the command-line. but the above commit
> moves the sanity check so it doesn't catch the implied --mirror when
> remote.<remote>.mirror is set (i.e. cloned with --mirror)
https://twitter.com/saleemrash1d/status/1163963105849876481
$ git clone --mirror git@github.com:FiloSottile/test.git
$ git ls-remote
From git@github.com:FiloSottile/test.git
2aa1cacf9b1a6b1227c7c13367ec38637ef3d9a3 HEAD
2aa1cacf9b1a6b1227c7c13367ec38637ef3d9a3 refs/heads/master
773069ef7f893e7fcb3271e6ba80eeafbfb98694 refs/heads/patch-1
2aa1cacf9b1a6b1227c7c13367ec38637ef3d9a3 refs/tags/v0.0.0
$ git show-ref
2aa1cacf9b1a6b1227c7c13367ec38637ef3d9a3 refs/heads/master
773069ef7f893e7fcb3271e6ba80eeafbfb98694 refs/heads/patch-1
2aa1cacf9b1a6b1227c7c13367ec38637ef3d9a3 refs/tags/v0.0.0
$ git push -d origin patch-1
To github.com:FiloSottile/test.git
- [deleted] patch-1
- [deleted] v0.0.0
! [remote rejected] master (refusing to delete the current branch: refs/heads/master)
error: failed to push some refs to 'git@github.com:FiloSottile/test.git'
$ git version
git version 2.22.0
next reply other threads:[~2019-08-21 0:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-21 0:05 Filippo Valsorda [this message]
2019-09-02 18:08 ` [PATCH] push: disallow --all and refspecs when remote.<name>.mirror is set Thomas Gummerer
2019-09-03 18:29 ` Junio C Hamano
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=4d995a0b-0ac4-45a0-9ead-1bc76bd720c7@www.fastmail.com \
--to=filippo@ml.filippo.io \
--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).