X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=http-push.c;h=ff41a0e183dd3a449f5136c6d1488a31b4a8960b;hb=3f142468997f9d14d8051a96b2e9db265d41ac0d;hp=c9bcd116975635cabf30eceb7909abfc7f341948;hpb=6296062285e07051a5a46cbbd74c67a10bf2ac16;p=git.git diff --git a/http-push.c b/http-push.c index c9bcd1169..ff41a0e18 100644 --- a/http-push.c +++ b/http-push.c @@ -1090,6 +1090,10 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed) if (tag_closed) { if (!strcmp(ctx->name, DAV_PROPFIND_RESP) && ls->dentry_name) { if (ls->dentry_flags & IS_DIR) { + + /* ensure collection names end with slash */ + str_end_url_with_slash(ls->dentry_name, &ls->dentry_name); + if (ls->flags & PROCESS_DIRS) { ls->userFunc(ls); } @@ -1112,8 +1116,16 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed) } } if (path) { - path += repo->path_len; - ls->dentry_name = xstrdup(path); + const char *url = repo->url; + if (repo->path) + url = repo->path; + if (strncmp(path, url, repo->path_len)) + error("Parsed path '%s' does not match url: '%s'\n", + path, url); + else { + path += repo->path_len; + ls->dentry_name = xstrdup(path); + } } } else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) { ls->dentry_flags |= IS_DIR; @@ -1789,7 +1801,6 @@ int main(int argc, char **argv) int new_refs; struct ref *ref, *local_refs; struct remote *remote; - char *rewritten_url = NULL; git_extract_argv0_path(argv[0]); @@ -1835,8 +1846,8 @@ int main(int argc, char **argv) } if (!repo->url) { char *path = strstr(arg, "//"); - repo->url = arg; - repo->path_len = strlen(arg); + str_end_url_with_slash(arg, &repo->url); + repo->path_len = strlen(repo->url); if (path) { repo->path = strchr(path+2, '/'); if (repo->path) @@ -1872,15 +1883,6 @@ int main(int argc, char **argv) remote->url[remote->url_nr++] = repo->url; http_init(remote); - if (repo->url && repo->url[strlen(repo->url)-1] != '/') { - rewritten_url = xmalloc(strlen(repo->url)+2); - strcpy(rewritten_url, repo->url); - strcat(rewritten_url, "/"); - repo->path = rewritten_url + (repo->path - repo->url); - repo->path_len++; - repo->url = rewritten_url; - } - #ifdef USE_CURL_MULTI is_running_queue = 0; #endif @@ -2088,7 +2090,6 @@ int main(int argc, char **argv) } cleanup: - free(rewritten_url); if (info_ref_lock) unlock_remote(info_ref_lock); free(repo);