summaryrefslogtreecommitdiff
path: root/t/lib-httpd/apply-one-time-sed.sh
diff options
context:
space:
mode:
authorLibravatar Brandon Williams <bmwill@google.com>2018-06-27 15:30:18 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-06-28 09:33:29 -0700
commit3374292e55564fa6107b31a63a5e5432cd8c2265 (patch)
tree237b8f0fdc0addc8d3284ecbc9c6934ac0e010b8 /t/lib-httpd/apply-one-time-sed.sh
parentupload-pack: implement ref-in-want (diff)
downloadtgif-3374292e55564fa6107b31a63a5e5432cd8c2265.tar.xz
upload-pack: test negotiation with changing repository
Add tests to check the behavior of fetching from a repository which changes between rounds of negotiation (for example, when different servers in a load-balancing agreement participate in the same stateless RPC negotiation). This forms a baseline of comparison to the ref-in-want functionality (which will be introduced to the client in subsequent commits), and ensures that subsequent commits do not change existing behavior. As part of this effort, a mechanism to substitute strings in a single HTTP response is added. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/lib-httpd/apply-one-time-sed.sh')
-rw-r--r--t/lib-httpd/apply-one-time-sed.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/lib-httpd/apply-one-time-sed.sh b/t/lib-httpd/apply-one-time-sed.sh
new file mode 100644
index 0000000000..fcef728925
--- /dev/null
+++ b/t/lib-httpd/apply-one-time-sed.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# If "one-time-sed" exists in $HTTPD_ROOT_PATH, run sed on the HTTP response,
+# using the contents of "one-time-sed" as the sed command to be run. If the
+# response was modified as a result, delete "one-time-sed" so that subsequent
+# HTTP responses are no longer modified.
+#
+# This can be used to simulate the effects of the repository changing in
+# between HTTP request-response pairs.
+if [ -e one-time-sed ]; then
+ "$GIT_EXEC_PATH/git-http-backend" >out
+ sed "$(cat one-time-sed)" <out >out_modified
+
+ if diff out out_modified >/dev/null; then
+ cat out
+ else
+ cat out_modified
+ rm one-time-sed
+ fi
+else
+ "$GIT_EXEC_PATH/git-http-backend"
+fi