git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: What does `git push origin --delete ""` do?

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 23, 2021, 22:46 UTC
Message-ID
<xmqqa6ru1jxg.fsf@gitster.g>
In-Reply-To
<CAAbQbbCAqbJhU05WSWD6HmHpAxLqs0LbFzQmKHNaDUg2kHkZBQ@mail.gmail.com>
Tilman Vogel <tilman.vogel@web.de> writes:
Show 6 quoted lines
> 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, ':')) {
Previous: Tilman Vogel
Message 2 of 2 in “What does `git push origin --delete ""` do?”
  1. Tilman VogelFeb 23, 2021
  2. Junio C HamanoFeb 23, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.