@matheusbsbs / matheus-bagliano / commits / 021ab6f00b
Fork 0

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 <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shawn O. Pearce committed Apr 17, 2010 at 13:07 UTC 021ab6f00b66d0d3931310e77383239a606c96c2
1 file changed +8 -8
http.c
+8 -8
@@ -1002,8 +1002,9 @@ int finish_http_pack_request(struct http_pack_request *preq)
1002 {
1003 int ret;
1004 struct packed_git **lst;
1005 + struct packed_git *p = preq->target;
1006
1006 - preq->target->pack_size = ftell(preq->packfile);
1007 + p->pack_size = ftell(preq->packfile);
1008
1009 if (preq->packfile != NULL) {
1010 fclose(preq->packfile);
@@ -1011,18 +1012,17 @@ int finish_http_pack_request(struct http_pack_request *preq)
1012 preq->slot->local = NULL;
1013 }
1014
1014 - ret = move_temp_to_file(preq->tmpfile, preq->filename);
1015 - if (ret)
1016 - return ret;
1017 -
1015 lst = preq->lst;
1019 - while (*lst != preq->target)
1016 + while (*lst != p)
1017 lst = &((*lst)->next);
1018 *lst = (*lst)->next;
1019
1023 - if (verify_pack(preq->target))
1020 + ret = move_temp_to_file(preq->tmpfile, preq->filename);
1021 + if (ret)
1022 + return ret;
1023 + if (verify_pack(p))
1024 return -1;
1025 - install_packed_git(preq->target);
1025 + install_packed_git(p);
1026
1027 return 0;
1028 }