Skip to content

Commit 753bc91

Browse files
catapgitster
authored andcommitted
Remove the requirement opaquelocktoken uri scheme
The program flow of pushing over http is: - call lock_remote() to issue a DAV_LOCK request to the server to lock info/refs and branch refs being pushed into; handle_new_lock_ctx() is used to parse its response to populate "struct remote_lock" that is returned from lock_remote(); - send objects; - call unlock_remote() to drop the lock. The handle_new_lock_ctx() function assumed that the server will use a lock token in opaquelocktoken URI scheme, which may have been an Ok assumption under RFC 2518, but under RFC 4918 which obsoletes the older standard it is not necessarily true. This resulted in push failure (often resulted in "cannot lock existing info/refs" error message) when talking to a server that does not use opaquelocktoken URI scheme. Signed-off-by: Kirill A. Korinskiy <catap@catap.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 08fc060 commit 753bc91

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

http-push.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static int refresh_lock(struct remote_lock *lock)
595595
lock->refreshing = 1;
596596

597597
if_header = xmalloc(strlen(lock->token) + 25);
598-
sprintf(if_header, "If: (<opaquelocktoken:%s>)", lock->token);
598+
sprintf(if_header, "If: (<%s>)", lock->token);
599599
sprintf(timeout_header, "Timeout: Second-%ld", lock->timeout);
600600
dav_headers = curl_slist_append(dav_headers, if_header);
601601
dav_headers = curl_slist_append(dav_headers, timeout_header);
@@ -1120,10 +1120,8 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)
11201120
lock->timeout =
11211121
strtol(ctx->cdata + 7, NULL, 10);
11221122
} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {
1123-
if (!prefixcmp(ctx->cdata, "opaquelocktoken:")) {
1124-
lock->token = xmalloc(strlen(ctx->cdata) - 15);
1125-
strcpy(lock->token, ctx->cdata + 16);
1126-
}
1123+
lock->token = xmalloc(strlen(ctx->cdata) + 1);
1124+
strcpy(lock->token, ctx->cdata);
11271125
}
11281126
}
11291127
}
@@ -1308,7 +1306,7 @@ static int unlock_remote(struct remote_lock *lock)
13081306
int rc = 0;
13091307

13101308
lock_token_header = xmalloc(strlen(lock->token) + 31);
1311-
sprintf(lock_token_header, "Lock-Token: <opaquelocktoken:%s>",
1309+
sprintf(lock_token_header, "Lock-Token: <%s>",
13121310
lock->token);
13131311
dav_headers = curl_slist_append(dav_headers, lock_token_header);
13141312

@@ -1722,7 +1720,7 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock)
17221720
struct curl_slist *dav_headers = NULL;
17231721

17241722
if_header = xmalloc(strlen(lock->token) + 25);
1725-
sprintf(if_header, "If: (<opaquelocktoken:%s>)", lock->token);
1723+
sprintf(if_header, "If: (<%s>)", lock->token);
17261724
dav_headers = curl_slist_append(dav_headers, if_header);
17271725

17281726
strbuf_addf(&out_buffer.buf, "%s\n", sha1_to_hex(sha1));
@@ -1941,7 +1939,7 @@ static void update_remote_info_refs(struct remote_lock *lock)
19411939
add_remote_info_ref, &buffer.buf);
19421940
if (!aborted) {
19431941
if_header = xmalloc(strlen(lock->token) + 25);
1944-
sprintf(if_header, "If: (<opaquelocktoken:%s>)", lock->token);
1942+
sprintf(if_header, "If: (<%s>)", lock->token);
19451943
dav_headers = curl_slist_append(dav_headers, if_header);
19461944

19471945
slot = get_active_slot();

0 commit comments

Comments
 (0)