Skip to content

Commit 9116de5

Browse files
Grégoire Barbiergitster
authored andcommitted
http-push: fix webdav lock leak.
Releasing webdav lock even if push fails because of bad (or no) reference on command line. To reproduce the issue that this patch fixes, prepare a test repository availlable over http+webdav, say at http://myhost/myrepo.git/ Then: $ git clone http://myhost/myrepo.git/ $ cd myrepo $ git push http Fetching remote heads... refs/ refs/heads/ refs/tags/ No refs in common and none specified; doing nothing. $ git push http Fetching remote heads... refs/ refs/heads/ refs/tags/ No refs in common and none specified; doing nothing. $ Finally, you look at the web server logs, and will find one LOCK query and no UNLOCK query, of course the second one will be in 423 return code instead of 200: 1.2.3.4 - gb [19/Jan/2008:14:24:56 +0100] "LOCK /myrepo.git/info/refs HTTP/1.1" 200 465 (...) 1.2.3.4 - gb [19/Jan/2008:14:25:10 +0100] "LOCK /myrepo.git/info/refs HTTP/1.1" 423 363 With this patch, there would have be two UNLOCKs in addition of the LOCKs From the user's point of view: - If you realize that you should have typed e.g. "git push http master" instead of "git push http", you will have to wait for 10 minutes for the lock to expire by its own. - Furthermore, if somebody else is dumb enough to type "git push http" while you need to push "master" branch, then you'll need too to wait for 10 minutes too. Signed-off-by: Gr�.A�Nigoire Barbier <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0a61779 commit 9116de5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

http-push.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,11 +2264,14 @@ int main(int argc, char **argv)
22642264
if (!remote_tail)
22652265
remote_tail = &remote_refs;
22662266
if (match_refs(local_refs, remote_refs, &remote_tail,
2267-
nr_refspec, (const char **) refspec, push_all))
2268-
return -1;
2267+
nr_refspec, (const char **) refspec, push_all)) {
2268+
rc = -1;
2269+
goto cleanup;
2270+
}
22692271
if (!remote_refs) {
22702272
fprintf(stderr, "No refs in common and none specified; doing nothing.\n");
2271-
return 0;
2273+
rc = 0;
2274+
goto cleanup;
22722275
}
22732276

22742277
new_refs = 0;
@@ -2399,10 +2402,10 @@ int main(int argc, char **argv)
23992402
fprintf(stderr, "Unable to update server info\n");
24002403
}
24012404
}
2402-
if (info_ref_lock)
2403-
unlock_remote(info_ref_lock);
24042405

24052406
cleanup:
2407+
if (info_ref_lock)
2408+
unlock_remote(info_ref_lock);
24062409
free(remote);
24072410

24082411
curl_slist_free_all(no_pragma_header);

0 commit comments

Comments
 (0)