From: Junio C Hamano Date: Tue, 14 Dec 2010 15:36:10 +0000 (-0800) Subject: Merge branch 'tc/http-urls-ends-with-slash' into maint X-Git-Tag: v1.7.3.4~10 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6b090e1710dbdf3f2c9f46c7f089ce34399b35c5?ds=inline;hp=-c Merge branch 'tc/http-urls-ends-with-slash' into maint * tc/http-urls-ends-with-slash: http-fetch: rework url handling http-push: add trailing slash at arg-parse time, instead of later on http-push: check path length before using it http-push: Normalise directory names when pushing to some WebDAV servers http-backend: use end_url_with_slash() url: add str wrapper for end_url_with_slash() shift end_url_with_slash() from http.[ch] to url.[ch] t5550-http-fetch: add test for http-fetch t5550-http-fetch: add missing '&&' --- 6b090e1710dbdf3f2c9f46c7f089ce34399b35c5 diff --combined Makefile index cd0f648172,90aaa30e7f..f2de401e29 --- a/Makefile +++ b/Makefile @@@ -1879,7 -1879,7 +1879,7 @@@ builtin/tar-tree.o archive-tar.o: tar. builtin/pack-objects.o: thread-utils.h connect.o transport.o http-backend.o: url.h http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h - http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h + http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h url.h xdiff-interface.o $(XDIFF_OBJS): \ xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \ @@@ -1921,7 -1921,7 +1921,7 @@@ git-%$X: %.o $(GITLIBS git-imap-send$X: imap-send.o $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ - $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) + $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO) git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ @@@ -1977,7 -1977,7 +1977,7 @@@ cscope $(FIND) . -name '*.[hcS]' -print | xargs cscope -b ### Detect prefix changes -TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\ +TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\ $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ) GIT-CFLAGS: FORCE diff --combined http.c index f582b13b91,3b3da12e0f..9e767723ed --- a/http.c +++ b/http.c @@@ -280,11 -280,6 +280,11 @@@ static CURL *get_curl_handle(void } curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1); +#if LIBCURL_VERSION_NUM >= 0x071301 + curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL); +#elif LIBCURL_VERSION_NUM >= 0x071101 + curl_easy_setopt(result, CURLOPT_POST301, 1); +#endif if (getenv("GIT_CURL_VERBOSE")) curl_easy_setopt(result, CURLOPT_VERBOSE, 1); @@@ -303,7 -298,7 +303,7 @@@ static void http_auth_init(const char *url) { - char *at, *colon, *cp, *slash; + char *at, *colon, *cp, *slash, *decoded; int len; cp = strstr(url, "://"); @@@ -328,25 -323,16 +328,25 @@@ user_name = xmalloc(len + 1); memcpy(user_name, cp, len); user_name[len] = '\0'; + decoded = url_decode(user_name); + free(user_name); + user_name = decoded; user_pass = NULL; } else { len = colon - cp; user_name = xmalloc(len + 1); memcpy(user_name, cp, len); user_name[len] = '\0'; + decoded = url_decode(user_name); + free(user_name); + user_name = decoded; len = at - (colon + 1); user_pass = xmalloc(len + 1); memcpy(user_pass, colon + 1, len); user_pass[len] = '\0'; + decoded = url_decode(user_pass); + free(user_pass); + user_pass = decoded; } } @@@ -743,13 -729,6 +743,6 @@@ static inline int hex(int v return 'A' + v - 10; } - void end_url_with_slash(struct strbuf *buf, const char *url) - { - strbuf_addstr(buf, url); - if (buf->len && buf->buf[buf->len - 1] != '/') - strbuf_addstr(buf, "/"); - } - static char *quote_ref_url(const char *base, const char *ref) { struct strbuf buf = STRBUF_INIT; diff --combined t/t5550-http-fetch.sh index 8c2ac353b7,d3bf5cefb1..a1883ca6b6 --- a/t/t5550-http-fetch.sh +++ b/t/t5550-http-fetch.sh @@@ -30,25 -30,30 +30,37 @@@ test_expect_success 'create http-access ' test_expect_success 'clone http repository' ' - git clone $HTTPD_URL/dumb/repo.git clone && + git clone $HTTPD_URL/dumb/repo.git clone-tmpl && + cp -R clone-tmpl clone && test_cmp file clone/file ' +test_expect_success 'clone http repository with authentication' ' + mkdir "$HTTPD_DOCUMENT_ROOT_PATH/auth/" && + cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" "$HTTPD_DOCUMENT_ROOT_PATH/auth/repo.git" && + git clone $AUTH_HTTPD_URL/auth/repo.git clone-auth && + test_cmp file clone-auth/file +' + test_expect_success 'fetch changes via http' ' echo content >>file && git commit -a -m two && - git push public + git push public && (cd clone && git pull) && test_cmp file clone/file ' + test_expect_success 'fetch changes via manual http-fetch' ' + cp -R clone-tmpl clone2 && + + HEAD=$(git rev-parse --verify HEAD) && + (cd clone2 && + git http-fetch -a -w heads/master-new $HEAD $(git config remote.origin.url) && + git checkout master-new && + test $HEAD = $(git rev-parse --verify HEAD)) && + test_cmp file clone2/file + ' + test_expect_success 'http remote detects correct HEAD' ' git push public master:other && (cd clone &&