aboutsummaryrefslogtreecommitdiff
path: root/t/t5516-fetch-push.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2014-11-26 23:44:16 +0100
committerJunio C Hamano <gitster@pobox.com>2014-11-30 17:15:13 -0800
commit1404bcbb6b3bdb248d32024430644e55faec91ce (patch)
treed02bc43daffcc76e8fc33aa4f5d13cfafca4a9f4 /t/t5516-fetch-push.sh
parent66edfe9ddc29102fa39edd37f9aecccbaca6a013 (diff)
downloadgit-1404bcbb6b3bdb248d32024430644e55faec91ce.tar.gz
git-1404bcbb6b3bdb248d32024430644e55faec91ce.tar.xz
receive-pack: add another option for receive.denyCurrentBranch
When synchronizing between working directories, it can be handy to update the current branch via 'push' rather than 'pull', e.g. when pushing a fix from inside a VM, or when pushing a fix made on a user's machine (where the developer is not at liberty to install an ssh daemon let alone know the user's password). The common workaround – pushing into a temporary branch and then merging on the other machine – is no longer necessary with this patch. The new option is: 'updateInstead': Update the working tree accordingly, but refuse to do so if there are any uncommitted changes. Signed-off-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.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index f4da20aa9..7b353d0b8 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1330,4 +1330,30 @@ test_expect_success 'fetch into bare respects core.logallrefupdates' '
)
'
+test_expect_success 'receive.denyCurrentBranch = updateInstead' '
+ git push testrepo master &&
+ (cd testrepo &&
+ git reset --hard &&
+ git config receive.denyCurrentBranch updateInstead
+ ) &&
+ test_commit third path2 &&
+ git push testrepo master &&
+ test $(git rev-parse HEAD) = $(cd testrepo && git rev-parse HEAD) &&
+ test third = "$(cat testrepo/path2)" &&
+ (cd testrepo &&
+ git update-index -q --refresh &&
+ git diff-files --quiet -- &&
+ git diff-index --quiet --cached HEAD -- &&
+ echo changed >path2 &&
+ git add path2
+ ) &&
+ test_commit fourth path2 &&
+ test_must_fail git push testrepo master &&
+ test $(git rev-parse HEAD^) = $(git -C testrepo rev-parse HEAD) &&
+ (cd testrepo &&
+ git diff --quiet &&
+ test changed = "$(cat path2)"
+ )
+'
+
test_done