Re: [PATCH] add post-fetch hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 26.12.2011 03:31, schrieb Joey Hess:
> +int feed_post_fetch_hook (int in, int out, void *data)
> +{
> +	struct ref *ref;
> +	struct strbuf buf = STRBUF_INIT;

Is there a particular reason that you accumulate everything in a buffer?

If I read the loop below correctly, you should be able to run it using
only the functions sha1_to_hex(), strlen() and write_in_full(). This
would avoid any problems with concurrent calls to xmalloc().

> +	int ret;
> +
> +	for (ref = post_fetch_hook_refs; ref; ref = ref->next) {
> +		strbuf_addstr(&buf, sha1_to_hex(ref->old_sha1));

sha1_to_hex() works with a static buffer. Are you certain that it is not
called concurrently in the main thread?

> +		strbuf_addch(&buf, ' ');
> +		strbuf_addstr(&buf, ref->merge ? "merge" : "not-for-merge");
> +		strbuf_addch(&buf, ' ');
> +		if (ref->name)
> +			strbuf_addstr(&buf, ref->name);
> +		strbuf_addch(&buf, ' ');
> +		if (ref->peer_ref && ref->peer_ref->name)
> +			strbuf_addstr(&buf, ref->peer_ref->name);
> +		strbuf_addch(&buf, '\n');
> +	}

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]