From: Johannes Sixt <j6t@kdbg.org>
To: Joey Hess <joey@kitenet.net>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] add post-fetch hook
Date: Tue, 27 Dec 2011 22:27:15 +0100 [thread overview]
Message-ID: <4EFA3833.80409@kdbg.org> (raw)
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?
> + 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
next prev parent reply other threads:[~2011-12-27 21:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-24 23:42 [PATCH] add post-fetch hook Joey Hess
2011-12-25 3:13 ` Junio C Hamano
2011-12-25 3:50 ` Joey Hess
2011-12-25 9:30 ` Junio C Hamano
2011-12-25 16:24 ` Jakub Narebski
2011-12-25 18:06 ` Joey Hess
2011-12-26 8:09 ` Junio C Hamano
2011-12-25 17:54 ` Joey Hess
2011-12-26 2:31 ` Joey Hess
2011-12-26 7:59 ` Junio C Hamano
2011-12-26 15:51 ` Joey Hess
2011-12-27 6:37 ` Junio C Hamano
2011-12-27 15:49 ` Joey Hess
2011-12-27 23:23 ` Junio C Hamano
2011-12-27 21:27 ` Johannes Sixt [this message]
2011-12-28 19:30 ` Joey Hess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EFA3833.80409@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=joey@kitenet.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).