Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t/t5411
diff options
context:
space:
mode:
authorJiang Xin <zhiyou.jx@alibaba-inc.com>2020-08-27 18:45:46 +0300
committerJunio C Hamano <gitster@pobox.com>2020-08-27 22:47:47 +0300
commit63518a574a3a4b8c6f152b29cb1b6d1f66f6e6c7 (patch)
treea967d86e5cecce2b80e1b529afd8ef6aa66ff7d8 /t/t5411
parent195d6eaea3b886fe13f422ce6675009ea1351224 (diff)
New capability "report-status-v2" for git-push
The new introduced "proc-receive" hook may handle a command for a pseudo-reference with a zero-old as its old-oid, while the hook may create or update a reference with different name, different new-oid, and different old-oid (the reference may exist already with a non-zero old-oid). Current "report-status" protocol cannot report the status for such reference rewrite. Add new capability "report-status-v2" and new report protocol which is not backward compatible for report of git-push. If a user pushes to a pseudo-reference "refs/for/master/topic", and "receive-pack" creates two new references "refs/changes/23/123/1" and "refs/changes/24/124/1", for client without the knowledge of "report-status-v2", "receive-pack" will only send "ok/ng" directives in the report, such as: ok ref/for/master/topic But for client which has the knowledge of "report-status-v2", "receive-pack" will use "option" directives to report more attributes for the reference given by the above "ok/ng" directive. ok refs/for/master/topic option refname refs/changes/23/123/1 option new-oid <new-oid> ok refs/for/master/topic option refname refs/changes/24/124/1 option new-oid <new-oid> The client will report two new created references to the end user. Suggested-by: Junio C Hamano <gitster@pobox.com> Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5411')
-rw-r--r--t/t5411/once-0010-report-status-v1.sh90
-rw-r--r--t/t5411/test-0032-report-with-options.sh14
-rw-r--r--t/t5411/test-0033-report-with-options--porcelain.sh14
-rw-r--r--t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh11
-rw-r--r--t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh11
-rw-r--r--t/t5411/test-0038-report-mixed-refs.sh2
-rw-r--r--t/t5411/test-0039-report-mixed-refs--porcelain.sh2
7 files changed, 122 insertions, 22 deletions
diff --git a/t/t5411/once-0010-report-status-v1.sh b/t/t5411/once-0010-report-status-v1.sh
new file mode 100644
index 0000000000..bf410dc418
--- /dev/null
+++ b/t/t5411/once-0010-report-status-v1.sh
@@ -0,0 +1,90 @@
+test_expect_success "setup proc-receive hook" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v \
+ -r "ok refs/for/master/topic1" \
+ -r "option fall-through" \
+ -r "ok refs/for/master/topic2" \
+ -r "option refname refs/for/changes/23/123/1" \
+ -r "option new-oid $A" \
+ -r "ok refs/for/master/topic2" \
+ -r "option refname refs/for/changes/24/124/2" \
+ -r "option old-oid $B" \
+ -r "option new-oid $A" \
+ -r "option forced-update" \
+ -r "ng refs/for/next/topic target branch not exist"
+ EOF
+'
+
+# Refs of upstream : master(A)
+# Refs of workbench: master(A) tags/v123
+# git push : (B) refs/for/master/topic1(A) foo(A) refs/for/next/topic(A) refs/for/master/topic2(A)
+test_expect_success "proc-receive: report status v1" '
+ {
+ if test -z "$GIT_DEFAULT_HASH" || test "$GIT_DEFAULT_HASH" = "sha1"
+ then
+ printf "%s %s refs/heads/master\0report-status\n" \
+ $A $B | packetize
+ else
+ printf "%s %s refs/heads/master\0report-status object-format=$GIT_DEFAULT_HASH\n" \
+ $A $B | packetize
+ fi &&
+ printf "%s %s refs/for/master/topic1\n" \
+ $ZERO_OID $A | packetize &&
+ printf "%s %s refs/heads/foo\n" \
+ $ZERO_OID $A | packetize &&
+ printf "%s %s refs/for/next/topic\n" \
+ $ZERO_OID $A | packetize &&
+ printf "%s %s refs/for/master/topic2\n" \
+ $ZERO_OID $A | packetize &&
+ printf 0000 &&
+ printf "" | git -C "$upstream" pack-objects --stdout
+ } | git receive-pack "$upstream" --stateless-rpc \
+ >out 2>&1 &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ # pre-receive hook
+ pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
+ pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1
+ pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo
+ pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic
+ pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic2
+ # proc-receive hook
+ proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1
+ proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic
+ proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic2
+ proc-receive> ok refs/for/master/topic1
+ proc-receive> option fall-through
+ proc-receive> ok refs/for/master/topic2
+ proc-receive> option refname refs/for/changes/23/123/1
+ proc-receive> option new-oid <COMMIT-A>
+ proc-receive> ok refs/for/master/topic2
+ proc-receive> option refname refs/for/changes/24/124/2
+ proc-receive> option old-oid <COMMIT-B>
+ proc-receive> option new-oid <COMMIT-A>
+ proc-receive> option forced-update
+ proc-receive> ng refs/for/next/topic target branch not exist
+ 000eunpack ok
+ 0019ok refs/heads/master
+ 001eok refs/for/master/topic1
+ 0016ok refs/heads/foo
+ 0033ng refs/for/next/topic target branch not exist
+ 001eok refs/for/master/topic2
+ 0000# post-receive hook
+ post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
+ post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1
+ post-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo
+ post-receive< <ZERO-OID> <COMMIT-A> refs/for/changes/23/123/1
+ post-receive< <COMMIT-B> <COMMIT-A> refs/for/changes/24/124/2
+ EOF
+ test_cmp expect actual &&
+
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/for/master/topic1
+ <COMMIT-A> refs/heads/foo
+ <COMMIT-B> refs/heads/master
+ EOF
+ test_cmp expect actual
+'
diff --git a/t/t5411/test-0032-report-with-options.sh b/t/t5411/test-0032-report-with-options.sh
index c559c207fa..b77b78c49f 100644
--- a/t/t5411/test-0032-report-with-options.sh
+++ b/t/t5411/test-0032-report-with-options.sh
@@ -56,7 +56,7 @@ test_expect_success "proc-receive: report option refname ($PROTOCOL)" '
remote: # post-receive hook
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/master/topic
+ * [new reference] HEAD -> refs/pull/123/head
EOF
test_cmp expect actual
'
@@ -89,7 +89,7 @@ test_expect_success "proc-receive: report option refname and forced-update ($PRO
remote: # post-receive hook
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/master/topic
+ * [new reference] HEAD -> refs/pull/123/head
EOF
test_cmp expect actual
'
@@ -123,7 +123,7 @@ test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL)
remote: # post-receive hook
remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/123/head
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/master/topic
+ <OID-B>..<OID-A> HEAD -> refs/pull/123/head
EOF
test_cmp expect actual
'
@@ -155,7 +155,7 @@ test_expect_success "proc-receive: report option old-oid ($PROTOCOL)" '
remote: # post-receive hook
remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/master/topic
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/master/topic
+ <OID-B>..<OID-A> HEAD -> refs/for/master/topic
EOF
test_cmp expect actual
'
@@ -189,7 +189,7 @@ test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL)
remote: # post-receive hook
remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/master/topic
+ <OID-A>..<OID-B> HEAD -> refs/for/master/topic
EOF
test_cmp expect actual
'
@@ -241,9 +241,9 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" '
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic
remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/next/topic
+ * [new reference] HEAD -> refs/pull/123/head
* [new reference] HEAD -> refs/for/a/b/c/topic
- * [new reference] HEAD -> refs/for/master/topic
+ + <OID-B>...<OID-A> HEAD -> refs/pull/124/head (forced update)
EOF
test_cmp expect actual &&
diff --git a/t/t5411/test-0033-report-with-options--porcelain.sh b/t/t5411/test-0033-report-with-options--porcelain.sh
index ea9312234e..1fe352b686 100644
--- a/t/t5411/test-0033-report-with-options--porcelain.sh
+++ b/t/t5411/test-0033-report-with-options--porcelain.sh
@@ -57,7 +57,7 @@ test_expect_success "proc-receive: report option refname ($PROTOCOL/porcelain)"
remote: # post-receive hook
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head
To <URL/of/upstream.git>
- * HEAD:refs/for/master/topic [new reference]
+ * HEAD:refs/pull/123/head [new reference]
Done
EOF
test_cmp expect actual
@@ -92,7 +92,7 @@ test_expect_success "proc-receive: report option refname and forced-update ($PRO
remote: # post-receive hook
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head
To <URL/of/upstream.git>
- * HEAD:refs/for/master/topic [new reference]
+ * HEAD:refs/pull/123/head [new reference]
Done
EOF
test_cmp expect actual
@@ -127,7 +127,7 @@ test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL/
remote: # post-receive hook
remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/123/head
To <URL/of/upstream.git>
- * HEAD:refs/for/master/topic [new reference]
+ HEAD:refs/pull/123/head <OID-B>..<OID-A>
Done
EOF
test_cmp expect actual
@@ -160,7 +160,7 @@ test_expect_success "proc-receive: report option old-oid ($PROTOCOL/porcelain)"
remote: # post-receive hook
remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/master/topic
To <URL/of/upstream.git>
- * HEAD:refs/for/master/topic [new reference]
+ HEAD:refs/for/master/topic <OID-B>..<OID-A>
Done
EOF
test_cmp expect actual
@@ -195,7 +195,7 @@ test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL/
remote: # post-receive hook
remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic
To <URL/of/upstream.git>
- * HEAD:refs/for/master/topic [new reference]
+ HEAD:refs/for/master/topic <OID-A>..<OID-B>
Done
EOF
test_cmp expect actual
@@ -249,9 +249,9 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porc
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic
remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head
To <URL/of/upstream.git>
- * HEAD:refs/for/next/topic [new reference]
+ * HEAD:refs/pull/123/head [new reference]
* HEAD:refs/for/a/b/c/topic [new reference]
- * HEAD:refs/for/master/topic [new reference]
+ + HEAD:refs/pull/124/head <OID-B>...<OID-A> (forced update)
Done
EOF
test_cmp expect actual &&
diff --git a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh
index 67cc4a8a4c..27d58edd14 100644
--- a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh
+++ b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh
@@ -45,7 +45,9 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1
remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/master/topic
+ <OID-A>..<OID-B> HEAD -> refs/for/master/topic
+ * [new reference] HEAD -> refs/changes/24/124/1
+ <OID-A>..<OID-B> HEAD -> refs/changes/25/125/1
EOF
test_cmp expect actual &&
git -C "$upstream" show-ref >out &&
@@ -105,7 +107,9 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for
remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic
remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/master/topic
+ * [new reference] HEAD -> refs/changes/24/124/1
+ <OID-A>..<OID-B> HEAD -> refs/for/master/topic
+ + <OID-B>...<OID-A> HEAD -> refs/changes/25/125/1 (forced update)
EOF
test_cmp expect actual &&
git -C "$upstream" show-ref >out &&
@@ -152,7 +156,8 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" '
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/23/123/1
remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/24/124/2
To <URL/of/upstream.git>
- * [new reference] HEAD -> refs/for/master/topic
+ * [new reference] HEAD -> refs/changes/23/123/1
+ <OID-A>..<OID-B> HEAD -> refs/changes/24/124/2
EOF
test_cmp expect actual &&
git -C "$upstream" show-ref >out &&
diff --git a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh
index 1dc8551bc6..77b5b22ed4 100644
--- a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh
+++ b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh
@@ -45,7 +45,9 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1
remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1
To <URL/of/upstream.git>
- * HEAD:refs/for/master/topic [new reference]
+ HEAD:refs/for/master/topic <OID-A>..<OID-B>
+ * HEAD:refs/changes/24/124/1 [new reference]
+ HEAD:refs/changes/25/125/1 <OID-A>..<OID-B>
Done
EOF
test_cmp expect actual &&
@@ -106,7 +108,9 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for
remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic
remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1
To <URL/of/upstream.git>
- * HEAD:refs/for/master/topic [new reference]
+ * HEAD:refs/changes/24/124/1 [new reference]
+ HEAD:refs/for/master/topic <OID-A>..<OID-B>
+ + HEAD:refs/changes/25/125/1 <OID-B>...<OID-A> (forced update)
Done
EOF
test_cmp expect actual &&
@@ -154,7 +158,8 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porc
remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/23/123/1
remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/24/124/2
To <URL/of/upstream.git>
- * HEAD:refs/for/master/topic [new reference]
+ * HEAD:refs/changes/23/123/1 [new reference]
+ HEAD:refs/changes/24/124/2 <OID-A>..<OID-B>
Done
EOF
test_cmp expect actual &&
diff --git a/t/t5411/test-0038-report-mixed-refs.sh b/t/t5411/test-0038-report-mixed-refs.sh
index bfc8d586d6..a74a2cb449 100644
--- a/t/t5411/test-0038-report-mixed-refs.sh
+++ b/t/t5411/test-0038-report-mixed-refs.sh
@@ -60,7 +60,7 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" '
* [new branch] HEAD -> baz
* [new reference] HEAD -> refs/for/next/topic2
* [new branch] HEAD -> foo
- * [new reference] HEAD -> refs/for/master/topic
+ <OID-A>..<OID-B> HEAD -> refs/for/master/topic
! [remote rejected] HEAD -> refs/for/next/topic1 (fail to call Web API)
! [remote rejected] HEAD -> refs/for/next/topic3 (proc-receive failed to report status)
EOF
diff --git a/t/t5411/test-0039-report-mixed-refs--porcelain.sh b/t/t5411/test-0039-report-mixed-refs--porcelain.sh
index 5d021a4837..e4baa13ea3 100644
--- a/t/t5411/test-0039-report-mixed-refs--porcelain.sh
+++ b/t/t5411/test-0039-report-mixed-refs--porcelain.sh
@@ -60,7 +60,7 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel
* HEAD:refs/heads/baz [new branch]
* HEAD:refs/for/next/topic2 [new reference]
* HEAD:refs/heads/foo [new branch]
- * HEAD:refs/for/master/topic [new reference]
+ HEAD:refs/for/master/topic <OID-A>..<OID-B>
! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API)
! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status)
Done