Re: [PATCH 08/15] provide helpers to access the commit buffer

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

 



On Monday, June 9, 2014, Jeff King <peff@xxxxxxxx> wrote:
> Many sites look at commit->buffer to get more detailed
> information than what is in the parsed commit struct.
> However, we sometimes drop commit->buffer to save memory,
> in which case the caller would need to read the object
> afresh. Some callers do this (leading to duplicated code),
> and others do not (which opens the possibility of a segfault
> if somebody else frees the buffer).
>
> Let's provide a pair of helpers, "get" and "unuse", that let
> callers easily get the buffer. They will use the cached
> buffer when possible, and otherwise load from disk using
> read_sha1_file.
>
> Note that we also need to add a "get_cached" variant which
> returns NULL when we do not have a cached buffer. At first
> glance this seems to defeat the purpose of "get", which is
> to always provide a return value. However, some log code
> paths actually use the NULL-ness of commit->buffer as a
> boolean flag to decide whether to try to printing the

s/printing/print/ ... or some other variation of the phrase.

> commit. At least for now, we want to continue supporting
> that use.
>
> Signed-off-by: Jeff King <peff@xxxxxxxx>
--
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]