From: Junio C Hamano Date: Tue, 20 Dec 2011 00:05:16 +0000 (-0800) Subject: Merge branch 'jk/credentials' X-Git-Tag: v1.7.9-rc0~54 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=367d20ec6b9e8e297537f665fb528346bd0aff27;p=git.git Merge branch 'jk/credentials' * jk/credentials: t: add test harness for external credential helpers credentials: add "store" helper strbuf: add strbuf_add*_urlencode Makefile: unix sockets may not available on some platforms credentials: add "cache" helper docs: end-user documentation for the credential subsystem credential: make relevance of http path configurable credential: add credential.*.username credential: apply helper config http: use credential API to get passwords credential: add function for parsing url components introduce credentials API t5550: fix typo test-lib: add test_config_global variant Conflicts: strbuf.c --- 367d20ec6b9e8e297537f665fb528346bd0aff27 diff --cc http.c index 44fcc4d17,917a1ae7d..8e7266406 --- a/http.c +++ b/http.c @@@ -3,7 -3,9 +3,8 @@@ #include "sideband.h" #include "run-command.h" #include "url.h" + #include "credential.h" -int data_received; int active_requests; int http_is_verbose; size_t http_post_buffer = 16 * LARGE_PACKET_MAX; diff --cc strbuf.c index a84970519,60e5e598d..ff0b96b41 --- a/strbuf.c +++ b/strbuf.c @@@ -398,16 -398,39 +398,53 @@@ int strbuf_read_file(struct strbuf *sb return len; } +void strbuf_add_lines(struct strbuf *out, const char *prefix, + const char *buf, size_t size) +{ + while (size) { + const char *next = memchr(buf, '\n', size); + next = next ? (next + 1) : (buf + size); + strbuf_addstr(out, prefix); + strbuf_add(out, buf, next - buf); + size -= next - buf; + buf = next; + } + strbuf_complete_line(out); +} ++ + static int is_rfc3986_reserved(char ch) + { + switch (ch) { + case '!': case '*': case '\'': case '(': case ')': case ';': + case ':': case '@': case '&': case '=': case '+': case '$': + case ',': case '/': case '?': case '#': case '[': case ']': + return 1; + } + return 0; + } + + static int is_rfc3986_unreserved(char ch) + { + return isalnum(ch) || + ch == '-' || ch == '_' || ch == '.' || ch == '~'; + } + + void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len, + int reserved) + { + strbuf_grow(sb, len); + while (len--) { + char ch = *s++; + if (is_rfc3986_unreserved(ch) || + (!reserved && is_rfc3986_reserved(ch))) + strbuf_addch(sb, ch); + else + strbuf_addf(sb, "%%%02x", ch); + } + } + + void strbuf_addstr_urlencode(struct strbuf *sb, const char *s, + int reserved) + { + strbuf_add_urlencode(sb, s, strlen(s), reserved); + }