summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2016-11-30 22:04:17 +0100
committerJunio C Hamano <gitster@pobox.com>2016-12-01 14:55:33 -0800
commita642c80ef66d61447358ced8e2bdc32472e53143 (patch)
tree3a4bf4123eb514f603fe08d5a1c85063517a2d2d
parent04d5b4b053400e732710955c30ea03d2139548a2 (diff)
downloadgit-a642c80ef66d61447358ced8e2bdc32472e53143.tar.gz
lib-httpd: add list.sh
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@tuxfamily.org>
-rw-r--r--t/lib-httpd.sh1
-rw-r--r--t/lib-httpd/list.sh34
2 files changed, 35 insertions, 0 deletions
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..a54402558f
--- /dev/null
+++ b/t/lib-httpd/list.sh
@@ -0,0 +1,34 @@
+#!/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
+
+echo 'Status: 200 OK'
+echo
+
+if test -d "$FILES_DIR"
+then
+ if test -n "$sha1"
+ then
+ cat "$FILES_DIR/$sha1"-*
+ else
+ ls "$FILES_DIR" | tr '-' ' '
+ fi
+fi