From: Shawn O. Pearce Date: Sat, 17 Apr 2010 20:07:36 +0000 (-0700) Subject: http.c: Tiny refactoring of finish_http_pack_request X-Git-Tag: v1.7.2-rc0~118^2~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=021ab6f00b66d0d3931310e77383239a606c96c2;p=git.git http.c: Tiny refactoring of finish_http_pack_request Always remove the struct packed_git from the active list, even if the rename of the temporary file fails. While we are here, simplify the code a bit by using a common local variable name ("p") to hold the relevant packed_git. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- diff --git a/http.c b/http.c index 9526491a4..e9e226956 100644 --- a/http.c +++ b/http.c @@ -1002,8 +1002,9 @@ int finish_http_pack_request(struct http_pack_request *preq) { int ret; struct packed_git **lst; + struct packed_git *p = preq->target; - preq->target->pack_size = ftell(preq->packfile); + p->pack_size = ftell(preq->packfile); if (preq->packfile != NULL) { fclose(preq->packfile); @@ -1011,18 +1012,17 @@ int finish_http_pack_request(struct http_pack_request *preq) preq->slot->local = NULL; } - ret = move_temp_to_file(preq->tmpfile, preq->filename); - if (ret) - return ret; - lst = preq->lst; - while (*lst != preq->target) + while (*lst != p) lst = &((*lst)->next); *lst = (*lst)->next; - if (verify_pack(preq->target)) + ret = move_temp_to_file(preq->tmpfile, preq->filename); + if (ret) + return ret; + if (verify_pack(p)) return -1; - install_packed_git(preq->target); + install_packed_git(p); return 0; }