Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Jun 12, 2014
  1. Jeff King Junio C Hamano

    replace dangerous uses of strbuf_attach

    peff authored gitster committed
    It is not a good idea to strbuf_attach an arbitrary pointer
    just because a function you are calling wants a strbuf.
    Attaching implies a transfer of memory ownership; if anyone
    were to modify or release the resulting strbuf, we would
    free() the pointer, leading to possible problems:
    
      1. Other users of the original pointer might access freed
         memory.
    
      2. The pointer might not be the start of a malloc'd
         area, so calling free() on it in the first place would
         be wrong.
    
    In the two cases modified here, we are fortunate that nobody
    touches the strbuf once it is attached, but it is an
    accident waiting to happen.  Since the previous commit,
    commit_tree and friends take a pointer/buf pair, so we can
    just do away with the strbufs entirely.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. Jeff King Junio C Hamano

    commit_tree: take a pointer/len pair rather than a const strbuf

    peff authored gitster committed
    While strbufs are pretty common throughout our code, it is
    more flexible for functions to take a pointer/len pair than
    a strbuf. It's easy to turn a strbuf into such a pair (by
    dereferencing its members), but less easy to go the other
    way (you can strbuf_attach, but that has implications about
    memory ownership).
    
    This patch teaches commit_tree (and its associated callers
    and sub-functions) to take such a pair for the commit
    message rather than a strbuf.  This makes passing the buffer
    around slightly more verbose, but means we can get rid of
    some dangerous strbuf_attach calls in the next patch.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Apr 2, 2010
  1. Jeff King Junio C Hamano

    introduce notes-cache interface

    peff authored gitster committed
    Notes provide a fast lookup mechanism for data keyed by
    sha1. This is ideal for caching certain operations, like
    textconv filters.
    
    This patch builds some infrastructure to make it simpler to
    use notes trees as caches. In particular, caches:
    
      1. don't have arbitrary commit messages. They store a
         cache validity string in the commit, and clear the tree
         when the cache validity string changes.
    
      2. don't keep any commit history. The accumulated history
         of a a cache is just useless cruft.
    
      3. use a looser form of locking for ref updates. If two
         processes try to write to the cache simultaneously, it
         is OK if one overwrites the other, losing some changes.
         It's just a cache, so we will just end up with an extra
         miss.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.