{"thread":{"id":"55197","subject":"What does `git push origin --delete \"\"` do?","startedAt":"2021-02-23T21:51:24Z","lastAt":"2021-02-23T22:51:53Z","messageCount":2,"participants":["Tilman Vogel","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"417624","messageId":"CAAbQbbCAqbJhU05WSWD6HmHpAxLqs0LbFzQmKHNaDUg2kHkZBQ@mail.gmail.com","threadId":"55197","inReplyTo":null,"subject":"What does `git push origin --delete \"\"` do?","fromName":"Tilman Vogel","fromEmail":"tilman.vogel@web.de","sentAt":"2021-02-23T21:50:09Z","receivedAt":"2021-02-23T21:51:24Z","isPatch":false,"sender":{"key":"tilman.vogel@web.de","avatar":"https://avatars.githubusercontent.com/u/349303?v=4"},"body":"Hi!\n\nBecause of an empty line in the input file, my script\n\ncat remove.txt | sed 's/origin\\///' | xargs -d '\\n' git push origin --delete\n\nexecuted (among other deletions) an implicit `git push origin --delete\n\"\"`. I wonder, what that one is supposed to do. I think, it should\nproduce an error just as `git push origin --delete` without a further\nargument does but it doesn't. It seemed like instead, it tried to push\nall my local branches to origin!? Is this something that should get\nfixed?\n\nBest regards,\n\nTilman\n"},{"id":"417628","messageId":"xmqqa6ru1jxg.fsf@gitster.g","threadId":"55197","inReplyTo":"CAAbQbbCAqbJhU05WSWD6HmHpAxLqs0LbFzQmKHNaDUg2kHkZBQ@mail.gmail.com","subject":"Re: What does `git push origin --delete \"\"` do?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-23T22:46:51Z","receivedAt":"2021-02-23T22:51:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tilman Vogel <tilman.vogel@web.de> writes:\n\n> Because of an empty line in the input file, my script\n>\n> cat remove.txt | sed 's/origin\\///' | xargs -d '\\n' git push origin --delete\n>\n> executed (among other deletions) an implicit `git push origin --delete\n> \"\"`. I wonder, what that one is supposed to do.\n\nIt is supposed to error out, but incorrectly and silently turns\nitself into a \"matching push\".\n\nThis should fix it, I think (not even compiled tested).\n\n builtin/push.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git c/builtin/push.c w/builtin/push.c\nindex 03adb58602..194967ed79 100644\n--- c/builtin/push.c\n+++ w/builtin/push.c\n@@ -115,7 +115,7 @@ static void set_refspecs(const char **refs, int nr, const char *repo)\n \t\t\telse\n \t\t\t\trefspec_appendf(&rs, \"refs/tags/%s\", ref);\n \t\t} else if (deleterefs) {\n-\t\t\tif (strchr(ref, ':'))\n+\t\t\tif (strchr(ref, ':') || !*ref)\n \t\t\t\tdie(_(\"--delete only accepts plain target ref names\"));\n \t\t\trefspec_appendf(&rs, \":%s\", ref);\n \t\t} else if (!strchr(ref, ':')) {\n"}]}