Skip to content

Commit 5bd0851

Browse files
pks-tgitster
authored andcommitted
send-pack: always allocate receive status
In `receive_status()`, we record the reason why ref updates have been rejected by the remote via the `remote_status`. But while we allocate the assigned string when a reason was given, we assign a string constant when no reason was given. This has been working fine so far due to two reasons: - We don't ever free the refs in git-send-pack(1)' - Remotes always give a reason, at least as implemented by Git proper. Adapt the code to always allocate the receive status string and free the refs. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e463c5e commit 5bd0851

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

builtin/send-pack.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
336336
/* stable plumbing output; do not modify or localize */
337337
fprintf(stderr, "Everything up-to-date\n");
338338

339+
free_refs(remote_refs);
340+
free_refs(local_refs);
339341
return ret;
340342
}

send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)
259259
if (p)
260260
hint->remote_status = xstrdup(p);
261261
else
262-
hint->remote_status = "failed";
262+
hint->remote_status = xstrdup("failed");
263263
} else {
264264
hint->status = REF_STATUS_OK;
265265
hint->remote_status = xstrdup_or_null(p);

0 commit comments

Comments
 (0)