From: Junio C Hamano Date: Mon, 12 Dec 2011 22:44:08 GMT Subject: Re: [PATCH v2 20/51] repack_without_ref(): reimplement using do_for_each_ref_in_array() Message-ID: <7vk461xq4n.fsf@alter.siamese.dyndns.org> In-Reply-To: <1323668338-1764-21-git-send-email-mhagger@alum.mit.edu> mhagger@alum.mit.edu writes: > +static int repack_without_ref_fn(const char *refname, const unsigned char *sha1, > + int flags, void *cb_data) > +{ > + struct repack_without_ref_sb *data = cb_data; > + char line[PATH_MAX + 100]; > + int len; > + > + if (!strcmp(data->refname, refname)) > + return 0; > + len = snprintf(line, sizeof(line), "%s %s\n", > + sha1_to_hex(sha1), refname); > + /* this should not happen but just being defensive */ > + if (len > sizeof(line)) > + die("too long a refname '%s'", refname); Perhaps strbuf would be easier to use for things like this.