summaryrefslogtreecommitdiff
path: root/url.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2010-12-14 07:36:10 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-12-14 07:36:10 -0800
commit6b090e1710dbdf3f2c9f46c7f089ce34399b35c5 (patch)
tree5103919c6668e99e22db598c0f57299e14c6393b /url.c
parentMerge branch 'nd/maint-hide-checkout-index-from-error' into maint (diff)
parenthttp-fetch: rework url handling (diff)
downloadtgif-6b090e1710dbdf3f2c9f46c7f089ce34399b35c5.tar.xz
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 '&&'
Diffstat (limited to 'url.c')
-rw-r--r--url.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/url.c b/url.c
index cd8f74f00c..6a5495960f 100644
--- a/url.c
+++ b/url.c
@@ -125,3 +125,17 @@ char *url_decode_parameter_value(const char **query)
struct strbuf out = STRBUF_INIT;
return url_decode_internal(query, "&", &out, 1);
}
+
+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, "/");
+}
+
+void str_end_url_with_slash(const char *url, char **dest) {
+ struct strbuf buf = STRBUF_INIT;
+ end_url_with_slash(&buf, url);
+ free(*dest);
+ *dest = strbuf_detach(&buf, NULL);
+}