[PATCH 1/3] receive-pack: Two small code cleanups
- From
- Andreas Gruenbacher <agruen@suse.de>
- Date
- Feb 24, 2010, 15:33 UTC
- Message-ID
- <f409d0cde7939a833708ed92f86605dbbdd64a49.1267029680.git.agruen@suse.de>
- In-Reply-To
- <cover.1267029680.git.agruen@suse.de>
Rename show_ref()'s path parameter to refname.
In read_head_info(), lines may have trailing capability strings. Throw away such strings after evaluation; they are not needed in the command structs.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de> --- builtin-receive-pack.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c index 0559fcc..77cbc2a 100644 --- a/builtin-receive-pack.c +++ b/builtin-receive-pack.c @@ -105,13 +105,13 @@ static int receive_pack_config(const char *var, const char *value, void *cb) return git_default_config(var, value, cb); } -static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int show_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { if (sent_capabilities) - packet_write(1, "%s %s\n", sha1_to_hex(sha1), path); + packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname); else packet_write(1, "%s %s%c%s%s\n", - sha1_to_hex(sha1), path, 0, + sha1_to_hex(sha1), refname, 0, " report-status delete-refs side-band-64k", prefer_ofs_delta ? " ofs-delta" : ""); sent_capabilities = 1; @@ -524,7 +524,7 @@ static void read_head_info(void) static char line[1000]; unsigned char old_sha1[20], new_sha1[20]; struct command *cmd; - char *refname; + const char *refname; int len, reflen; len = packet_read_line(0, line, sizeof(line)); @@ -548,10 +548,10 @@ static void read_head_info(void) if (strstr(refname + reflen + 1, "side-band-64k")) use_sideband = LARGE_PACKET_MAX; } - cmd = xmalloc(sizeof(struct command) + len - 80); + cmd = xmalloc(sizeof(struct command) + reflen + 1); hashcpy(cmd->old_sha1, old_sha1); hashcpy(cmd->new_sha1, new_sha1); - memcpy(cmd->ref_name, line + 82, len - 81); + memcpy(cmd->ref_name, refname, reflen + 1); cmd->error_string = NULL; cmd->next = NULL; *p = cmd;
-- 1.6.6.243.gff6d2