summaryrefslogtreecommitdiff
path: root/t/t5516-fetch-push.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-03-31 23:15:45 -0700
committerJunio C Hamano <gitster@pobox.com>2015-04-01 22:40:10 -0700
commit1a51b52422e055e433dec9a496621341d70d38ff (patch)
tree771ce6613ff70e626aeaaaf137ba7a8019b7b679 /t/t5516-fetch-push.sh
parent0855331941b723b227e93b33955bbe0b45025659 (diff)
downloadgit-1a51b52422e055e433dec9a496621341d70d38ff.tar.gz
push-to-deploy: allow pushing into an unborn branch and updating itjc/update-instead-into-void
Setting receive.denycurrentbranch to updateinstead and pushing into the current branch, when the working tree and the index is truly clean, is supposed to reset the working tree and the index to match the tree of the pushed commit. This did not work when pushing into an unborn branch. The code that drives push-to-checkout hook needs no change, as the interface is defined so that hook can decide what to do when the push is coming to an unborn branch and take an appropriate action since the beginning. Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5516-fetch-push.sh')
-rwxr-xr-xt/t5516-fetch-push.sh55
1 files changed, 54 insertions, 1 deletions
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index e4436c1700..4f659d949b 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1430,8 +1430,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' '
@@ -1494,6 +1508,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)
)
'