Re: [PATCH v5 2/6] receive-pack: add new proc-receive hook
Jiang Xin <worldhello.net@gmail.com> writes:
Show 7 quoted lines
> diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c
> new file mode 100644
> index 0000000000..aafa3e8e59
> --- /dev/null
> +++ b/t/helper/test-proc-receive.c
> @@ -0,0 +1,172 @@
> +static void proc_receive_verison(struct packet_reader *reader) {Is that a phone company ;-)?
Show 27 quoted lines
> + int server_version = 0;
> +
> + for (;;) {
> +...
> +static void proc_receive_read_commands(struct packet_reader *reader,
> + struct command **commands)
> +{
> + struct command **tail = commands;
> +
> + for (;;) {
> + struct object_id old_oid, new_oid;
> + struct command *cmd;
> + const char *refname;
> + const char *p;
> +
> + if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
> + break;
> + }
> +
> + if (parse_oid_hex(reader->line, &old_oid, &p) ||
> + *p++ != ' ' ||
> + parse_oid_hex(p, &new_oid, &p) ||
> + *p++ != ' ')
> + die("protocol error: expected 'old new ref', got '%s'",
> + reader->line);
> + refname = p;
> + FLEX_ALLOC_MEM(cmd, ref_name, refname, strlen(refname)); FLEX_ALLOC_STR(cmd, ref_name, refname);
Show 7 quoted lines
> + oidcpy(&cmd->old_oid, &old_oid);
> + oidcpy(&cmd->new_oid, &new_oid);
> +
> + *tail = cmd;
> + tail = &cmd->next;
> + }
> +}