1. 13 10月, 2016 1 次提交
  2. 10 9月, 2016 21 次提交
  3. 08 9月, 2016 1 次提交
  4. 02 8月, 2016 1 次提交
  5. 21 6月, 2016 1 次提交
    • M
      do_for_each_ref(): reimplement using reference iteration · 4c4de895
      Michael Haggerty 提交于
      Use the reference iterator interface to implement do_for_each_ref().
      Delete a bunch of code supporting the old for_each_ref() implementation.
      And now that do_for_each_ref() is generic code (it is no longer tied to
      the files backend), move it to refs.c.
      
      The implementation is via a new function, do_for_each_ref_iterator(),
      which takes a reference iterator as argument and calls a callback
      function for each of the references in the iterator.
      
      This change requires the current_ref performance hack for peel_ref() to
      be implemented via ref_iterator_peel() rather than peel_entry() because
      we don't have a ref_entry handy (it is hidden under three layers:
      file_ref_iterator, merge_ref_iterator, and cache_ref_iterator). So:
      
      * do_for_each_ref_iterator() records the active iterator in
        current_ref_iter while it is running.
      
      * peel_ref() checks whether current_ref_iter is pointing at the
        requested reference. If so, it asks the iterator to peel the
        reference (which it can do efficiently via its "peel" virtual
        function). For extra safety, we do the optimization only if the
        refname *addresses* are the same, not only if the refname *strings*
        are the same, to forestall possible mixups between refnames that come
        from different ref_iterators.
      
      Please note that this optimization of peel_ref() is only available when
      iterating via do_for_each_ref_iterator() (including all of the
      for_each_ref() functions, which call it indirectly). It would be
      complicated to implement a similar optimization when iterating directly
      using a reference iterator, because multiple reference iterators can be
      in use at the same time, with interleaved calls to
      ref_iterator_advance(). (In fact we do exactly that in
      merge_ref_iterator.)
      
      But that is not necessary. peel_ref() is only called while iterating
      over references. Callers who iterate using the for_each_ref() functions
      benefit from the optimization described above. Callers who iterate using
      reference iterators directly have access to the ref_iterator, so they
      can call ref_iterator_peel() themselves to get an analogous optimization
      in a more straightforward manner.
      
      If we rewrite all callers to use the reference iteration API, then we
      can remove the current_ref_iter hack permanently.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4c4de895
  6. 14 6月, 2016 1 次提交
  7. 13 6月, 2016 4 次提交
  8. 05 5月, 2016 3 次提交
  9. 11 4月, 2016 3 次提交
  10. 23 2月, 2016 3 次提交
    • J
      use st_add and st_mult for allocation size computation · 50a6c8ef
      Jeff King 提交于
      If our size computation overflows size_t, we may allocate a
      much smaller buffer than we expected and overflow it. It's
      probably impossible to trigger an overflow in most of these
      sites in practice, but it is easy enough convert their
      additions and multiplications into overflow-checking
      variants. This may be fixing real bugs, and it makes
      auditing the code easier.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      50a6c8ef
    • J
      convert trivial cases to FLEX_ARRAY macros · 96ffc06f
      Jeff King 提交于
      Using FLEX_ARRAY macros reduces the amount of manual
      computation size we have to do. It also ensures we don't
      overflow size_t, and it makes sure we write the same number
      of bytes that we allocated.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      96ffc06f
    • J
      use xmallocz to avoid size arithmetic · 3733e694
      Jeff King 提交于
      We frequently allocate strings as xmalloc(len + 1), where
      the extra 1 is for the NUL terminator. This can be done more
      simply with xmallocz, which also checks for integer
      overflow.
      
      There's no case where switching xmalloc(n+1) to xmallocz(n)
      is wrong; the result is the same length, and malloc made no
      guarantees about what was in the buffer anyway. But in some
      cases, we can stop manually placing NUL at the end of the
      allocated buffer. But that's only safe if it's clear that
      the contents will always fill the buffer.
      
      In each case where this patch does so, I manually examined
      the control flow, and I tried to err on the side of caution.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3733e694
  11. 02 12月, 2015 1 次提交
    • S
      Make error message after failing commit_lock_file() less confusing · 08a3651f
      SZEDER Gábor 提交于
      The error message after a failing commit_lock_file() call sometimes
      looks like this, causing confusion:
      
        $ git remote add remote git@server.com/repo.git
        error: could not commit config file .git/config
        # Huh?!
        # I didn't want to commit anything, especially not my config file!
      
      While in the narrow context of the lockfile module using the verb
      'commit' in the error message makes perfect sense, in the broader
      context of git the word 'commit' already has a very specific meaning,
      hence the confusion.
      
      Reword these error messages to say "could not write" instead of "could
      not commit".
      
      While at it, include strerror in the error messages after writing the
      config file or the credential store fails to provide some information
      about the cause of the failure, and update the style of the error
      message after writing the reflog fails to match surrounding error
      messages (i.e. no '' around the pathname and no () around the error
      description).
      Signed-off-by: NSZEDER Gábor <szeder@ira.uka.de>
      Signed-off-by: NJeff King <peff@peff.net>
      08a3651f