Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/lib-httpd/apply-one-time-script.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / lib-httpd / apply-one-time-script.sh` 36 lines ยท 1247 bytes Raw Blame History 1 #!/bin/sh 2 3 # If "one-time-script" exists in $HTTPD_ROOT_PATH, run the script on the HTTP 4 # response. If the response was modified as a result, delete "one-time-script" 5 # so that subsequent HTTP responses are no longer modified. 6 # 7 # This can be used to simulate the effects of the repository changing in 8 # between HTTP request-response pairs. 9 test -f one-time-script || exec "$GIT_EXEC_PATH/git-http-backend" 10 11 LC_ALL=C 12 export LC_ALL 13 14 out=out.$$ 15 modified=out-modified.$$ 16 "$GIT_EXEC_PATH/git-http-backend" >"$out" 17 18 # Since Apache can execute this script for multiple requests 19 # concurrently, we chain "rm one-time-script" with the logic 20 # for generating a modified response. If the "rm" ran separately, 21 # a concurrent request could pass the "test -f" above and 22 # erroneously result in multiple modified responses or an empty 23 # body depending on the race state. 24 # 25 # We discard stderr for ./one-time-script since it is possible 26 # ./one-time-script has been removed already, which is expected 27 # sometimes. In this case, the unmodified response will be returned. 28 if ./one-time-script "$out" 2>/dev/null >"$modified" && 29 ! cmp -s "$out" "$modified" && 30 rm one-time-script 2>/dev/null 31 then 32 cat "$modified" 33 else 34 cat "$out" 35 fi 36 rm -f "$out" "$modified"