diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-10-19 04:57:35 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-10-19 06:13:32 (GMT) |
commit | b072a25fad21b8aecfa29f6ffb813a0a6194a764 (patch) | |
tree | 361e7cb31b42f55f584a1b41e8c750580d5b4e19 /t/t5516-fetch-push.sh | |
parent | 268fbcd172cdb306e8a3e7143cc16677c963d6cd (diff) | |
download | git-b072a25fad21b8aecfa29f6ffb813a0a6194a764.zip git-b072a25fad21b8aecfa29f6ffb813a0a6194a764.tar.gz git-b072a25fad21b8aecfa29f6ffb813a0a6194a764.tar.bz2 |
receive: denyCurrentBranch=updateinstead should not blindly update
The handling of receive.denyCurrentBranch=updateInstead was added to
a switch statement that handles other values of the variable, but
all the other case arms only checked a condition to reject the
attempted push, or let later logic in the same function to still
intervene, so that a push that does not fast-forward (which is
checked after the switch statement in question) is still rejected.
But the handling of updateInstead incorrectly took immediate effect,
without giving other checks a chance to intervene.
Instead of calling update_worktree() that causes the side effect
immediately, just note the fact that we will need to call the
function later, and first give other checks a chance to reject the
request. After the update-hook gets a chance to reject the push
(which happens as the last step in a series of checks), call
update_worktree() when we earlier detected the need to.
Reported-by: Rajesh Madamanchi
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5516-fetch-push.sh')
-rwxr-xr-x | t/t5516-fetch-push.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index a5077d8..1a67f47 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1527,7 +1527,13 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' test $(git -C .. rev-parse master) = $(git rev-parse HEAD) && git diff --quiet && git diff --cached --quiet - ) + ) && + + # (6) updateInstead intervened by fast-forward check + test_must_fail git push void master^:master && + test $(git -C void rev-parse HEAD) = $(git rev-parse master) && + git -C void diff --quiet && + git -C void diff --cached --quiet ' test_expect_success 'updateInstead with push-to-checkout hook' ' |