Skip to content

Commit

Permalink
http.c: Tiny refactoring of finish_http_pack_request
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Apr 17, 2010
1 parent d761b2a commit 021ab6f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,27 +1002,27 @@ 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);
preq->packfile = NULL;
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;
}
Expand Down

0 comments on commit 021ab6f

Please sign in to comment.