1. 08 Jul, 2016 1 commit
  2. 25 Apr, 2016 1 commit
  3. 15 Jan, 2016 1 commit
    • Junio C Hamano's avatar
      strbuf: introduce strbuf_getline_{lf,nul}() · 8f309aeb
      Junio C Hamano authored
      The strbuf_getline() interface allows a byte other than LF or NUL as
      the line terminator, but this is only because I wrote these
      codepaths anticipating that there might be a value other than NUL
      and LF that could be useful when I introduced line_termination long
      time ago.  No useful caller that uses other value has emerged.
      By now, it is clear that the interface is overly broad without a
      good reason.  Many codepaths have hardcoded preference to read
      either LF terminated or NUL terminated records from their input, and
      then call strbuf_getline() with LF or NUL as the third parameter.
      This step introduces two thin wrappers around strbuf_getline(),
      namely, strbuf_getline_lf() and strbuf_getline_nul(), and
      mechanically rewrites these call sites to call either one of
      them.  The changes contained in this patch are:
       * introduction of these two functions in strbuf.[ch]
       * mechanical conversion of all callers to strbuf_getline() with
         either '\n' or '\0' as the third parameter to instead call the
         respective thin wrapper.
      After this step, output from "git grep 'strbuf_getline('" would
      become a lot smaller.  An interim goal of this series is to make
      this an empty set, so that we can have strbuf_getline_crlf() take
      over the shorter name strbuf_getline().
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  4. 20 Nov, 2015 4 commits
  5. 05 Oct, 2015 1 commit
  6. 25 May, 2015 2 commits
  7. 17 Feb, 2015 1 commit
  8. 13 Jan, 2015 1 commit
  9. 15 Oct, 2014 1 commit
  10. 18 Sep, 2014 1 commit
  11. 03 Sep, 2014 1 commit
  12. 25 Aug, 2014 1 commit
  13. 19 Jun, 2014 1 commit
    • Jeff King's avatar
      walker_fetch: fix minor memory leak · f3320699
      Jeff King authored
      We sometimes allocate "msg" on the heap, but will fail to
      free it if we hit the failure code path. We can instead keep
      a separate variable that is safe to be freed no matter how
      we get to the failure code path.
      While we're here, we can also do two readability
        1. Use xstrfmt instead of a manual malloc/sprintf
        2. Due to the "maybe we allocate msg, maybe we don't"
           strategy, the logic for deciding which message to show
           was split into two parts. Since the deallocation is now
           pushed onto a separate variable, this is no longer a
           concern, and we can keep all of the logic in the same
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  14. 25 Mar, 2014 1 commit
  15. 06 Jun, 2013 1 commit
    • Jeff King's avatar
      clear parsed flag when we free tree buffers · 6e454b9a
      Jeff King authored
      Many code paths will free a tree object's buffer and set it
      to NULL after finishing with it in order to keep memory
      usage down during a traversal. However, out of 8 sites that
      do this, only one actually unsets the "parsed" flag back.
      Those sites that don't are setting a trap for later users of
      the tree object; even after calling parse_tree, the buffer
      will remain NULL, causing potential segfaults.
      It is not known whether this is triggerable in the current
      code. Most commands do not do an in-memory traversal
      followed by actually using the objects again. However, it
      does not hurt to be safe for future callers.
      In most cases, we can abstract this out to a
      "free_tree_buffer" helper. However, there are two
        1. The fsck code relies on the parsed flag to know that we
           were able to parse the object at one point. We can
           switch this to using a flag in the "flags" field.
        2. The index-pack code sets the buffer to NULL but does
           not free it (it is freed by a caller). We should still
           unset the parsed flag here, but we cannot use our
           helper, as we do not want to free the buffer.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  16. 05 Oct, 2011 1 commit
    • Michael Haggerty's avatar
      Change check_ref_format() to take a flags argument · 8d9c5010
      Michael Haggerty authored
      Change check_ref_format() to take a flags argument that indicates what
      is acceptable in the reference name (analogous to "git
      check-ref-format"'s "--allow-onelevel" and "--refspec-pattern").  This
      is more convenient for callers and also fixes a failure in the test
      suite (and likely elsewhere in the code) by enabling "onelevel" and
      "refspec-pattern" to be allowed independently of each other.
      Also rename check_ref_format() to check_refname_format() to make it
      obvious that it deals with refnames rather than references themselves.
      Signed-off-by: default avatarMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  17. 29 Nov, 2010 1 commit
  18. 23 Jul, 2009 1 commit
  19. 11 Feb, 2009 1 commit
  20. 18 Oct, 2008 1 commit
  21. 12 Oct, 2008 1 commit
  22. 04 Jun, 2008 1 commit
  23. 11 May, 2008 1 commit
  24. 27 Apr, 2008 1 commit
    • Daniel Barkalow's avatar
      Make walker.fetch_ref() take a struct ref. · c13b2633
      Daniel Barkalow authored
      This simplifies a few things, makes a few things slightly more
      complicated, but, more importantly, allows that, when struct ref can
      represent a symref, http_fetch_ref() can return one.
      Incidentally makes the string that http_fetch_ref() gets include "refs/"
      (if appropriate), because that's how the name field of struct ref works.
      As far as I can tell, the usage in walker:interpret_target() wouldn't have
      worked previously, if it ever would have been used, which it wouldn't
      (since the fetch process uses the hash instead of the name of the ref
      Signed-off-by: default avatarDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  25. 26 Feb, 2008 1 commit
  26. 18 Dec, 2007 1 commit
  27. 19 Sep, 2007 1 commit
  28. 18 Sep, 2007 1 commit
  29. 17 Sep, 2007 1 commit
  30. 10 Sep, 2007 1 commit
    • Pierre Habouzit's avatar
      Strbuf API extensions and fixes. · f1696ee3
      Pierre Habouzit authored
        * Add strbuf_rtrim to remove trailing spaces.
        * Add strbuf_insert to insert data at a given position.
        * Off-by one fix in strbuf_addf: strbuf_avail() does not counts the final
          \0 so the overflow test for snprintf is the strict comparison. This is
          not critical as the growth mechanism chosen will always allocate _more_
          memory than asked, so the second test will not fail. It's some kind of
          miracle though.
        * Add size extension hints for strbuf_init and strbuf_read. If 0, default
          applies, else:
            + initial buffer has the given size for strbuf_init.
            + first growth checks it has at least this size rather than the
              default 8192.
      Signed-off-by: default avatarPierre Habouzit <madcoder@debian.org>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  31. 27 Jun, 2007 1 commit
  32. 07 Jun, 2007 1 commit
    • Junio C Hamano's avatar
      War on whitespace · a6080a0a
      Junio C Hamano authored
      This uses "git-apply --whitespace=strip" to fix whitespace errors that have
      crept in to our source files over time.  There are a few files that need
      to have trailing whitespaces (most notably, test vectors).  The results
      still passes the test, and build result in Documentation/ area is unchanged.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  33. 21 Mar, 2007 1 commit
  34. 20 Dec, 2006 1 commit
    • Junio C Hamano's avatar
      simplify inclusion of system header files. · 85023577
      Junio C Hamano authored
      This is a mechanical clean-up of the way *.c files include
      system header files.
       (1) sources under compat/, platform sha-1 implementations, and
           xdelta code are exempt from the following rules;
       (2) the first #include must be "git-compat-util.h" or one of
           our own header file that includes it first (e.g. config.h,
           builtin.h, pkt-line.h);
       (3) system headers that are included in "git-compat-util.h"
           need not be included in individual C source files.
       (4) "git-compat-util.h" does not have to include subsystem
           specific header files (e.g. expat.h).
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
  35. 13 Dec, 2006 1 commit
  36. 27 Sep, 2006 1 commit