aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--builtin/push.c2
-rwxr-xr-xt/t5516-fetch-push.sh5
2 files changed, 6 insertions, 1 deletions
diff --git a/builtin/push.c b/builtin/push.c
index 6da3a8e5d3..da34524e6f 100644
--- a/builtin/push.c
+++ b/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, ':')) {
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index d11382f769..bf0d295d80 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -818,6 +818,11 @@ test_expect_success 'push --delete refuses src:dest refspecs' '
test_must_fail git push testrepo --delete master: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/master &&
(