diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-07-06 11:36:35 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-06 15:43:37 -0700 |
commit | f2f60a5935e3673e6df2a45b25c961587d9a2186 (patch) | |
tree | bb233b5cde90ce1483d434f0acaca6d2e26e1b69 /t | |
parent | 50ff9ea4a0770c8b1bfe3f98f09728427c0c6cc7 (diff) | |
download | git-jc/allow-lazy-cas.tar.gz |
push: disable lazy --force-with-lease by defaultjc/allow-lazy-cas
"git push --force-with-lease=<branch>:<expect>" makes sure that
there is no unexpected changes to the branch at the remote while you
prepare a rewrite based on the old state of the branch. This
feature came with an experimental option that allows :<expect> part
to be omitted by using the tip of remote-tracking branch that
corresponds to the <branch>.
It turns out that some people use third-party tools that fetch from
remote and update the remote-tracking branches behind users' back,
defeating the safety that relies on the stability of the remote-tracking
branches. We have some warning text that was meant to sound scary
in our documentation, but nevertheless people seem to be bitten. See
https://public-inbox.org/git/1491617750.2149.10.camel@mattmccutchen.net/
for a recent example.
Let's disable the forms that rely on the stability of remote-tracking
branches by default, and allow users who _know_ their remote-tracking
branches are stable to enable it with a configuration variable.
This problem was predicted from the very beginning; see 28f5d176
(remote.c: add command line option parser for "--force-with-lease",
2013-07-08).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t5533-push-cas.sh | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/t/t5533-push-cas.sh b/t/t5533-push-cas.sh index d38ecee217..4269058c89 100755 --- a/t/t5533-push-cas.sh +++ b/t/t5533-push-cas.sh @@ -17,7 +17,8 @@ test_expect_success setup ' # create template repository test_commit A && test_commit B && - test_commit C + test_commit C && + git config --global push.allowLazyForceWithLease true ' test_expect_success 'push to update (protected)' ' @@ -91,6 +92,7 @@ test_expect_success 'push to update (allowed)' ' ( cd dst && test_commit D && + git config push.allowLazyForceWithLease false && git push --force-with-lease=master:master^ origin master ) && git ls-remote dst refs/heads/master >expect && @@ -103,6 +105,10 @@ test_expect_success 'push to update (allowed, tracking)' ' ( cd dst && test_commit D && + git config push.allowLazyForceWithLease false && + test_must_fail git push --force-with-lease=master origin master 2>err && + grep "lazy force-with-lease" err && + git config --unset push.allowLazyForceWithLease && git push --force-with-lease=master origin master 2>err && ! grep "forced update" err ) && @@ -151,6 +157,10 @@ test_expect_success 'push to delete (allowed)' ' setup_srcdst_basic && ( cd dst && + git config push.allowLazyForceWithLease false && + test_must_fail git push --force-with-lease=master origin :master 2>err && + grep "lazy force-with-lease" err && + git config --unset push.allowLazyForceWithLease && git push --force-with-lease=master origin :master 2>err && grep deleted err ) && @@ -183,6 +193,9 @@ test_expect_success 'cover everything with default force-with-lease (allowed)' ' ( cd dst && git fetch && + git config push.allowLazyForceWithLease false && + test_must_fail git push --force-with-lease origin master master:naster && + git config --unset push.allowLazyForceWithLease && git push --force-with-lease origin master master:naster ) && git ls-remote dst refs/heads/master | @@ -196,6 +209,9 @@ test_expect_success 'new branch covered by force-with-lease' ' ( cd dst && git branch branch master && + git config push.allowLazyForceWithLease false && + test_must_fail git push --force-with-lease=branch origin branch && + git config --unset push.allowLazyForceWithLease && git push --force-with-lease=branch origin branch ) && git ls-remote dst refs/heads/branch >expect && |