Skip to content

Commit 885a1ff

Browse files
committed
Merge branch 'kk/maint-http-push' into maint
* kk/maint-http-push: http-push: support full URI in handle_remote_ls_ctx()
2 parents 94468bc + e1f33ef commit 885a1ff

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

http-push.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static struct object_list *objects;
8787
struct repo
8888
{
8989
char *url;
90+
char *path;
9091
int path_len;
9192
int has_info_refs;
9293
int can_update_info_refs;
@@ -1424,9 +1425,19 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
14241425
ls->userFunc(ls);
14251426
}
14261427
} else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
1427-
ls->dentry_name = xmalloc(strlen(ctx->cdata) -
1428+
char *path = ctx->cdata;
1429+
if (*ctx->cdata == 'h') {
1430+
path = strstr(path, "//");
1431+
if (path) {
1432+
path = strchr(path+2, '/');
1433+
}
1434+
}
1435+
if (path) {
1436+
path += remote->path_len;
1437+
}
1438+
ls->dentry_name = xmalloc(strlen(path) -
14281439
remote->path_len + 1);
1429-
strcpy(ls->dentry_name, ctx->cdata + remote->path_len);
1440+
strcpy(ls->dentry_name, path + remote->path_len);
14301441
} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
14311442
ls->dentry_flags |= IS_DIR;
14321443
}
@@ -2206,10 +2217,11 @@ int main(int argc, char **argv)
22062217
if (!remote->url) {
22072218
char *path = strstr(arg, "//");
22082219
remote->url = arg;
2220+
remote->path_len = strlen(arg);
22092221
if (path) {
2210-
path = strchr(path+2, '/');
2211-
if (path)
2212-
remote->path_len = strlen(path);
2222+
remote->path = strchr(path+2, '/');
2223+
if (remote->path)
2224+
remote->path_len = strlen(remote->path);
22132225
}
22142226
continue;
22152227
}
@@ -2238,8 +2250,9 @@ int main(int argc, char **argv)
22382250
rewritten_url = xmalloc(strlen(remote->url)+2);
22392251
strcpy(rewritten_url, remote->url);
22402252
strcat(rewritten_url, "/");
2253+
remote->path = rewritten_url + (remote->path - remote->url);
2254+
remote->path_len++;
22412255
remote->url = rewritten_url;
2242-
++remote->path_len;
22432256
}
22442257

22452258
/* Verify DAV compliance/lock support */

0 commit comments

Comments
 (0)