On 21.03.2012 21:17, Jeff King wrote:
On Wed, Mar 21, 2012 at 09:02:13PM +0100, Ivan Todoroski wrote:
Something in me feels slightly uncomfortable with that, just because
simple newline-delimited formats make it easy for people to hack on the
tool and feed input from unexpected sources.
I understand what you mean. How about this:
If both --stdin and --stateless-rpc are specified to fetch-pack, it
will use pkt-line to read the refs from stdin before handing off
stdin to get_remote_heads().
However, if only --stdin is specified, it will read refs from stdin
in a script-friendly newline delimited format, one ref per line. This
is okay because when --stateless-rpc is not specified
get_remote_heads() reads from an fd different from stdin so there is
no issue with residual buffers in this case.
This way you preserve scriptability for any other callers who don't
use --stateless-rpc.
How does this sound?
I think that sounds quite reasonable, and shouldn't be more than a few
extra lines to implement.
-Peff
I wrote the code for this and went to write the test cases, but the test
suite is not cooperating. :(
I'll send just the code changes for comments while I'm figuring out the
test suite. I'll include the test cases along with better commit
messages in the next version of the patches.
So, back to the test suite problem. To get familiar with it I first ran
the test suite against the vanilla "maint" branch without any of my
changes, just to see what I should expect on properly running code.
Unfortunately it failed, and to make matters worse it failed exactly on
the parts dealing with smart HTTP, which is what I need to test in the
first place. Talk about Murphy's law...
Is it failing for anyone else on the vanilla "maint" branch? I would
appreciate any help I could get here.
My machine is CentOS 5.8 with latest updates and I have the httpd
package installed. Here is the command that is failing (you can find the
full output in the attachment):
$ GIT_TEST_HTTPD=yes ./t5551-http-fetch.sh -i -v
[... skip successful tests ...]
ok 5 - used upload-pack service
expecting success:
git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
error: RPC failed; result=22, HTTP code = 405
fatal: The remote end hung up unexpectedly
not ok - 6 follow redirects (301)
#
# git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet
repo-p
#
Initialized empty Git repository in /home/itodoroski/git/t/trash directory.t5551-http-fetch/.git/
expecting success:
echo content >file &&
git add file &&
git commit -m one
[master (root-commit) ba36540] one
Author: A U Thor <author@xxxxxxxxxxx>
1 file changed, 1 insertion(+)
create mode 100644 file
ok 1 - setup repository
expecting success:
mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
git --bare init
) &&
git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
git push public master:master
Initialized empty Git repository in /home/itodoroski/git/t/trash directory.t5551-http-fetch/httpd/www/repo.git/
To /home/itodoroski/git/t/trash directory.t5551-http-fetch/httpd/www/repo.git
* [new branch] master -> master
ok 2 - create http-accessible bare repository
expecting success:
GIT_CURL_VERBOSE=1 git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
test_cmp file clone/file &&
tr '\015' Q <err |
sed -e "
s/Q\$//
/^[*] /d
/^$/d
/^< $/d
/^[^><]/{
s/^/> /
}
/^> User-Agent: /d
/^> Host: /d
/^> POST /,$ {
/^> Accept: [*]\\/[*]/d
}
s/^> Content-Length: .*/> Content-Length: xxx/
/^> 00..want /d
/^> 00.*done/d
/^< Server: /d
/^< Expires: /d
/^< Date: /d
/^< Content-Length: /d
/^< Transfer-Encoding: /d
" >act &&
test_cmp exp act
ok 3 - clone http repository
expecting success:
echo content >>file &&
git commit -a -m two &&
git push public
(cd clone && git pull) &&
test_cmp file clone/file
[master ace4881] two
Author: A U Thor <author@xxxxxxxxxxx>
1 file changed, 1 insertion(+)
To /home/itodoroski/git/t/trash directory.t5551-http-fetch/httpd/www/repo.git
ba36540..ace4881 master -> master
From http://127.0.0.1:5551/smart/repo
ba36540..ace4881 master -> origin/master
Updating ba36540..ace4881
Fast-forward
file | 1 +
1 file changed, 1 insertion(+)
ok 4 - fetch changes via http
expecting success:
sed -e "
s/^.* \"//
s/\"//
s/ [1-9][0-9]*\$//
s/^GET /GET /
" >act <"$HTTPD_ROOT_PATH"/access.log &&
test_cmp exp act
ok 5 - used upload-pack service
expecting success:
git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
error: RPC failed; result=22, HTTP code = 405
fatal: The remote end hung up unexpectedly
not ok - 6 follow redirects (301)
#
# git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
#