* Re: suppress fatal pathspec errors from "git add"?
From: Junio C Hamano @ 2010-01-03 8:12 UTC (permalink / raw)
To: Jeff King; +Cc: aaron smith, git
In-Reply-To: <20100103074058.GB23031@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> ... I could see it
> if your workflow were something like "in a script, add these N files if
> they exist, but it is not an error if they don't". But I still don't
> think you would want to ignore all errors; you would want to do
> something like:
>
> $ git add $(for i in foo bar baz; do test -e $i && echo $i; done)
>
> instead. Am I missing something?
If your primary activity that happens in the work tree were:
while :
do
file=$(date +"random-%H%M%S")
>"$file"
rm -f "$file"
done
and your add were done in
while sleep 3600
do
git add $(for i in *; do test -e $i && echo $i; done)
git commit -m "hourly snapshot"
done
totally asynchronously without coordinating with what the primary activity
is doing, your "test -e && echo" can race with a concurrent "rm".
Even though I think it is an insane use pattern that we shouldn't bother
to bend too much backwards to support it, --ignore-errors were added
primarily for a similar use case (i.e. by the time we try to read it, it
is either gone or it cannot be read by the user who runs "git add"), so in
that sense it _might_ make sense to ignore all errors with the option. If
we choose to go in that direction, it would also make tons of sense to
update the documentation of the option to caution more strongly that its
use is a sign of insanity and is discouraged at the same time.
^ permalink raw reply
* Re: suppress fatal pathspec errors from "git add"?
From: aaron smith @ 2010-01-03 8:00 UTC (permalink / raw)
To: Jeff King; +Cc: git
In-Reply-To: <20100103074058.GB23031@sigill.intra.peff.net>
Hey Jeff, thanks for the reply.
Yeah you hit it right on the head, it would be useful to suppress the
errors if you're running a script to add the files. I can certainly
use that snippet u provided - thanks. It would even be useful in git
if you could suppress the errors, or maybe have a switch to list out
the files that failed, but add the ones that pass.. like "git add
--ignore-errors --list-failures" something like that. Anyway, thanks
for the input.
On Sat, Jan 2, 2010 at 11:40 PM, Jeff King <peff@peff.net> wrote:
> On Thu, Dec 31, 2009 at 01:24:59PM -0800, aaron smith wrote:
>
>> I'm looking through the add documentation, I don't see a way to
>> suppress fatal pathspec errors? For example, if I'm adding 5 files,
>> but one of them is mis-spelled, can I have git just supress the errors
>> and add the other four?
>
> Hmm. I would have thought "git add --ignore-errors" would do what you
> want, but it only ignores errors in reading the file. If we can't stat
> it, we will always die. IMHO that is an oversight in how
> "--ignore-errors" works (why should this one particular error be treated
> as fatal, when others are not?).
>
> However, I have to wonder what your workflow is to really want this. If
> you do:
>
> $ ls
> foo bar baz
> $ git add foo bar bz
> fatal: pathspec 'bz' did not match any files
>
> Then presumably your next command would be:
>
> $ git add foo bar baz
>
> Using ignore-errors (if it worked), you would probably do:
>
> $ git add baz
>
> Less typing, I suppose, but presumably you are using a shell that
> lets you just go back and edit the previous command line. I could see it
> if your workflow were something like "in a script, add these N files if
> they exist, but it is not an error if they don't". But I still don't
> think you would want to ignore all errors; you would want to do
> something like:
>
> $ git add $(for i in foo bar baz; do test -e $i && echo $i; done)
>
> instead. Am I missing something?
>
> -Peff
>
^ permalink raw reply
* Re: suppress fatal pathspec errors from "git add"?
From: Jeff King @ 2010-01-03 7:40 UTC (permalink / raw)
To: aaron smith; +Cc: git
In-Reply-To: <d7ac1a680912311324i85b7a5anadaf2ac13f215873@mail.gmail.com>
On Thu, Dec 31, 2009 at 01:24:59PM -0800, aaron smith wrote:
> I'm looking through the add documentation, I don't see a way to
> suppress fatal pathspec errors? For example, if I'm adding 5 files,
> but one of them is mis-spelled, can I have git just supress the errors
> and add the other four?
Hmm. I would have thought "git add --ignore-errors" would do what you
want, but it only ignores errors in reading the file. If we can't stat
it, we will always die. IMHO that is an oversight in how
"--ignore-errors" works (why should this one particular error be treated
as fatal, when others are not?).
However, I have to wonder what your workflow is to really want this. If
you do:
$ ls
foo bar baz
$ git add foo bar bz
fatal: pathspec 'bz' did not match any files
Then presumably your next command would be:
$ git add foo bar baz
Using ignore-errors (if it worked), you would probably do:
$ git add baz
Less typing, I suppose, but presumably you are using a shell that
lets you just go back and edit the previous command line. I could see it
if your workflow were something like "in a script, add these N files if
they exist, but it is not an error if they don't". But I still don't
think you would want to ignore all errors; you would want to do
something like:
$ git add $(for i in foo bar baz; do test -e $i && echo $i; done)
instead. Am I missing something?
-Peff
^ permalink raw reply
* Re: [PATCH 7/6] t0021: use $SHELL_PATH for the filter script
From: Jeff King @ 2010-01-03 7:24 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Junio C Hamano, Nanako Shiraishi, git
In-Reply-To: <4B3E73AE.6050003@kdbg.org>
On Fri, Jan 01, 2010 at 11:14:06PM +0100, Johannes Sixt wrote:
> On Windows, we need the shbang line to correctly invoke shell scripts via
> a POSIX shell, except when the script is invoked via 'sh -c' because
> sh (a bash) does "the right thing". Since nowadays the clean and smudge
> filters are not always invoked via 'sh -c' anymore, we have to mark the
> the one in t0021-conversion with #!$SHELL_PATH.
Hrm. This does mean we might be breaking users who have helper scripts
in a similar state to those in the test suite (of course, so does your
pager hack, or anything which might optimize out a shell call). But
perhaps given that scripts without a shebang generally don't work on
Windows, they are not too common and we don't need to worry about it.
-Peff
^ permalink raw reply
* Re: [PATCH] grep: do not do external grep on skip-worktree entries
From: Miles Bader @ 2010-01-03 3:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Nguyen Thai Ngoc Duy, git
In-Reply-To: <fc339e4a1001021847hf1e1a7fq894de7908839ff77@mail.gmail.com>
Miles Bader <miles@gnu.org> writes:
>> Isn't "-e" a "classic" grep option tho?
>
> Hmm, a bit of googling, and it seems that while 7th Edition unix (as
> classic as I get) had -e, solaris indeed doesn't....
Tho solaris does have it in /usr/xpg4/bin/grep...
Since it's a general attribute of solaris that the default (/usr/bin)
tools are horrible sysv things and the actual useful tools are in
e.g. /usr/xpg4/bin, maybe it would be better to just try and add that
directory to the path...?
-miles
--
Americans are broad-minded people. They'll accept the fact that a person can
be an alcoholic, a dope fiend, a wife beater, and even a newspaperman, but if
a man doesn't drive, there is something wrong with him. -- Art Buchwald
^ permalink raw reply
* Re: [PATCH] grep: do not do external grep on skip-worktree entries
From: Miles Bader @ 2010-01-03 2:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Nguyen Thai Ngoc Duy, git
In-Reply-To: <87ljgfgbl0.fsf@catnip.gol.com>
On Sun, Jan 3, 2010 at 11:35 AM, Miles Bader <miles@gnu.org> wrote:
>> Then please at least make the second grep "grep ext-grep", droping "-e --"
>> from it. We assume some implementation of external grep to lack "-e"
>> (e.g. Solaris).
>
> Isn't "-e" a "classic" grep option tho?
Hmm, a bit of googling, and it seems that while 7th Edition unix (as
classic as I get) had -e, solaris indeed doesn't....
-miles
--
Do not taunt Happy Fun Ball.
^ permalink raw reply
* Re: [PATCH] grep: do not do external grep on skip-worktree entries
From: Miles Bader @ 2010-01-03 2:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Nguyen Thai Ngoc Duy, git
In-Reply-To: <7v7hs09tpi.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Then please at least make the second grep "grep ext-grep", droping "-e --"
> from it. We assume some implementation of external grep to lack "-e"
> (e.g. Solaris).
Isn't "-e" a "classic" grep option tho?
-Miles
--
Consult, v.i. To seek another's disapproval of a course already decided on.
^ permalink raw reply
* Re: [PATCH v3] Smart-http documentation: add example of how to execute from userdir
From: Tay Ray Chuan @ 2010-01-03 2:11 UTC (permalink / raw)
To: Tarmigan Casebolt; +Cc: Junio C Hamano, git, Shawn O. Pearce
In-Reply-To: <1262467101-5755-1-git-send-email-tarmigan+git@gmail.com>
Hi,
On Sun, Jan 3, 2010 at 5:18 AM, Tarmigan Casebolt
<tarmigan+git@gmail.com> wrote:
> Smart-http may be an attactive and easy way for people to setup git
> hosting on shared servers whose primary web server configuration they
> do not control. To facilite this, provide an example of how it may be
> done.
>
> cc: Tay Ray Chuan <rctay89@gmail.com>
> cc: Shawn O. Pearce <spearce@spearce.org>
> Editing-by: Tay Ray Chuan <rctay89@gmail.com>
> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
Acked-by: Tay Ray Chuan <rctay89@gmail.com>
--
Cheers,
Ray Chuan
^ permalink raw reply
* [PATCH v2] t/lib-http.sh: Restructure finding of default httpd location
From: Tarmigan Casebolt @ 2010-01-02 22:04 UTC (permalink / raw)
To: gitster; +Cc: git, Tarmigan Casebolt, Jay Soffian
In-Reply-To: <905315640911191930rc33cabdr290b534ffbe85690@mail.gmail.com>
On CentOS 5, httpd is located at /usr/sbin/httpd, and the modules are
located at /usr/lib64/httpd/modules. To enable easy testing of httpd,
we would like those locations to be detected automatically.
uname might not be the best way to determine the default location for
httpd since different Linux distributions apparently put httpd in
different places, so we test a couple different locations for httpd,
and use the first one that we come across. We do the same for the
modules directory.
cc: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
Jay was concerned about the final fallthrough cases for testing these
lists. I have added a test for the modules directory and the existing
tests later in the script already test that the apache executable
exists. If either cannot be found, we do test_done.
Would any machines have httpd or the modules/ directory in several of
these locations?
---
t/lib-httpd.sh | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 6765b08..27b466b 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -12,16 +12,29 @@ fi
HTTPD_PARA=""
+for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
+do
+ if test -x "$DEFAULT_HTTPD_PATH"
+ then
+ break
+ fi
+done
+
+for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
+ '/usr/lib/apache2/modules' \
+ '/usr/lib64/httpd/modules' \
+ '/usr/lib/httpd/modules'
+do
+ if test -d "$DEFAULT_HTTPD_MODULE_PATH"
+ then
+ break
+ fi
+done
+
case $(uname) in
Darwin)
- DEFAULT_HTTPD_PATH='/usr/sbin/httpd'
- DEFAULT_HTTPD_MODULE_PATH='/usr/libexec/apache2'
HTTPD_PARA="$HTTPD_PARA -DDarwin"
;;
- *)
- DEFAULT_HTTPD_PATH='/usr/sbin/apache2'
- DEFAULT_HTTPD_MODULE_PATH='/usr/lib/apache2/modules'
- ;;
esac
LIB_HTTPD_PATH=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"}
@@ -49,6 +62,11 @@ then
say "skipping test, at least Apache version 2 is required"
test_done
fi
+ if ! test -d "$DEFAULT_HTTPD_MODULE_PATH"
+ then
+ say "Apache module directory not found. Skipping tests."
+ test_done
+ fi
LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH"
fi
--
1.6.6.236.gc56f3
^ permalink raw reply related
* [PATCH v4 3/3] Smart-http tests: Test http-backend without curl or a webserver
From: Tarmigan Casebolt @ 2010-01-02 21:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O. Pearce, git, Tarmigan Casebolt
In-Reply-To: <20100102214107.GO6914@spearce.org>
This reuses many of the tests from the old t5560 but runs those tests
without curl or a webserver. This will hopefully increase the testing
coverage for http-backend because it does not require users to set
GIT_TEST_HTTPD.
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
Oops forgot to commit the grep changes.
Only resending 3/3 of the series.
---
t/t5560-http-backend-noserver.sh | 26 ++++++++++++++++++++------
t/t556x_common | 3 +++
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index a9ba2d9..a63d3ec 100755
--- a/t/t5560-http-backend-noserver.sh
+++ b/t/t5560-http-backend-noserver.sh
@@ -6,18 +6,32 @@ test_description='test git-http-backend-noserver'
HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
run_backend() {
- REQUEST_METHOD=GET \
+ echo "$2"| \
+ QUERY_STRING="${1#*\?}" \
GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
- PATH_INFO="$1" \
+ PATH_INFO="${1%%\?*}" \
git http-backend >act.out 2>act.err
}
GET() {
- return 0
+ REQUEST_METHOD="GET" \
+ run_backend "/repo.git/$1" &&
+ if ! grep "Status" act.out >act; then
+ printf "Status: 200 OK\r\n" > act
+ fi
+ printf "Status: $2\r\n" > exp &&
+ test_cmp exp act
}
POST() {
- return 0
+ REQUEST_METHOD="POST" \
+ CONTENT_TYPE="application/x-$1-request" \
+ run_backend "/repo.git/$1" "$2" &&
+ if ! grep "Status" act.out >act; then
+ printf "Status: 200 OK\r\n" > act
+ fi
+ printf "Status: $3\r\n" > exp &&
+ test_cmp exp act
}
log_div() {
@@ -28,9 +42,9 @@ log_div() {
expect_aliased() {
if test $1 = 0; then
- run_backend "$2"
+ REQUEST_METHOD=GET run_backend "$2"
else
- run_backend "$2" &&
+ REQUEST_METHOD=GET run_backend "$2" &&
echo "fatal: '$2': aliased" >exp.err &&
test_cmp exp.err act.err
fi
diff --git a/t/t556x_common b/t/t556x_common
index 1b4921c..be024e5 100755
--- a/t/t556x_common
+++ b/t/t556x_common
@@ -50,6 +50,7 @@ get_static_files() {
}
SMART=smart
+export GIT_HTTP_EXPORT_ALL=1
test_expect_success 'direct refs/heads/master not found' '
log_div "refs/heads/master"
GET refs/heads/master "404 Not Found"
@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '
get_static_files "200 OK"
'
SMART=smart_noexport
+unset GIT_HTTP_EXPORT_ALL
test_expect_success 'no export by default' '
log_div "no git-daemon-export-ok"
get_static_files "404 Not Found"
@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '
get_static_files "200 OK"
'
SMART=smart
+export GIT_HTTP_EXPORT_ALL=1
test_expect_success 'static file if http.getanyfile true is ok' '
log_div "getanyfile true"
config http.getanyfile true &&
--
1.6.6.236.gc56f3
^ permalink raw reply related
* Re: [PATCH v3 3/3] Smart-http tests: Test http-backend without curl or a webserver
From: Shawn O. Pearce @ 2010-01-02 21:41 UTC (permalink / raw)
To: Tarmigan; +Cc: Junio C Hamano, git
In-Reply-To: <905315641001021337v238515c8s34d820236dac698d@mail.gmail.com>
Tarmigan <tarmigan+git@gmail.com> wrote:
> On Sat, Jan 2, 2010 at 1:03 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> > Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:
> >> ?GET() {
> >> - ? ? return 0
> >> + ? ? REQUEST_METHOD="GET" \
> >> + ? ? run_backend "/repo.git/$1" &&
> >> + ? ? grep "Status" act.out >act
> >> + ? ? if [ $? -eq 1 ];
> >
> > I think this should be spelled as:
> >
> > ? ? ? ?if ! grep "Status" act.out >act; then
> > ? ? ? ? ? ? ? ?printf "Status: 200 OK\r\n" > act
> > ? ? ? ?fi
>
> OK. I had figured the "1" would mean "no matches not found" rather
> than some other error like "file does not exist". Not sure how
> portable that error value convention is for greps though, so I've
> changed it as you suggested.
Your v3 series still shows it the old way...
--
Shawn.
^ permalink raw reply
* [PATCH v4 3/3] Smart-http tests: Test http-backend without curl or a webserver
From: Tarmigan Casebolt @ 2010-01-02 21:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O. Pearce, git, Tarmigan Casebolt
In-Reply-To: <20100102205928.GM6914@spearce.org>
This reuses many of the tests from the old t5560 but runs those tests
without curl or a webserver. This will hopefully increase the testing
coverage for http-backend because it does not require users to set
GIT_TEST_HTTPD.
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
As a side note, I am very impressed that git rebase was able to
apply this patch properly even after I renamed the tests earlier in
the series.
---
t/t5560-http-backend-noserver.sh | 30 ++++++++++++++++++++++++------
t/t556x_common | 3 +++
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index a9ba2d9..9013824 100755
--- a/t/t5560-http-backend-noserver.sh
+++ b/t/t5560-http-backend-noserver.sh
@@ -6,18 +6,36 @@ test_description='test git-http-backend-noserver'
HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
run_backend() {
- REQUEST_METHOD=GET \
+ echo "$2"| \
+ QUERY_STRING="${1#*\?}" \
GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
- PATH_INFO="$1" \
+ PATH_INFO="${1%%\?*}" \
git http-backend >act.out 2>act.err
}
GET() {
- return 0
+ REQUEST_METHOD="GET" \
+ run_backend "/repo.git/$1" &&
+ grep "Status" act.out >act
+ if [ $? -eq 1 ];
+ then
+ printf "Status: 200 OK\r\n" > act
+ fi
+ printf "Status: $2\r\n" > exp &&
+ test_cmp exp act
}
POST() {
- return 0
+ REQUEST_METHOD="POST" \
+ CONTENT_TYPE="application/x-$1-request" \
+ run_backend "/repo.git/$1" "$2" &&
+ grep "Status" act.out >act
+ if [ $? -eq 1 ];
+ then
+ printf "Status: 200 OK\r\n" > act
+ fi
+ printf "Status: $3\r\n" > exp &&
+ test_cmp exp act
}
log_div() {
@@ -28,9 +46,9 @@ log_div() {
expect_aliased() {
if test $1 = 0; then
- run_backend "$2"
+ REQUEST_METHOD=GET run_backend "$2"
else
- run_backend "$2" &&
+ REQUEST_METHOD=GET run_backend "$2" &&
echo "fatal: '$2': aliased" >exp.err &&
test_cmp exp.err act.err
fi
diff --git a/t/t556x_common b/t/t556x_common
index 1b4921c..be024e5 100755
--- a/t/t556x_common
+++ b/t/t556x_common
@@ -50,6 +50,7 @@ get_static_files() {
}
SMART=smart
+export GIT_HTTP_EXPORT_ALL=1
test_expect_success 'direct refs/heads/master not found' '
log_div "refs/heads/master"
GET refs/heads/master "404 Not Found"
@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '
get_static_files "200 OK"
'
SMART=smart_noexport
+unset GIT_HTTP_EXPORT_ALL
test_expect_success 'no export by default' '
log_div "no git-daemon-export-ok"
get_static_files "404 Not Found"
@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '
get_static_files "200 OK"
'
SMART=smart
+export GIT_HTTP_EXPORT_ALL=1
test_expect_success 'static file if http.getanyfile true is ok' '
log_div "getanyfile true"
config http.getanyfile true &&
--
1.6.6.236.gc56f3
^ permalink raw reply related
* [PATCH v4 2/3] Smart-http tests: Break test t5560-http-backend into pieces
From: Tarmigan Casebolt @ 2010-01-02 21:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O. Pearce, git, Tarmigan Casebolt
In-Reply-To: <20100102205928.GM6914@spearce.org>
This should introduce no functional change in the tests or the amount
of test coverage.
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
t/t5560-http-backend-noserver.sh | 52 +++++++
t/t5560-http-backend.sh | 294 --------------------------------------
t/t5561-http-backend.sh | 149 +++++++++++++++++++
t/t556x_common | 119 +++++++++++++++
4 files changed, 320 insertions(+), 294 deletions(-)
create mode 100755 t/t5560-http-backend-noserver.sh
delete mode 100755 t/t5560-http-backend.sh
create mode 100755 t/t5561-http-backend.sh
create mode 100755 t/t556x_common
diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
new file mode 100755
index 0000000..a9ba2d9
--- /dev/null
+++ b/t/t5560-http-backend-noserver.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+test_description='test git-http-backend-noserver'
+. ./test-lib.sh
+
+HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
+
+run_backend() {
+ REQUEST_METHOD=GET \
+ GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
+ PATH_INFO="$1" \
+ git http-backend >act.out 2>act.err
+}
+
+GET() {
+ return 0
+}
+
+POST() {
+ return 0
+}
+
+log_div() {
+ return 0
+}
+
+. "$TEST_DIRECTORY"/t556x_common
+
+expect_aliased() {
+ if test $1 = 0; then
+ run_backend "$2"
+ else
+ run_backend "$2" &&
+ echo "fatal: '$2': aliased" >exp.err &&
+ test_cmp exp.err act.err
+ fi
+}
+
+test_expect_success 'http-backend blocks bad PATH_INFO' '
+ config http.getanyfile true &&
+
+ expect_aliased 0 /repo.git/HEAD &&
+
+ expect_aliased 1 /repo.git/../HEAD &&
+ expect_aliased 1 /../etc/passwd &&
+ expect_aliased 1 ../etc/passwd &&
+ expect_aliased 1 /etc//passwd &&
+ expect_aliased 1 /etc/./passwd &&
+ expect_aliased 1 //domain/data.txt
+'
+
+test_done
diff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh
deleted file mode 100755
index 0e4dc4b..0000000
--- a/t/t5560-http-backend.sh
+++ /dev/null
@@ -1,294 +0,0 @@
-#!/bin/sh
-
-test_description='test git-http-backend'
-. ./test-lib.sh
-
-if test -n "$NO_CURL"; then
- say 'skipping test, git built without http support'
- test_done
-fi
-
-LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5560'}
-. "$TEST_DIRECTORY"/lib-httpd.sh
-start_httpd
-
-find_file() {
- cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- find $1 -type f |
- sed -e 1q
-}
-
-config() {
- git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config $1 $2
-}
-
-GET() {
- curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null &&
- tr '\015' Q <out |
- sed '
- s/Q$//
- 1q
- ' >act &&
- echo "HTTP/1.1 $2" >exp &&
- test_cmp exp act
-}
-
-POST() {
- curl --include --data "$2" \
- --header "Content-Type: application/x-$1-request" \
- "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null &&
- tr '\015' Q <out |
- sed '
- s/Q$//
- 1q
- ' >act &&
- echo "HTTP/1.1 $3" >exp &&
- test_cmp exp act
-}
-
-log_div() {
- echo >>"$HTTPD_ROOT_PATH"/access.log
- echo "### $1" >>"$HTTPD_ROOT_PATH"/access.log
- echo "###" >>"$HTTPD_ROOT_PATH"/access.log
-}
-
-test_expect_success 'setup repository' '
- echo content >file &&
- git add file &&
- git commit -m one &&
-
- mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- git --bare init &&
- : >objects/info/alternates &&
- : >objects/info/http-alternates
- ) &&
- git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- git push public master:master &&
-
- (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- git repack -a -d
- ) &&
-
- echo other >file &&
- git add file &&
- git commit -m two &&
- git push public master:master &&
-
- LOOSE_URL=$(find_file objects/??) &&
- PACK_URL=$(find_file objects/pack/*.pack) &&
- IDX_URL=$(find_file objects/pack/*.idx)
-'
-
-get_static_files() {
- GET HEAD "$1" &&
- GET info/refs "$1" &&
- GET objects/info/packs "$1" &&
- GET objects/info/alternates "$1" &&
- GET objects/info/http-alternates "$1" &&
- GET $LOOSE_URL "$1" &&
- GET $PACK_URL "$1" &&
- GET $IDX_URL "$1"
-}
-
-SMART=smart
-test_expect_success 'direct refs/heads/master not found' '
- log_div "refs/heads/master"
- GET refs/heads/master "404 Not Found"
-'
-test_expect_success 'static file is ok' '
- log_div "getanyfile default"
- get_static_files "200 OK"
-'
-SMART=smart_noexport
-test_expect_success 'no export by default' '
- log_div "no git-daemon-export-ok"
- get_static_files "404 Not Found"
-'
-test_expect_success 'export if git-daemon-export-ok' '
- log_div "git-daemon-export-ok"
- (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- touch git-daemon-export-ok
- ) &&
- get_static_files "200 OK"
-'
-SMART=smart
-test_expect_success 'static file if http.getanyfile true is ok' '
- log_div "getanyfile true"
- config http.getanyfile true &&
- get_static_files "200 OK"
-'
-test_expect_success 'static file if http.getanyfile false fails' '
- log_div "getanyfile false"
- config http.getanyfile false &&
- get_static_files "403 Forbidden"
-'
-
-test_expect_success 'http.uploadpack default enabled' '
- log_div "uploadpack default"
- GET info/refs?service=git-upload-pack "200 OK" &&
- POST git-upload-pack 0000 "200 OK"
-'
-test_expect_success 'http.uploadpack true' '
- log_div "uploadpack true"
- config http.uploadpack true &&
- GET info/refs?service=git-upload-pack "200 OK" &&
- POST git-upload-pack 0000 "200 OK"
-'
-test_expect_success 'http.uploadpack false' '
- log_div "uploadpack false"
- config http.uploadpack false &&
- GET info/refs?service=git-upload-pack "403 Forbidden" &&
- POST git-upload-pack 0000 "403 Forbidden"
-'
-
-test_expect_success 'http.receivepack default disabled' '
- log_div "receivepack default"
- GET info/refs?service=git-receive-pack "403 Forbidden" &&
- POST git-receive-pack 0000 "403 Forbidden"
-'
-test_expect_success 'http.receivepack true' '
- log_div "receivepack true"
- config http.receivepack true &&
- GET info/refs?service=git-receive-pack "200 OK" &&
- POST git-receive-pack 0000 "200 OK"
-'
-test_expect_success 'http.receivepack false' '
- log_div "receivepack false"
- config http.receivepack false &&
- GET info/refs?service=git-receive-pack "403 Forbidden" &&
- POST git-receive-pack 0000 "403 Forbidden"
-'
-run_backend() {
- REQUEST_METHOD=GET \
- GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
- PATH_INFO="$1" \
- git http-backend >act.out 2>act.err
-}
-
-expect_aliased() {
- if test $1 = 0; then
- run_backend "$2"
- else
- run_backend "$2" &&
- echo "fatal: '$2': aliased" >exp.err &&
- test_cmp exp.err act.err
- fi
-}
-
-test_expect_success 'http-backend blocks bad PATH_INFO' '
- config http.getanyfile true &&
-
- expect_aliased 0 /repo.git/HEAD &&
-
- expect_aliased 1 /repo.git/../HEAD &&
- expect_aliased 1 /../etc/passwd &&
- expect_aliased 1 ../etc/passwd &&
- expect_aliased 1 /etc//passwd &&
- expect_aliased 1 /etc/./passwd &&
- expect_aliased 1 //domain/data.txt
-'
-
-cat >exp <<EOF
-
-### refs/heads/master
-###
-GET /smart/repo.git/refs/heads/master HTTP/1.1 404 -
-
-### getanyfile default
-###
-GET /smart/repo.git/HEAD HTTP/1.1 200
-GET /smart/repo.git/info/refs HTTP/1.1 200
-GET /smart/repo.git/objects/info/packs HTTP/1.1 200
-GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
-GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
-GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
-GET /smart/repo.git/$PACK_URL HTTP/1.1 200
-GET /smart/repo.git/$IDX_URL HTTP/1.1 200
-
-### no git-daemon-export-ok
-###
-GET /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
-GET /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
-GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
-GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
-GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
-GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
-GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
-GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
-
-### git-daemon-export-ok
-###
-GET /smart_noexport/repo.git/HEAD HTTP/1.1 200
-GET /smart_noexport/repo.git/info/refs HTTP/1.1 200
-GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
-GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
-GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
-GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
-GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
-GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
-
-### getanyfile true
-###
-GET /smart/repo.git/HEAD HTTP/1.1 200
-GET /smart/repo.git/info/refs HTTP/1.1 200
-GET /smart/repo.git/objects/info/packs HTTP/1.1 200
-GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
-GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
-GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
-GET /smart/repo.git/$PACK_URL HTTP/1.1 200
-GET /smart/repo.git/$IDX_URL HTTP/1.1 200
-
-### getanyfile false
-###
-GET /smart/repo.git/HEAD HTTP/1.1 403 -
-GET /smart/repo.git/info/refs HTTP/1.1 403 -
-GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
-GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
-GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
-GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
-GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
-GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
-
-### uploadpack default
-###
-GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
-POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
-
-### uploadpack true
-###
-GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
-POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
-
-### uploadpack false
-###
-GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
-POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
-
-### receivepack default
-###
-GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
-POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
-
-### receivepack true
-###
-GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
-POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
-
-### receivepack false
-###
-GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
-POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
-EOF
-test_expect_success 'server request log matches test results' '
- sed -e "
- s/^.* \"//
- s/\"//
- s/ [1-9][0-9]*\$//
- s/^GET /GET /
- " >act <"$HTTPD_ROOT_PATH"/access.log &&
- test_cmp exp act
-'
-
-stop_httpd
-test_done
diff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh
new file mode 100755
index 0000000..8c6d0b2
--- /dev/null
+++ b/t/t5561-http-backend.sh
@@ -0,0 +1,149 @@
+#!/bin/sh
+
+test_description='test git-http-backend'
+. ./test-lib.sh
+
+if test -n "$NO_CURL"; then
+ say 'skipping test, git built without http support'
+ test_done
+fi
+
+LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5561'}
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+GET() {
+ curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null &&
+ tr '\015' Q <out |
+ sed '
+ s/Q$//
+ 1q
+ ' >act &&
+ echo "HTTP/1.1 $2" >exp &&
+ test_cmp exp act
+}
+
+POST() {
+ curl --include --data "$2" \
+ --header "Content-Type: application/x-$1-request" \
+ "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null &&
+ tr '\015' Q <out |
+ sed '
+ s/Q$//
+ 1q
+ ' >act &&
+ echo "HTTP/1.1 $3" >exp &&
+ test_cmp exp act
+}
+
+log_div() {
+ echo >>"$HTTPD_ROOT_PATH"/access.log
+ echo "### $1" >>"$HTTPD_ROOT_PATH"/access.log
+ echo "###" >>"$HTTPD_ROOT_PATH"/access.log
+}
+
+. "$TEST_DIRECTORY"/t556x_common
+
+cat >exp <<EOF
+
+### refs/heads/master
+###
+GET /smart/repo.git/refs/heads/master HTTP/1.1 404 -
+
+### getanyfile default
+###
+GET /smart/repo.git/HEAD HTTP/1.1 200
+GET /smart/repo.git/info/refs HTTP/1.1 200
+GET /smart/repo.git/objects/info/packs HTTP/1.1 200
+GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
+GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
+GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
+GET /smart/repo.git/$PACK_URL HTTP/1.1 200
+GET /smart/repo.git/$IDX_URL HTTP/1.1 200
+
+### no git-daemon-export-ok
+###
+GET /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
+GET /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
+GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
+GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
+GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
+GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
+GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
+GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
+
+### git-daemon-export-ok
+###
+GET /smart_noexport/repo.git/HEAD HTTP/1.1 200
+GET /smart_noexport/repo.git/info/refs HTTP/1.1 200
+GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
+GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
+GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
+GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
+GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
+GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
+
+### getanyfile true
+###
+GET /smart/repo.git/HEAD HTTP/1.1 200
+GET /smart/repo.git/info/refs HTTP/1.1 200
+GET /smart/repo.git/objects/info/packs HTTP/1.1 200
+GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
+GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
+GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
+GET /smart/repo.git/$PACK_URL HTTP/1.1 200
+GET /smart/repo.git/$IDX_URL HTTP/1.1 200
+
+### getanyfile false
+###
+GET /smart/repo.git/HEAD HTTP/1.1 403 -
+GET /smart/repo.git/info/refs HTTP/1.1 403 -
+GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
+GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
+GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
+GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
+GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
+GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
+
+### uploadpack default
+###
+GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
+POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
+
+### uploadpack true
+###
+GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
+POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
+
+### uploadpack false
+###
+GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
+POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
+
+### receivepack default
+###
+GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
+POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
+
+### receivepack true
+###
+GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
+POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
+
+### receivepack false
+###
+GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
+POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
+EOF
+test_expect_success 'server request log matches test results' '
+ sed -e "
+ s/^.* \"//
+ s/\"//
+ s/ [1-9][0-9]*\$//
+ s/^GET /GET /
+ " >act <"$HTTPD_ROOT_PATH"/access.log &&
+ test_cmp exp act
+'
+
+stop_httpd
+test_done
diff --git a/t/t556x_common b/t/t556x_common
new file mode 100755
index 0000000..1b4921c
--- /dev/null
+++ b/t/t556x_common
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+find_file() {
+ cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ find $1 -type f |
+ sed -e 1q
+}
+
+config() {
+ git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config $1 $2
+}
+
+test_expect_success 'setup repository' '
+ echo content >file &&
+ git add file &&
+ git commit -m one &&
+
+ mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git --bare init &&
+ : >objects/info/alternates &&
+ : >objects/info/http-alternates
+ ) &&
+ git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git push public master:master &&
+
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git repack -a -d
+ ) &&
+
+ echo other >file &&
+ git add file &&
+ git commit -m two &&
+ git push public master:master &&
+
+ LOOSE_URL=$(find_file objects/??) &&
+ PACK_URL=$(find_file objects/pack/*.pack) &&
+ IDX_URL=$(find_file objects/pack/*.idx)
+'
+
+get_static_files() {
+ GET HEAD "$1" &&
+ GET info/refs "$1" &&
+ GET objects/info/packs "$1" &&
+ GET objects/info/alternates "$1" &&
+ GET objects/info/http-alternates "$1" &&
+ GET $LOOSE_URL "$1" &&
+ GET $PACK_URL "$1" &&
+ GET $IDX_URL "$1"
+}
+
+SMART=smart
+test_expect_success 'direct refs/heads/master not found' '
+ log_div "refs/heads/master"
+ GET refs/heads/master "404 Not Found"
+'
+test_expect_success 'static file is ok' '
+ log_div "getanyfile default"
+ get_static_files "200 OK"
+'
+SMART=smart_noexport
+test_expect_success 'no export by default' '
+ log_div "no git-daemon-export-ok"
+ get_static_files "404 Not Found"
+'
+test_expect_success 'export if git-daemon-export-ok' '
+ log_div "git-daemon-export-ok"
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ touch git-daemon-export-ok
+ ) &&
+ get_static_files "200 OK"
+'
+SMART=smart
+test_expect_success 'static file if http.getanyfile true is ok' '
+ log_div "getanyfile true"
+ config http.getanyfile true &&
+ get_static_files "200 OK"
+'
+test_expect_success 'static file if http.getanyfile false fails' '
+ log_div "getanyfile false"
+ config http.getanyfile false &&
+ get_static_files "403 Forbidden"
+'
+
+test_expect_success 'http.uploadpack default enabled' '
+ log_div "uploadpack default"
+ GET info/refs?service=git-upload-pack "200 OK" &&
+ POST git-upload-pack 0000 "200 OK"
+'
+test_expect_success 'http.uploadpack true' '
+ log_div "uploadpack true"
+ config http.uploadpack true &&
+ GET info/refs?service=git-upload-pack "200 OK" &&
+ POST git-upload-pack 0000 "200 OK"
+'
+test_expect_success 'http.uploadpack false' '
+ log_div "uploadpack false"
+ config http.uploadpack false &&
+ GET info/refs?service=git-upload-pack "403 Forbidden" &&
+ POST git-upload-pack 0000 "403 Forbidden"
+'
+
+test_expect_success 'http.receivepack default disabled' '
+ log_div "receivepack default"
+ GET info/refs?service=git-receive-pack "403 Forbidden" &&
+ POST git-receive-pack 0000 "403 Forbidden"
+'
+test_expect_success 'http.receivepack true' '
+ log_div "receivepack true"
+ config http.receivepack true &&
+ GET info/refs?service=git-receive-pack "200 OK" &&
+ POST git-receive-pack 0000 "200 OK"
+'
+test_expect_success 'http.receivepack false' '
+ log_div "receivepack false"
+ config http.receivepack false &&
+ GET info/refs?service=git-receive-pack "403 Forbidden" &&
+ POST git-receive-pack 0000 "403 Forbidden"
+'
--
1.6.6.236.gc56f3
^ permalink raw reply related
* [PATCH v4 1/3] Smart-http tests: Improve coverage in test t5560
From: Tarmigan Casebolt @ 2010-01-02 21:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O. Pearce, git, Tarmigan Casebolt
In-Reply-To: <20100102205928.GM6914@spearce.org>
Commit 34b6cb8bb ("http-backend: Protect GIT_PROJECT_ROOT from /../
requests") added the path_info helper function to test t5560 but did
not use it. We should use it as it provides another level of error
checking.
The /etc/.../passwd case is one that is not special (and the test
fails for reasons other than being aliased), so we remove that test
case.
Also rename the function from 'path_info' to 'expect_aliased'.
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
One thing to note is that
expect_aliased 0 /repo.git/HEAD
test still does not actually test any results back from http-backend,
but that's also how it was before as well.
---
t/t5560-http-backend.sh | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh
index 04a9896..0e4dc4b 100755
--- a/t/t5560-http-backend.sh
+++ b/t/t5560-http-backend.sh
@@ -162,15 +162,15 @@ test_expect_success 'http.receivepack false' '
run_backend() {
REQUEST_METHOD=GET \
GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
- PATH_INFO="$2" \
+ PATH_INFO="$1" \
git http-backend >act.out 2>act.err
}
-path_info() {
+expect_aliased() {
if test $1 = 0; then
run_backend "$2"
else
- test_must_fail run_backend "$2" &&
+ run_backend "$2" &&
echo "fatal: '$2': aliased" >exp.err &&
test_cmp exp.err act.err
fi
@@ -179,15 +179,14 @@ path_info() {
test_expect_success 'http-backend blocks bad PATH_INFO' '
config http.getanyfile true &&
- run_backend 0 /repo.git/HEAD &&
+ expect_aliased 0 /repo.git/HEAD &&
- run_backend 1 /repo.git/../HEAD &&
- run_backend 1 /../etc/passwd &&
- run_backend 1 ../etc/passwd &&
- run_backend 1 /etc//passwd &&
- run_backend 1 /etc/./passwd &&
- run_backend 1 /etc/.../passwd &&
- run_backend 1 //domain/data.txt
+ expect_aliased 1 /repo.git/../HEAD &&
+ expect_aliased 1 /../etc/passwd &&
+ expect_aliased 1 ../etc/passwd &&
+ expect_aliased 1 /etc//passwd &&
+ expect_aliased 1 /etc/./passwd &&
+ expect_aliased 1 //domain/data.txt
'
cat >exp <<EOF
--
1.6.6.236.gc56f3
^ permalink raw reply related
* Re: [PATCH v3 3/3] Smart-http tests: Test http-backend without curl or a webserver
From: Tarmigan @ 2010-01-02 21:37 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git
In-Reply-To: <20100102210318.GN6914@spearce.org>
On Sat, Jan 2, 2010 at 1:03 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:
>> GET() {
>> - return 0
>> + REQUEST_METHOD="GET" \
>> + run_backend "/repo.git/$1" &&
>> + grep "Status" act.out >act
>> + if [ $? -eq 1 ];
>
> I think this should be spelled as:
>
> if ! grep "Status" act.out >act; then
> printf "Status: 200 OK\r\n" > act
> fi
OK. I had figured the "1" would mean "no matches not found" rather
than some other error like "file does not exist". Not sure how
portable that error value convention is for greps though, so I've
changed it as you suggested.
Thanks,
Tarmigan
^ permalink raw reply
* [PATCH v3] Smart-http documentation: add example of how to execute from userdir
From: Tarmigan Casebolt @ 2010-01-02 21:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Tarmigan Casebolt, Tay Ray Chuan, Shawn O. Pearce
In-Reply-To: <be6fef0d0912301818o678976ebqa3e339dc1ff1f2e8@mail.gmail.com>
Smart-http may be an attactive and easy way for people to setup git
hosting on shared servers whose primary web server configuration they
do not control. To facilite this, provide an example of how it may be
done.
cc: Tay Ray Chuan <rctay89@gmail.com>
cc: Shawn O. Pearce <spearce@spearce.org>
Editing-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
Documentation/git-http-backend.txt | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt
index 67aec06..0485033 100644
--- a/Documentation/git-http-backend.txt
+++ b/Documentation/git-http-backend.txt
@@ -60,8 +60,8 @@ automatically by the web server.
EXAMPLES
--------
-All of the following examples map 'http://$hostname/git/foo/bar.git'
-to '/var/www/git/foo/bar.git'.
+Unless otherwise noted, the following examples map
+'http://$hostname/git/foo/bar.git' to '/var/www/git/foo/bar.git'.
Apache 2.x::
Ensure mod_cgi, mod_alias, and mod_env are enabled, set
@@ -144,6 +144,34 @@ ScriptAliasMatch \
ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
----------------------------------------------------------------
+In the following example, the repository at
+'/home/$username/devel/foo/bar.git' will be accessible at
+'http://$hostname/~$username/cgi-bin/git/foo/bar.git'.
+
+From UserDir on Apache 2.x::
+ One way to configure 'git-http-backend' to execute and serve
+ from a user directory (for example, on a shared hosting
+ provider), is to have a symbolic link named 'git' that points
+ from the cgi directory to the 'git-http-backend' executable in
+ libexec. The advantage is that this symbolic link always
+ points to the latest installed version; one does not have to
+ make any changes to the symbolic link when the installed
+ 'git-http-backend' is updated.
++
+----------------------------------------------------------------
+SetHandler cgi-script
+Options +SymLinksIfOwnerMatch
+SetEnv GIT_PROJECT_ROOT /home/$username/devel
+----------------------------------------------------------------
++
+Also add any needed authentication to the .htaccess file as discussed
+in earlier examples.
++
+If the web server does not follow any symbolic links, the
+'git-http-backend' executable may be copied into the cgi-bin directory
+and renamed to 'git' to acheive the same effect, but it will also need
+to be manually updated whenever a new version of 'git-http-backend' is
+installed.
ENVIRONMENT
-----------
--
1.6.6.236.gc56f3
^ permalink raw reply related
* Re: [PATCH v3 3/3] Smart-http tests: Test http-backend without curl or a webserver
From: Shawn O. Pearce @ 2010-01-02 21:03 UTC (permalink / raw)
To: Tarmigan Casebolt; +Cc: Junio C Hamano, git
In-Reply-To: <1262465119-96115-3-git-send-email-tarmigan+git@gmail.com>
Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:
> GET() {
> - return 0
> + REQUEST_METHOD="GET" \
> + run_backend "/repo.git/$1" &&
> + grep "Status" act.out >act
> + if [ $? -eq 1 ];
I think this should be spelled as:
if ! grep "Status" act.out >act; then
printf "Status: 200 OK\r\n" > act
fi
--
Shawn.
^ permalink raw reply
* Re: [PATCH v3 2/3] Smart-http tests: Break test t5560-http-backend into pieces
From: Shawn O. Pearce @ 2010-01-02 20:59 UTC (permalink / raw)
To: Tarmigan Casebolt; +Cc: Junio C Hamano, git
In-Reply-To: <1262465119-96115-2-git-send-email-tarmigan+git@gmail.com>
Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:
> This should introduce no functional change in the tests or the amount
> of test coverage.
>
> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
> ---
> t/t5560-http-backend.sh | 147 +-------------------------------------
> t/t5561-http-backend-noserver.sh | 52 +++++++++++++
These should be reversed. We'd want to find out the backend doesn't
work by itself before we see it fail under Apache.
Otherwise, Acked-by: Shawn O. Pearce <spearce@spearce.org>
--
Shawn.
^ permalink raw reply
* Re: [PATCH v3 RFC 1/3] Smart-http tests: Improve coverage in test t5560
From: Shawn O. Pearce @ 2010-01-02 20:54 UTC (permalink / raw)
To: Tarmigan Casebolt; +Cc: Junio C Hamano, git
In-Reply-To: <1262465119-96115-1-git-send-email-tarmigan+git@gmail.com>
Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:
> Commit 34b6cb8bb ("http-backend: Protect GIT_PROJECT_ROOT from /../
> requests") added the path_info helper function to test t5560 but did
> not use it. We should use it as it provides another level of error
> checking.
>
> The /etc/.../passwd case is one that is not special (and the test
> fails for reasons other than being aliased), so we remove that test
> case.
>
> Also rename the function from 'path_info' to 'expect_aliased'.
>
> cc: Shawn O. Pearce <spearce@spearce.org>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
--
Shawn.
^ permalink raw reply
* Re: Filename quoting / parsing problem
From: Andreas Gruenbacher @ 2010-01-02 20:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v8wcge4kr.fsf@alter.siamese.dyndns.org>
On Saturday 02 January 2010 07:37:08 pm Junio C Hamano wrote:
> Andreas Gruenbacher <agruen@suse.de> writes:
> > On Friday 01 January 2010 09:01:19 pm Junio C Hamano wrote:
> >> > Both "b file" and "c file " are parsed by "git apply" perfectly fine.
> >
> > Right, the "diff --git" lines are technically still parseable when the
> > file name stays the same. With renames, lines like "diff --git a/f a/f
> > b/f" or "diff --git a/f b/f b/f" are possible, but then there will also
> > be "renamed from" and "renamed to" headers which will disambiguate
> > things. Still, it doesn't seem like a good idea to allow such
> > ambiguities in the first place.
>
> You already realized that there is no ambiguity because "diff --git" lines
> are parsable and renames have explicit names. Why do you still maintain
> that we are allowing such "ambiguities" when there is none?
Don't get so aroused ...
Right now, git generates lines like "diff --git a/f a/f b/f b/f" in some
corner cases, and from such lines alone, it is not possible to tell what the
two file names are (either "a/f a/f" and "b/f b/f", or "a/f a/f b/f" and
"b/f"). I can only find that out by looking at the other header lines.
I would prefer a format which I can parse line by line without ambiguities in
the first place, because this would keep things much simpler and easier to
debug. (Think of other implementations of the extended diff format which may
not produce the exact same output as git.)
So I would be happy with either of this:
* Also quote spaces in the "diff --git" line so that I can always reliably
parse it, or
* Add an additional extended header line with the file name in case there
are no other header lines giving the file names away already (as for
renames, copies, or when there are "---" and "+++" lines).
After our discussion so far, option two would probably be easier for everyone:
you could add it without risking to break anything, and I could avoid parsing
the "diff --git" line altogether.
> >> Having said all that, I don't think we would mind a change to treat a
> >> pathname with trailing SP a bit specially (iow, quoting "c file " in the
> >> above failed attempt to reproduce the issue).
> >
> > I would prefer quoting file names which contain spaces anywhere,...
>
> The only reason I said I don't think we would mind changing the trailing
> SP case is because the reduced risk of getting our patches corrupted by
> MUA _might_ outweigh the benefit of not quoting to avoid an eyesore [*1*].
>
> But what you said would add to eyesore of quoted names (which you omitted
> from your quote) without any justification other than "I would prefer".
> The pros-and-cons in such a change is quite different; as we have already
> established that there is no ambiguity, "disambuguation" is not a "pro" in
> this comparison.
>
> [Footnote]
>
> *1* Strictly speaking, it is not just "an eyesore" that is an issue. Our
> diff output without renames are designed to be grokkable by other people's
> patch implementations (e.g. GNU patch), and the quoted pathnames are not
> understandable by them.
GNU patch doesn't look at "diff --git" lines or extended header lines at all
so far, so there are no compatibility issues yet. Quoting spaces in "---" and
"+++" lines would lead to problems with current GNU patch though. (So does
the quoting of several other characters like ", of course.)
> Even though our final version of quoted path format came from the GNU
> diff/patch maintainer (back then, at least):
>
> http://article.gmane.org/gmane.comp.version-control.git/10103
>
> I don't think it happened in the GNU land yet, and you would be the person
> to know about it ;-).
I'm working on it ...
Thanks,
Andreas
^ permalink raw reply
* [PATCH v3 3/3] Smart-http tests: Test http-backend without curl or a webserver
From: Tarmigan Casebolt @ 2010-01-02 20:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Shawn O . Pearce, Tarmigan Casebolt
In-Reply-To: <905315641001021244o522ac092g7fdaaab83a2609e2@mail.gmail.com>
This reuses many of the tests from t5560 but runs those tests without
curl or a webserver. This will hopefully increase the testing
coverage for http-backend because it does not require users to set
GIT_TEST_HTTPD.
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
t/t5561-http-backend-noserver.sh | 30 ++++++++++++++++++++++++------
t/t556x_common | 3 +++
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/t/t5561-http-backend-noserver.sh b/t/t5561-http-backend-noserver.sh
index a9ba2d9..9013824 100755
--- a/t/t5561-http-backend-noserver.sh
+++ b/t/t5561-http-backend-noserver.sh
@@ -6,18 +6,36 @@ test_description='test git-http-backend-noserver'
HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
run_backend() {
- REQUEST_METHOD=GET \
+ echo "$2"| \
+ QUERY_STRING="${1#*\?}" \
GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
- PATH_INFO="$1" \
+ PATH_INFO="${1%%\?*}" \
git http-backend >act.out 2>act.err
}
GET() {
- return 0
+ REQUEST_METHOD="GET" \
+ run_backend "/repo.git/$1" &&
+ grep "Status" act.out >act
+ if [ $? -eq 1 ];
+ then
+ printf "Status: 200 OK\r\n" > act
+ fi
+ printf "Status: $2\r\n" > exp &&
+ test_cmp exp act
}
POST() {
- return 0
+ REQUEST_METHOD="POST" \
+ CONTENT_TYPE="application/x-$1-request" \
+ run_backend "/repo.git/$1" "$2" &&
+ grep "Status" act.out >act
+ if [ $? -eq 1 ];
+ then
+ printf "Status: 200 OK\r\n" > act
+ fi
+ printf "Status: $3\r\n" > exp &&
+ test_cmp exp act
}
log_div() {
@@ -28,9 +46,9 @@ log_div() {
expect_aliased() {
if test $1 = 0; then
- run_backend "$2"
+ REQUEST_METHOD=GET run_backend "$2"
else
- run_backend "$2" &&
+ REQUEST_METHOD=GET run_backend "$2" &&
echo "fatal: '$2': aliased" >exp.err &&
test_cmp exp.err act.err
fi
diff --git a/t/t556x_common b/t/t556x_common
index 1b4921c..be024e5 100755
--- a/t/t556x_common
+++ b/t/t556x_common
@@ -50,6 +50,7 @@ get_static_files() {
}
SMART=smart
+export GIT_HTTP_EXPORT_ALL=1
test_expect_success 'direct refs/heads/master not found' '
log_div "refs/heads/master"
GET refs/heads/master "404 Not Found"
@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '
get_static_files "200 OK"
'
SMART=smart_noexport
+unset GIT_HTTP_EXPORT_ALL
test_expect_success 'no export by default' '
log_div "no git-daemon-export-ok"
get_static_files "404 Not Found"
@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '
get_static_files "200 OK"
'
SMART=smart
+export GIT_HTTP_EXPORT_ALL=1
test_expect_success 'static file if http.getanyfile true is ok' '
log_div "getanyfile true"
config http.getanyfile true &&
--
1.6.6
^ permalink raw reply related
* [PATCH v3 2/3] Smart-http tests: Break test t5560-http-backend into pieces
From: Tarmigan Casebolt @ 2010-01-02 20:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Shawn O . Pearce, Tarmigan Casebolt
In-Reply-To: <905315641001021244o522ac092g7fdaaab83a2609e2@mail.gmail.com>
This should introduce no functional change in the tests or the amount
of test coverage.
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
t/t5560-http-backend.sh | 147 +-------------------------------------
t/t5561-http-backend-noserver.sh | 52 +++++++++++++
t/t556x_common | 119 ++++++++++++++++++++++++++++++
3 files changed, 172 insertions(+), 146 deletions(-)
create mode 100755 t/t5561-http-backend-noserver.sh
create mode 100755 t/t556x_common
diff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh
index 0e4dc4b..dd844d3 100755
--- a/t/t5560-http-backend.sh
+++ b/t/t5560-http-backend.sh
@@ -12,16 +12,6 @@ LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5560'}
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
-find_file() {
- cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- find $1 -type f |
- sed -e 1q
-}
-
-config() {
- git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config $1 $2
-}
-
GET() {
curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null &&
tr '\015' Q <out |
@@ -52,142 +42,7 @@ log_div() {
echo "###" >>"$HTTPD_ROOT_PATH"/access.log
}
-test_expect_success 'setup repository' '
- echo content >file &&
- git add file &&
- git commit -m one &&
-
- mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- git --bare init &&
- : >objects/info/alternates &&
- : >objects/info/http-alternates
- ) &&
- git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- git push public master:master &&
-
- (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- git repack -a -d
- ) &&
-
- echo other >file &&
- git add file &&
- git commit -m two &&
- git push public master:master &&
-
- LOOSE_URL=$(find_file objects/??) &&
- PACK_URL=$(find_file objects/pack/*.pack) &&
- IDX_URL=$(find_file objects/pack/*.idx)
-'
-
-get_static_files() {
- GET HEAD "$1" &&
- GET info/refs "$1" &&
- GET objects/info/packs "$1" &&
- GET objects/info/alternates "$1" &&
- GET objects/info/http-alternates "$1" &&
- GET $LOOSE_URL "$1" &&
- GET $PACK_URL "$1" &&
- GET $IDX_URL "$1"
-}
-
-SMART=smart
-test_expect_success 'direct refs/heads/master not found' '
- log_div "refs/heads/master"
- GET refs/heads/master "404 Not Found"
-'
-test_expect_success 'static file is ok' '
- log_div "getanyfile default"
- get_static_files "200 OK"
-'
-SMART=smart_noexport
-test_expect_success 'no export by default' '
- log_div "no git-daemon-export-ok"
- get_static_files "404 Not Found"
-'
-test_expect_success 'export if git-daemon-export-ok' '
- log_div "git-daemon-export-ok"
- (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
- touch git-daemon-export-ok
- ) &&
- get_static_files "200 OK"
-'
-SMART=smart
-test_expect_success 'static file if http.getanyfile true is ok' '
- log_div "getanyfile true"
- config http.getanyfile true &&
- get_static_files "200 OK"
-'
-test_expect_success 'static file if http.getanyfile false fails' '
- log_div "getanyfile false"
- config http.getanyfile false &&
- get_static_files "403 Forbidden"
-'
-
-test_expect_success 'http.uploadpack default enabled' '
- log_div "uploadpack default"
- GET info/refs?service=git-upload-pack "200 OK" &&
- POST git-upload-pack 0000 "200 OK"
-'
-test_expect_success 'http.uploadpack true' '
- log_div "uploadpack true"
- config http.uploadpack true &&
- GET info/refs?service=git-upload-pack "200 OK" &&
- POST git-upload-pack 0000 "200 OK"
-'
-test_expect_success 'http.uploadpack false' '
- log_div "uploadpack false"
- config http.uploadpack false &&
- GET info/refs?service=git-upload-pack "403 Forbidden" &&
- POST git-upload-pack 0000 "403 Forbidden"
-'
-
-test_expect_success 'http.receivepack default disabled' '
- log_div "receivepack default"
- GET info/refs?service=git-receive-pack "403 Forbidden" &&
- POST git-receive-pack 0000 "403 Forbidden"
-'
-test_expect_success 'http.receivepack true' '
- log_div "receivepack true"
- config http.receivepack true &&
- GET info/refs?service=git-receive-pack "200 OK" &&
- POST git-receive-pack 0000 "200 OK"
-'
-test_expect_success 'http.receivepack false' '
- log_div "receivepack false"
- config http.receivepack false &&
- GET info/refs?service=git-receive-pack "403 Forbidden" &&
- POST git-receive-pack 0000 "403 Forbidden"
-'
-run_backend() {
- REQUEST_METHOD=GET \
- GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
- PATH_INFO="$1" \
- git http-backend >act.out 2>act.err
-}
-
-expect_aliased() {
- if test $1 = 0; then
- run_backend "$2"
- else
- run_backend "$2" &&
- echo "fatal: '$2': aliased" >exp.err &&
- test_cmp exp.err act.err
- fi
-}
-
-test_expect_success 'http-backend blocks bad PATH_INFO' '
- config http.getanyfile true &&
-
- expect_aliased 0 /repo.git/HEAD &&
-
- expect_aliased 1 /repo.git/../HEAD &&
- expect_aliased 1 /../etc/passwd &&
- expect_aliased 1 ../etc/passwd &&
- expect_aliased 1 /etc//passwd &&
- expect_aliased 1 /etc/./passwd &&
- expect_aliased 1 //domain/data.txt
-'
+. "$TEST_DIRECTORY"/t556x_common
cat >exp <<EOF
diff --git a/t/t5561-http-backend-noserver.sh b/t/t5561-http-backend-noserver.sh
new file mode 100755
index 0000000..a9ba2d9
--- /dev/null
+++ b/t/t5561-http-backend-noserver.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+test_description='test git-http-backend-noserver'
+. ./test-lib.sh
+
+HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
+
+run_backend() {
+ REQUEST_METHOD=GET \
+ GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
+ PATH_INFO="$1" \
+ git http-backend >act.out 2>act.err
+}
+
+GET() {
+ return 0
+}
+
+POST() {
+ return 0
+}
+
+log_div() {
+ return 0
+}
+
+. "$TEST_DIRECTORY"/t556x_common
+
+expect_aliased() {
+ if test $1 = 0; then
+ run_backend "$2"
+ else
+ run_backend "$2" &&
+ echo "fatal: '$2': aliased" >exp.err &&
+ test_cmp exp.err act.err
+ fi
+}
+
+test_expect_success 'http-backend blocks bad PATH_INFO' '
+ config http.getanyfile true &&
+
+ expect_aliased 0 /repo.git/HEAD &&
+
+ expect_aliased 1 /repo.git/../HEAD &&
+ expect_aliased 1 /../etc/passwd &&
+ expect_aliased 1 ../etc/passwd &&
+ expect_aliased 1 /etc//passwd &&
+ expect_aliased 1 /etc/./passwd &&
+ expect_aliased 1 //domain/data.txt
+'
+
+test_done
diff --git a/t/t556x_common b/t/t556x_common
new file mode 100755
index 0000000..1b4921c
--- /dev/null
+++ b/t/t556x_common
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+find_file() {
+ cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ find $1 -type f |
+ sed -e 1q
+}
+
+config() {
+ git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config $1 $2
+}
+
+test_expect_success 'setup repository' '
+ echo content >file &&
+ git add file &&
+ git commit -m one &&
+
+ mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git --bare init &&
+ : >objects/info/alternates &&
+ : >objects/info/http-alternates
+ ) &&
+ git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git push public master:master &&
+
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git repack -a -d
+ ) &&
+
+ echo other >file &&
+ git add file &&
+ git commit -m two &&
+ git push public master:master &&
+
+ LOOSE_URL=$(find_file objects/??) &&
+ PACK_URL=$(find_file objects/pack/*.pack) &&
+ IDX_URL=$(find_file objects/pack/*.idx)
+'
+
+get_static_files() {
+ GET HEAD "$1" &&
+ GET info/refs "$1" &&
+ GET objects/info/packs "$1" &&
+ GET objects/info/alternates "$1" &&
+ GET objects/info/http-alternates "$1" &&
+ GET $LOOSE_URL "$1" &&
+ GET $PACK_URL "$1" &&
+ GET $IDX_URL "$1"
+}
+
+SMART=smart
+test_expect_success 'direct refs/heads/master not found' '
+ log_div "refs/heads/master"
+ GET refs/heads/master "404 Not Found"
+'
+test_expect_success 'static file is ok' '
+ log_div "getanyfile default"
+ get_static_files "200 OK"
+'
+SMART=smart_noexport
+test_expect_success 'no export by default' '
+ log_div "no git-daemon-export-ok"
+ get_static_files "404 Not Found"
+'
+test_expect_success 'export if git-daemon-export-ok' '
+ log_div "git-daemon-export-ok"
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ touch git-daemon-export-ok
+ ) &&
+ get_static_files "200 OK"
+'
+SMART=smart
+test_expect_success 'static file if http.getanyfile true is ok' '
+ log_div "getanyfile true"
+ config http.getanyfile true &&
+ get_static_files "200 OK"
+'
+test_expect_success 'static file if http.getanyfile false fails' '
+ log_div "getanyfile false"
+ config http.getanyfile false &&
+ get_static_files "403 Forbidden"
+'
+
+test_expect_success 'http.uploadpack default enabled' '
+ log_div "uploadpack default"
+ GET info/refs?service=git-upload-pack "200 OK" &&
+ POST git-upload-pack 0000 "200 OK"
+'
+test_expect_success 'http.uploadpack true' '
+ log_div "uploadpack true"
+ config http.uploadpack true &&
+ GET info/refs?service=git-upload-pack "200 OK" &&
+ POST git-upload-pack 0000 "200 OK"
+'
+test_expect_success 'http.uploadpack false' '
+ log_div "uploadpack false"
+ config http.uploadpack false &&
+ GET info/refs?service=git-upload-pack "403 Forbidden" &&
+ POST git-upload-pack 0000 "403 Forbidden"
+'
+
+test_expect_success 'http.receivepack default disabled' '
+ log_div "receivepack default"
+ GET info/refs?service=git-receive-pack "403 Forbidden" &&
+ POST git-receive-pack 0000 "403 Forbidden"
+'
+test_expect_success 'http.receivepack true' '
+ log_div "receivepack true"
+ config http.receivepack true &&
+ GET info/refs?service=git-receive-pack "200 OK" &&
+ POST git-receive-pack 0000 "200 OK"
+'
+test_expect_success 'http.receivepack false' '
+ log_div "receivepack false"
+ config http.receivepack false &&
+ GET info/refs?service=git-receive-pack "403 Forbidden" &&
+ POST git-receive-pack 0000 "403 Forbidden"
+'
--
1.6.6
^ permalink raw reply related
* [PATCH v3 RFC 1/3] Smart-http tests: Improve coverage in test t5560
From: Tarmigan Casebolt @ 2010-01-02 20:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Shawn O . Pearce, Tarmigan Casebolt
In-Reply-To: <905315641001021244o522ac092g7fdaaab83a2609e2@mail.gmail.com>
Commit 34b6cb8bb ("http-backend: Protect GIT_PROJECT_ROOT from /../
requests") added the path_info helper function to test t5560 but did
not use it. We should use it as it provides another level of error
checking.
The /etc/.../passwd case is one that is not special (and the test
fails for reasons other than being aliased), so we remove that test
case.
Also rename the function from 'path_info' to 'expect_aliased'.
cc: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
One thing to note is that
expect_aliased 0 /repo.git/HEAD
test still does not actually test any results back from http-backend,
but that's also how it was before as well.
---
t/t5560-http-backend.sh | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh
index 04a9896..0e4dc4b 100755
--- a/t/t5560-http-backend.sh
+++ b/t/t5560-http-backend.sh
@@ -162,15 +162,15 @@ test_expect_success 'http.receivepack false' '
run_backend() {
REQUEST_METHOD=GET \
GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
- PATH_INFO="$2" \
+ PATH_INFO="$1" \
git http-backend >act.out 2>act.err
}
-path_info() {
+expect_aliased() {
if test $1 = 0; then
run_backend "$2"
else
- test_must_fail run_backend "$2" &&
+ run_backend "$2" &&
echo "fatal: '$2': aliased" >exp.err &&
test_cmp exp.err act.err
fi
@@ -179,15 +179,14 @@ path_info() {
test_expect_success 'http-backend blocks bad PATH_INFO' '
config http.getanyfile true &&
- run_backend 0 /repo.git/HEAD &&
+ expect_aliased 0 /repo.git/HEAD &&
- run_backend 1 /repo.git/../HEAD &&
- run_backend 1 /../etc/passwd &&
- run_backend 1 ../etc/passwd &&
- run_backend 1 /etc//passwd &&
- run_backend 1 /etc/./passwd &&
- run_backend 1 /etc/.../passwd &&
- run_backend 1 //domain/data.txt
+ expect_aliased 1 /repo.git/../HEAD &&
+ expect_aliased 1 /../etc/passwd &&
+ expect_aliased 1 ../etc/passwd &&
+ expect_aliased 1 /etc//passwd &&
+ expect_aliased 1 /etc/./passwd &&
+ expect_aliased 1 //domain/data.txt
'
cat >exp <<EOF
--
1.6.6
^ permalink raw reply related
* Re: [PATCH RFC 1/2] Smart-http tests: Break test t5560-http-backend into pieces
From: Tarmigan @ 2010-01-02 20:44 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O . Pearce, git
In-Reply-To: <7viqbmo173.fsf@alter.siamese.dyndns.org>
On Thu, Dec 31, 2009 at 9:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Tarmigan <tarmigan+git@gmail.com> writes:
>
>> One reason it's labeled RFC is that I'm not very confident in my
>> ability to write portable shell script. It works for me with bash,
>> but I'm not completely confident that is would work on ksh or dash.
>> So it would be nice if you could specifically take a look at the new
>> POST() and GET() and see if you notice anything obviously wrong there.
>
> Looked Ok to me from a cursory reading, even though I wonder what the
> first argument to run_backend function is good for...
Thanks for looking. I used the run_backend that was introduced in
34b6cb8bb, but looking more closely, it seems that the "http-backend
blocks bad PATH_INFO" test wasn't actually checking anything. It
seems the path_info function was intended to be used, but never
actually was. I'm embarrassed to say that I was so focused on "no
changes to existing tests" that I wasn't thinking about the bigger
picture.
I have made a patch to address this, and have made it the first in the
series. I would like to have Shawn's ack on at least that first
patch, as I was trying to guess at his original intention with that
test.
Thanks,
Tarmigan
^ permalink raw reply
* [PATCH] Use warning function instead of fprintf(stderr, "Warning: ...").
From: Thiago Farina @ 2010-01-02 20:24 UTC (permalink / raw)
To: git
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
---
bisect.c | 2 +-
builtin-mv.c | 4 +---
http.c | 2 +-
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/bisect.c b/bisect.c
index dc18db8..d1f8c42 100644
--- a/bisect.c
+++ b/bisect.c
@@ -813,7 +813,7 @@ static void handle_skipped_merge_base(const unsigned char *mb)
char *bad_hex = sha1_to_hex(current_bad_sha1);
char *good_hex = join_sha1_array_hex(&good_revs, ' ');
- fprintf(stderr, "Warning: the merge base between %s and [%s] "
+ warning("the merge base between %s and [%s] "
"must be skipped.\n"
"So we cannot be sure the first bad commit is "
"between %s and %s.\n"
diff --git a/builtin-mv.c b/builtin-mv.c
index f633d81..8ad7245 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -169,9 +169,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
* check both source and destination
*/
if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
- fprintf(stderr, "Warning: %s;"
- " will overwrite!\n",
- bad);
+ warning("%s; will overwrite!\n", bad);
bad = NULL;
} else
bad = "Cannot overwrite";
diff --git a/http.c b/http.c
index ed6414a..afce7c3 100644
--- a/http.c
+++ b/http.c
@@ -1244,7 +1244,7 @@ int finish_http_object_request(struct http_object_request *freq)
process_http_object_request(freq);
if (freq->http_code == 416) {
- fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
+ warning("requested range invalid; we may already have all the data.\n");
} else if (freq->curl_result != CURLE_OK) {
if (stat(freq->tmpfile, &st) == 0)
if (st.st_size == 0)
--
1.6.6.rc3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox