git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] add post-fetch hook

From
Johannes Sixt <j6t@kdbg.org>
Date
Dec 27, 2011, 21:27 UTC
Message-ID
<4EFA3833.80409@kdbg.org>
In-Reply-To
<20111226023154.GA3243@gnu.kitenet.net>
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?

Show 10 quoted lines
> +		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
Previous: Junio C HamanoNext: Joey Hess
Message 15 of 16 in “add post-fetch hook”
  1. add post-fetch hookJoey Hess, Dec 24, 2011
  2. Junio C HamanoDec 25, 2011
  3. Joey HessDec 25, 2011
  4. Junio C HamanoDec 25, 2011
  5. Jakub NarebskiDec 25, 2011
  6. Joey HessDec 25, 2011
  7. Junio C HamanoDec 26, 2011
  8. Joey HessDec 25, 2011
  9. add post-fetch hookJoey Hess, Dec 26, 2011
  10. Junio C HamanoDec 26, 2011
  11. Joey HessDec 26, 2011
  12. Junio C HamanoDec 27, 2011
  13. Joey HessDec 27, 2011
  14. Junio C HamanoDec 27, 2011
  15. Johannes SixtDec 27, 2011
  16. Joey HessDec 28, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.