This cgi script can list Git objects that have been uploaded as files to an apache web server. This script can also retrieve the content of each of these files. This will help make apache work as an external object database. Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx> --- t/lib-httpd.sh | 1 + t/lib-httpd/list.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 t/lib-httpd/list.sh diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index d80b004549..f31ea261f5 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -133,6 +133,7 @@ prepare_httpd() { install_script broken-smart-http.sh install_script error.sh install_script upload.sh + install_script list.sh ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules" diff --git a/t/lib-httpd/list.sh b/t/lib-httpd/list.sh new file mode 100644 index 0000000000..7e520e507a --- /dev/null +++ b/t/lib-httpd/list.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +FILES_DIR="www/files" + +OLDIFS="$IFS" +IFS='&' +set -- $QUERY_STRING +IFS="$OLDIFS" + +while test $# -gt 0 +do + key=${1%=*} + val=${1#*=} + + case "$key" in + "sha1") sha1="$val" ;; + *) echo >&2 "unknown key '$key'" ;; + esac + + shift +done + +if test -d "$FILES_DIR" +then + if test -z "$sha1" + then + echo 'Status: 200 OK' + echo + ls "$FILES_DIR" | tr '-' ' ' + else + if test -f "$FILES_DIR/$sha1"-* + then + echo 'Status: 200 OK' + echo + cat "$FILES_DIR/$sha1"-* + else + echo 'Status: 404 Not Found' + echo + fi + fi +fi -- 2.14.0.rc1.52.gf02fb0ddac.dirty