From 703e6e76a14825e5b0c960d525f34e607154b4f7 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Thu, 21 Jan 2010 22:41:00 +0800 Subject: [PATCH 1/2] retry request without query when info/refs?query fails When "info/refs" is a static file and not behind a CGI handler, some servers may not handle a GET request for it with a query string appended (eg. "?foo=bar") properly. If such a request fails, retry it sans the query string. In addition, ensure that the "smart" http protocol is not used (a service has to be specified with "?service=" to be conformant). Signed-off-by: Tay Ray Chuan Reported-and-tested-by: Yaroslav Halchenko Acked-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- remote-curl.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/remote-curl.c b/remote-curl.c index 8f169ddca0fd46..3edbf5717c94f3 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -102,7 +102,7 @@ static struct discovery* discover_refs(const char *service) struct strbuf buffer = STRBUF_INIT; struct discovery *last = last_discovery; char *refs_url; - int http_ret, is_http = 0; + int http_ret, is_http = 0, proto_git_candidate = 1; if (last && !strcmp(service, last->service)) return last; @@ -121,6 +121,19 @@ static struct discovery* discover_refs(const char *service) init_walker(); http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE); + + /* try again with "plain" url (no ? or & appended) */ + if (http_ret != HTTP_OK) { + free(refs_url); + strbuf_reset(&buffer); + + proto_git_candidate = 0; + strbuf_addf(&buffer, "%s/info/refs", url); + refs_url = strbuf_detach(&buffer, NULL); + + http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE); + } + switch (http_ret) { case HTTP_OK: break; @@ -137,7 +150,8 @@ static struct discovery* discover_refs(const char *service) last->buf_alloc = strbuf_detach(&buffer, &last->len); last->buf = last->buf_alloc; - if (is_http && 5 <= last->len && last->buf[4] == '#') { + if (is_http && proto_git_candidate + && 5 <= last->len && last->buf[4] == '#') { /* smart HTTP response; validate that the service * pkt-line matches our request. */ From 19c6a4f8369f37c0df1fb57008a891eb6a6dc4bb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 21 Jan 2010 16:38:56 -0800 Subject: [PATCH 2/2] merge-recursive: do not return NULL only to cause segfault merge-recursive calls write_tree_from_memory() to come up with a virtual tree, with possible conflict markers inside the blob contents, while merging multiple common ancestors down. It is a bug to call the function with unmerged entries in the index, even if the merge to come up with the common ancestor resulted in conflicts. Otherwise the result won't be expressible as a tree object. We _might_ want to suggest the user to set GIT_MERGE_VERBOSITY to 5 and re-run the merge in the message. At least we will know which part of process_renames() or process_entry() functions is not correctly handling the unmerged paths, and it might help us diagnosing the issue. Signed-off-by: Junio C Hamano --- merge-recursive.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/merge-recursive.c b/merge-recursive.c index dd4fbd0e6bc22f..22a31ed5ff5d1a 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -200,14 +200,14 @@ struct tree *write_tree_from_memory(struct merge_options *o) if (unmerged_cache()) { int i; - output(o, 0, "There are unmerged index entries:"); + fprintf(stderr, "BUG: There are unmerged index entries:\n"); for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; if (ce_stage(ce)) - output(o, 0, "%d %.*s", ce_stage(ce), - (int)ce_namelen(ce), ce->name); + fprintf(stderr, "BUG: %d %.*s", ce_stage(ce), + (int)ce_namelen(ce), ce->name); } - return NULL; + die("Bug in merge-recursive.c"); } if (!active_cache_tree)