summaryrefslogtreecommitdiff
path: root/t/lib-httpd.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-09-09 21:30:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-09-09 21:30:29 (GMT)
commit2233ad4534db8a37b1bf726312d52d4a0a51db0a (patch)
treea13884a1de77eb61ef89f9b3f780553c6b2a3225 /t/lib-httpd.sh
parent711b2769740637e228c8200927e96b31f2065d32 (diff)
parent05c1eb10348f159908becc7a6ed6bbcdab24c893 (diff)
downloadgit-2233ad4534db8a37b1bf726312d52d4a0a51db0a.zip
git-2233ad4534db8a37b1bf726312d52d4a0a51db0a.tar.gz
git-2233ad4534db8a37b1bf726312d52d4a0a51db0a.tar.bz2
Merge branch 'jc/push-cas'
Allow a safer "rewind of the remote tip" push than blind "--force", by requiring that the overwritten remote ref to be unchanged since the new history to replace it was prepared. The machinery is more or less ready. The "--force" option is again the big red button to override any safety, thanks to J6t's sanity (the original round allowed --lockref to defeat --force). The logic to choose the default implemented here is fragile (e.g. "git fetch" after seeing a failure will update the remote-tracking branch and will make the next "push" pass, defeating the safety pretty easily). It is suitable only for the simplest workflows, and it may hurt users more than it helps them. * jc/push-cas: push: teach --force-with-lease to smart-http transport send-pack: fix parsing of --force-with-lease option t5540/5541: smart-http does not support "--force-with-lease" t5533: test "push --force-with-lease" push --force-with-lease: tie it all together push --force-with-lease: implement logic to populate old_sha1_expect[] remote.c: add command line option parser for "--force-with-lease" builtin/push.c: use OPT_BOOL, not OPT_BOOLEAN cache.h: move remote/connect API out of it
Diffstat (limited to 't/lib-httpd.sh')
-rw-r--r--t/lib-httpd.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 895b925..dab405d 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -141,10 +141,11 @@ stop_httpd() {
-f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop
}
-test_http_push_nonff() {
+test_http_push_nonff () {
REMOTE_REPO=$1
LOCAL_REPO=$2
BRANCH=$3
+ EXPECT_CAS_RESULT=${4-failure}
test_expect_success 'non-fast-forward push fails' '
cd "$REMOTE_REPO" &&
@@ -167,6 +168,22 @@ test_http_push_nonff() {
test_expect_success 'non-fast-forward push shows help message' '
test_i18ngrep "Updates were rejected because" output
'
+
+ test_expect_failure 'force with lease aka cas' '
+ HEAD=$( cd "$REMOTE_REPO" && git rev-parse --verify HEAD ) &&
+ test_when_finished '\''
+ (cd "$REMOTE_REPO" && git update-ref HEAD "$HEAD")
+ '\'' &&
+ (
+ cd "$LOCAL_REPO" &&
+ git push -v --force-with-lease=$BRANCH:$HEAD origin
+ ) &&
+ git rev-parse --verify "$BRANCH" >expect &&
+ (
+ cd "$REMOTE_REPO" && git rev-parse --verify HEAD
+ ) >actual &&
+ test_cmp expect actual
+ '
}
setup_askpass_helper() {