X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=http-push.c;h=a4b7d08663504a57008f66a39fffe293f62c1d08;hb=49129d3731a6d74ad403ecdffc0e7940a597bc65;hp=5cecef434a7740a3f853462978c3e071b4da7e74;hpb=df5e12f7d405b84de07c3f2dc1afe51b1d594e2c;p=git.git diff --git a/http-push.c b/http-push.c index 5cecef434..a4b7d0866 100644 --- a/http-push.c +++ b/http-push.c @@ -87,6 +87,7 @@ static struct object_list *objects; struct repo { char *url; + char *path; int path_len; int has_info_refs; int can_update_info_refs; @@ -595,7 +596,7 @@ static int refresh_lock(struct remote_lock *lock) lock->refreshing = 1; if_header = xmalloc(strlen(lock->token) + 25); - sprintf(if_header, "If: ()", lock->token); + sprintf(if_header, "If: (<%s>)", lock->token); sprintf(timeout_header, "Timeout: Second-%ld", lock->timeout); dav_headers = curl_slist_append(dav_headers, if_header); dav_headers = curl_slist_append(dav_headers, timeout_header); @@ -1120,10 +1121,8 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed) lock->timeout = strtol(ctx->cdata + 7, NULL, 10); } else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) { - if (!prefixcmp(ctx->cdata, "opaquelocktoken:")) { - lock->token = xmalloc(strlen(ctx->cdata) - 15); - strcpy(lock->token, ctx->cdata + 16); - } + lock->token = xmalloc(strlen(ctx->cdata) + 1); + strcpy(lock->token, ctx->cdata); } } } @@ -1308,7 +1307,7 @@ static int unlock_remote(struct remote_lock *lock) int rc = 0; lock_token_header = xmalloc(strlen(lock->token) + 31); - sprintf(lock_token_header, "Lock-Token: ", + sprintf(lock_token_header, "Lock-Token: <%s>", lock->token); dav_headers = curl_slist_append(dav_headers, lock_token_header); @@ -1426,9 +1425,19 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed) ls->userFunc(ls); } } else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) { - ls->dentry_name = xmalloc(strlen(ctx->cdata) - + char *path = ctx->cdata; + if (*ctx->cdata == 'h') { + path = strstr(path, "//"); + if (path) { + path = strchr(path+2, '/'); + } + } + if (path) { + path += remote->path_len; + } + ls->dentry_name = xmalloc(strlen(path) - remote->path_len + 1); - strcpy(ls->dentry_name, ctx->cdata + remote->path_len); + strcpy(ls->dentry_name, path + remote->path_len); } else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) { ls->dentry_flags |= IS_DIR; } @@ -1722,7 +1731,7 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock) struct curl_slist *dav_headers = NULL; if_header = xmalloc(strlen(lock->token) + 25); - sprintf(if_header, "If: ()", lock->token); + sprintf(if_header, "If: (<%s>)", lock->token); dav_headers = curl_slist_append(dav_headers, if_header); strbuf_addf(&out_buffer.buf, "%s\n", sha1_to_hex(sha1)); @@ -1941,7 +1950,7 @@ static void update_remote_info_refs(struct remote_lock *lock) add_remote_info_ref, &buffer.buf); if (!aborted) { if_header = xmalloc(strlen(lock->token) + 25); - sprintf(if_header, "If: ()", lock->token); + sprintf(if_header, "If: (<%s>)", lock->token); dav_headers = curl_slist_append(dav_headers, if_header); slot = get_active_slot(); @@ -2208,10 +2217,11 @@ int main(int argc, char **argv) if (!remote->url) { char *path = strstr(arg, "//"); remote->url = arg; + remote->path_len = strlen(arg); if (path) { - path = strchr(path+2, '/'); - if (path) - remote->path_len = strlen(path); + remote->path = strchr(path+2, '/'); + if (remote->path) + remote->path_len = strlen(remote->path); } continue; } @@ -2240,8 +2250,9 @@ int main(int argc, char **argv) rewritten_url = xmalloc(strlen(remote->url)+2); strcpy(rewritten_url, remote->url); strcat(rewritten_url, "/"); + remote->path = rewritten_url + (remote->path - remote->url); + remote->path_len++; remote->url = rewritten_url; - ++remote->path_len; } /* Verify DAV compliance/lock support */