Skip to content

Commit

Permalink
Merge branch 'jc/push-delete-nothing'
Browse files Browse the repository at this point in the history
"git push $there --delete ''" should have been diagnosed as an
error, but instead turned into a matching push, which has been
corrected.

* jc/push-delete-nothing:
  push: do not turn --delete '' into a matching push
  • Loading branch information
gitster committed Feb 26, 2021
2 parents cadae71 + 20e4164 commit 1400458
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/push.c
Expand Up @@ -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, ':')) {
Expand Down
5 changes: 5 additions & 0 deletions t/t5516-fetch-push.sh
Expand Up @@ -820,6 +820,11 @@ test_expect_success 'push --delete refuses src:dest refspecs' '
test_must_fail git push testrepo --delete main:foo
'

test_expect_success 'push --delete refuses empty string' '
mk_test testrepo heads/master &&
test_must_fail git push testrepo --delete ""
'

test_expect_success 'warn on push to HEAD of non-bare repository' '
mk_test testrepo heads/main &&
(
Expand Down

0 comments on commit 1400458

Please sign in to comment.