summaryrefslogtreecommitdiff
path: root/t/t5516-fetch-push.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-02-23 23:13:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-02-23 23:19:34 (GMT)
commit20e416409fc2bc260faf65a0fc74927ed0d3ca12 (patch)
treea8012d82b6ea04b43bfb95c04439a7aa01e386bf /t/t5516-fetch-push.sh
parent898f80736c75878acc02dc55672317fcc0e0a5a6 (diff)
downloadgit-20e416409fc2bc260faf65a0fc74927ed0d3ca12.zip
git-20e416409fc2bc260faf65a0fc74927ed0d3ca12.tar.gz
git-20e416409fc2bc260faf65a0fc74927ed0d3ca12.tar.bz2
push: do not turn --delete '' into a matching push
When we added a syntax sugar "git push remote --delete <ref>" to "git push" as a synonym to the canonical "git push remote :<ref>" syntax at f517f1f2 (builtin-push: add --delete as syntactic sugar for :foo, 2009-12-30), we weren't careful enough to make sure that <ref> is not empty. Blindly rewriting "--delete <ref>" to ":<ref>" means that an empty string <ref> results in refspec ":", which is the syntax to ask for "matching" push that does not delete anything. Worse yet, if there were matching refs that can be fast-forwarded, they would have been published prematurely, even if the user feels that they are not ready yet to be pushed out, which would be a real disaster. Noticed-by: Tilman Vogel <tilman.vogel@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5516-fetch-push.sh')
-rwxr-xr-xt/t5516-fetch-push.sh5
1 files changed, 5 insertions, 0 deletions
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index d11382f..bf0d295 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 &&
(