From: Junio C Hamano <gitster@pobox.com>
To: Tilman Vogel <tilman.vogel@web.de>
Cc: git@vger.kernel.org
Subject: Re: What does `git push origin --delete ""` do?
Date: Tue, 23 Feb 2021 14:46:51 -0800 [thread overview]
Message-ID: <xmqqa6ru1jxg.fsf@gitster.g> (raw)
In-Reply-To: <CAAbQbbCAqbJhU05WSWD6HmHpAxLqs0LbFzQmKHNaDUg2kHkZBQ@mail.gmail.com> (Tilman Vogel's message of "Tue, 23 Feb 2021 22:50:09 +0100")
Tilman Vogel <tilman.vogel@web.de> writes:
> Because of an empty line in the input file, my script
>
> cat remove.txt | sed 's/origin\///' | xargs -d '\n' git push origin --delete
>
> executed (among other deletions) an implicit `git push origin --delete
> ""`. I wonder, what that one is supposed to do.
It is supposed to error out, but incorrectly and silently turns
itself into a "matching push".
This should fix it, I think (not even compiled tested).
builtin/push.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git c/builtin/push.c w/builtin/push.c
index 03adb58602..194967ed79 100644
--- c/builtin/push.c
+++ w/builtin/push.c
@@ -115,7 +115,7 @@ static void set_refspecs(const char **refs, int nr, const char *repo)
else
refspec_appendf(&rs, "refs/tags/%s", ref);
} else if (deleterefs) {
- if (strchr(ref, ':'))
+ if (strchr(ref, ':') || !*ref)
die(_("--delete only accepts plain target ref names"));
refspec_appendf(&rs, ":%s", ref);
} else if (!strchr(ref, ':')) {
prev parent reply other threads:[~2021-02-23 22:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-23 21:50 What does `git push origin --delete ""` do? Tilman Vogel
2021-02-23 22:46 ` Junio C Hamano [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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqa6ru1jxg.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=tilman.vogel@web.de \
/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.
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).