diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-04-14 11:49:10 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-14 11:49:10 -0700 |
commit | fa9aaa8f1051bd7b0cd437a5006898277ec42805 (patch) | |
tree | c61245e041ea4e0bdcf2c4cd09555ae5bc324b82 /t/t5516-fetch-push.sh | |
parent | d2ae751b1cae0674e0a1f7fe4da0a341365cefbb (diff) | |
parent | 1a51b52422e055e433dec9a496621341d70d38ff (diff) | |
download | git-fa9aaa8f1051bd7b0cd437a5006898277ec42805.tar.gz |
Merge branch 'jc/update-instead-into-void'
A push into an unborn branch, with "receive.denyCurrentBranch" set
to "updateInstead", did not check out the working tree as expected.
* jc/update-instead-into-void:
push-to-deploy: allow pushing into an unborn branch and updating it
Diffstat (limited to 't/t5516-fetch-push.sh')
-rwxr-xr-x | t/t5516-fetch-push.sh | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 5e04d64109..8a5f2363a9 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1437,8 +1437,22 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' test $(git -C .. rev-parse HEAD^^) = $(git rev-parse HEAD) && git diff --quiet && test fifth = "$(cat path3)" - ) + ) && + # (5) push into void + rm -fr void && + git init void && + ( + cd void && + git config receive.denyCurrentBranch updateInstead + ) && + git push void master && + ( + cd void && + test $(git -C .. rev-parse master) = $(git rev-parse HEAD) && + git diff --quiet && + git diff --cached --quiet + ) ' test_expect_success 'updateInstead with push-to-checkout hook' ' @@ -1501,6 +1515,45 @@ test_expect_success 'updateInstead with push-to-checkout hook' ' test "$(cat path5)" = irrelevant && test "$(git diff --name-only --cached HEAD)" = path5 && test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) + ) && + + # push into void + rm -fr void && + git init void && + ( + cd void && + git config receive.denyCurrentBranch updateInstead && + write_script .git/hooks/push-to-checkout <<-\EOF + if git rev-parse --quiet --verify HEAD + then + has_head=yes + echo >&2 updating from $(git rev-parse HEAD) + else + has_head=no + echo >&2 pushing into void + fi + echo >&2 updating to "$1" + + git update-index -q --refresh && + case "$has_head" in + yes) + git read-tree -u -m HEAD "$1" ;; + no) + git read-tree -u -m "$1" ;; + esac || { + status=$? + echo >&2 read-tree failed + exit $status + } + EOF + ) && + + git push void master && + ( + cd void && + git diff --quiet && + git diff --cached --quiet && + test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) ) ' |