1. 26 2月, 2011 1 次提交
  2. 11 2月, 2011 1 次提交
  3. 11 11月, 2010 1 次提交
  4. 16 9月, 2010 1 次提交
    • J
      disallow branch names that start with a hyphen · 63486240
      Junio C Hamano 提交于
      The current command line parser is overly lax in places and allows a
      branch whose name begins with a hyphen e.g. "-foo" to be created, but the
      parseopt infrastructure in general does not like to parse anything that
      begins with a dash as a short-hand refname.  "git checkout -foo" won't
      work, nor will "git branch -d -foo" (even though "git branch -d -- -foo"
      works, it does so by mistake; we should not be taking anything but
      pathspecs after double-dash).
      
      All the codepaths that create a new branch ref, including the destination
      of "branch -m src dst", use strbuf_check_branch_ref() to validate if the
      given name is suitable as a branch name.  Tighten it to disallow a branch
      that begins with a hyphen.
      
      You can still get rid of historical mistakes with
      
        $ git update-ref -d refs/heads/-foo
      
      and third-party Porcelains are free to keep using update-ref to create
      refs with a path component that begins with "-".
      
      Issue originally raised by Clemens Buchacher.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      63486240
  5. 18 1月, 2010 1 次提交
  6. 15 1月, 2010 2 次提交
    • J
      strbuf: add strbuf_addbuf_percentquote · 361df5df
      Jeff King 提交于
      This is handy for creating strings which will be fed to printf() or
      strbuf_expand().
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      361df5df
    • J
      strbuf_expand: convert "%%" to "%" · 0a0416a3
      Jeff King 提交于
      The only way to safely quote arbitrary text in a pretty-print user
      format is to replace instances of "%" with "%x25". This is slightly
      unreadable, and many users would expect "%%" to produce a single
      "%", as that is what printf format specifiers do.
      
      This patch converts "%%" to "%" for all users of strbuf_expand():
      
       (1) git-daemon interpolated paths
      
       (2) pretty-print user formats
      
       (3) merge driver command lines
      
      Case (1) was already doing the conversion itself outside of
      strbuf_expand(). Case (2) is the intended beneficiary of this patch.
      Case (3) users probably won't notice, but as this is user-facing
      behavior, consistently providing the quoting mechanism makes sense.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0a0416a3
  7. 12 1月, 2010 1 次提交
  8. 06 8月, 2009 1 次提交
  9. 24 6月, 2009 1 次提交
  10. 23 3月, 2009 2 次提交
  11. 21 3月, 2009 1 次提交
  12. 07 1月, 2009 1 次提交
  13. 18 12月, 2008 1 次提交
    • L
      Add generic 'strbuf_readlink()' helper function · b11b7e13
      Linus Torvalds 提交于
      It was already what 'git apply' did in read_old_data(), just export it
      as a real function, and make it be more generic.
      
      In particular, this handles the case of the lstat() st_size data not
      matching the readlink() return value properly (which apparently happens
      at least on NTFS under Linux).  But as a result of this you could also
      use the new function without even knowing how big the link is going to
      be, and it will allocate an appropriately sized buffer.
      
      So we pass in the st_size of the link as just a hint, rather than a
      fixed requirement.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b11b7e13
  14. 24 11月, 2008 1 次提交
    • R
      add strbuf_expand_dict_cb(), a helper for simple cases · 9b864e73
      René Scharfe 提交于
      The new callback function strbuf_expand_dict_cb() can be used together
      with strbuf_expand() if there is only a small number of placeholders
      for static replacement texts.  It expects its dictionary as an array of
      placeholder+value pairs as context parameter, terminated by an entry
      with the placeholder member set to NULL.
      
      The new helper is intended to aid converting the remaining calls of
      interpolate().  strbuf_expand() is smaller, more flexible and can be
      used to go faster than interpolate(), so it should replace the latter.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9b864e73
  15. 14 7月, 2008 2 次提交
  16. 10 2月, 2008 1 次提交
  17. 03 1月, 2008 1 次提交
    • J
      Uninline prefixcmp() · 698a68be
      Junio C Hamano 提交于
      Now the routine is an open-coded loop that avoids an extra
      strlen() in the previous implementation, it got a bit too big to
      be inlined.  Uninlining it makes code footprint smaller but the
      result still retains the avoidance of strlen() cost.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      698a68be
  18. 14 11月, 2007 1 次提交
    • S
      Handle broken vsnprintf implementations in strbuf · f141bd80
      Shawn O. Pearce 提交于
      Solaris 9's vsnprintf implementation returns -1 if we pass it a
      buffer of length 0.  The only way to get it to give us the actual
      length necessary for the formatted string is to grow the buffer
      out to have at least 1 byte available in the strbuf and then ask
      it to compute the length.
      
      If the available space is 0 I'm growing it out by 64 to ensure
      we will get an accurate length estimate from all implementations.
      Some callers may need to grow the strbuf again but 64 should be a
      reasonable enough initial growth.
      
      We also no longer silently fail to append to the string when we are
      faced with a broken vsnprintf implementation.  On Solaris 9 this
      silent failure caused me to no longer be able to execute "git clone"
      as we tried to exec the empty string rather than "git-clone".
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f141bd80
  19. 11 11月, 2007 1 次提交
  20. 09 11月, 2007 1 次提交
    • R
      --pretty=format: on-demand format expansion · cde75e59
      René Scharfe 提交于
      Some of the --pretty=format placeholders expansions are expensive to
      calculate.  This is made worse by the current code's use of
      interpolate(), which requires _all_ placeholders are to be prepared
      up front.
      
      One way to speed this up is to check which placeholders are present
      in the format string and to prepare only the expansions that are
      needed.  That still leaves the allocation overhead of interpolate().
      
      Another way is to use a callback based approach together with the
      strbuf library to keep allocations to a minimum and avoid string
      copies.  That's what this patch does.  It introduces a new strbuf
      function, strbuf_expand().
      
      The function takes a format string, list of placeholder strings,
      a user supplied function 'fn', and an opaque pointer 'context'
      to tell 'fn' what thingy to operate on.
      
      The function 'fn' is expected to accept a strbuf, a parsed
      placeholder string and the 'context' pointer, and append the
      interpolated value for the 'context' thingy, according to the
      format specified by the placeholder.
      
      Thanks to Pierre Habouzit for his suggestion to use strchrnul() and
      the code surrounding its callsite.  And thanks to Junio for most of
      this commit message. :)
      
      Here my measurements of most of Paul Mackerras' test cases that
      highlighted the performance problem (best of three runs):
      
      (master)
      $ time git log --pretty=oneline >/dev/null
      
      real    0m0.390s
      user    0m0.340s
      sys     0m0.040s
      
      (master)
      $ time git log --pretty=raw >/dev/null
      
      real    0m0.434s
      user    0m0.408s
      sys     0m0.016s
      
      (master)
      $ time git log --pretty="format:%H {%P} %ct" >/dev/null
      
      real    0m1.347s
      user    0m0.080s
      sys     0m1.256s
      
      (interp_find_active -- Dscho)
      $ time ./git log --pretty="format:%H {%P} %ct" >/dev/null
      
      real    0m0.694s
      user    0m0.020s
      sys     0m0.672s
      
      (strbuf_expand -- this patch)
      $ time ./git log --pretty="format:%H {%P} %ct" >/dev/null
      
      real    0m0.395s
      user    0m0.352s
      sys     0m0.028s
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cde75e59
  21. 30 9月, 2007 1 次提交
  22. 29 9月, 2007 1 次提交
    • P
      strbuf change: be sure ->buf is never ever NULL. · b315c5c0
      Pierre Habouzit 提交于
      For that purpose, the ->buf is always initialized with a char * buf living
      in the strbuf module. It is made a char * so that we can sloppily accept
      things that perform: sb->buf[0] = '\0', and because you can't pass "" as an
      initializer for ->buf without making gcc unhappy for very good reasons.
      
      strbuf_init/_detach/_grow have been fixed to trust ->alloc and not ->buf
      anymore.
      
      as a consequence strbuf_detach is _mandatory_ to detach a buffer, copying
      ->buf isn't an option anymore, if ->buf is going to escape from the scope,
      and eventually be free'd.
      
      API changes:
        * strbuf_setlen now always works, so just make strbuf_reset a convenience
          macro.
        * strbuf_detatch takes a size_t* optional argument (meaning it can be
          NULL) to copy the buffer's len, as it was needed for this refactor to
          make the code more readable, and working like the callers.
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b315c5c0
  23. 27 9月, 2007 1 次提交
  24. 26 9月, 2007 1 次提交
  25. 21 9月, 2007 1 次提交
    • P
      strbuf API additions and enhancements. · c76689df
      Pierre Habouzit 提交于
      Add strbuf_remove, change strbuf_insert:
        As both are special cases of strbuf_splice, implement them as such.
        gcc is able to do the math and generate almost optimal code this way.
      
      Add strbuf_swap:
        Exchange the values of its arguments.
        Use it in fast-import.c
      
      Also fix spacing issues in strbuf.h
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      c76689df
  26. 18 9月, 2007 1 次提交
  27. 17 9月, 2007 2 次提交
  28. 11 9月, 2007 1 次提交
    • P
      Strbuf API extensions and fixes. · f1696ee3
      Pierre Habouzit 提交于
        * 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: NPierre Habouzit <madcoder@debian.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f1696ee3
  29. 07 9月, 2007 1 次提交
    • P
      Rework strbuf API and semantics. · b449f4cf
      Pierre Habouzit 提交于
        The gory details are explained in strbuf.h. The change of semantics this
      patch enforces is that the embeded buffer has always a '\0' character after
      its last byte, to always make it a C-string. The offs-by-one changes are all
      related to that very change.
      
        A strbuf can be used to store byte arrays, or as an extended string
      library. The `buf' member can be passed to any C legacy string function,
      because strbuf operations always ensure there is a terminating \0 at the end
      of the buffer, not accounted in the `len' field of the structure.
      
        A strbuf can be used to generate a string/buffer whose final size is not
      really known, and then "strbuf_detach" can be used to get the built buffer,
      and keep the wrapping "strbuf" structure usable for further work again.
      
        Other interesting feature: strbuf_grow(sb, size) ensure that there is
      enough allocated space in `sb' to put `size' new octets of data in the
      buffer. It helps avoiding reallocating data for nothing when the problem the
      strbuf helps to solve has a known typical size.
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b449f4cf
  30. 07 6月, 2007 1 次提交
    • J
      War on whitespace · a6080a0a
      Junio C Hamano 提交于
      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: NJunio C Hamano <gitster@pobox.com>
      a6080a0a
  31. 21 12月, 2006 1 次提交
    • J
      simplify inclusion of system header files. · 85023577
      Junio C Hamano 提交于
      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: NJunio C Hamano <junkio@cox.net>
      85023577
  32. 21 5月, 2005 1 次提交
    • L
      sparse cleanup · e99d59ff
      Linus Torvalds 提交于
      Fix various things that sparse complains about:
       - use NULL instead of 0
       - make sure we declare everything properly, or mark it static
       - use proper function declarations ("fn(void)" instead of "fn()")
      
      Sparse is always right.
      e99d59ff
  33. 19 5月, 2005 2 次提交
  34. 27 4月, 2005 1 次提交
  35. 26 4月, 2005 1 次提交
    • J
      [PATCH] Introduce diff-tree-helper. · d1df5743
      Junio C Hamano 提交于
      This patch introduces a new program, diff-tree-helper.  It reads
      output from diff-cache and diff-tree, and produces a patch file.
      The diff format customization can be done the same way the
      show-diff uses; the same external diff interface introduced by
      the previous patch to drive diff from show-diff is used so this
      is not surprising.
      
      It is used like the following examples:
      
         $ diff-cache --cached -z <tree> | diff-tree-helper -z -R paths...
         $ diff-tree -r -z <tree1> <tree2> | diff-tree-helper -z paths...
      
       - As usual, the use of the -z flag is recommended in the script
         to pass NUL-terminated filenames through the pipe between
         commands.
      
       - The -R flag is used to generate reverse diff.  It does not
         matter for diff-tree case, but it is sometimes useful to get
         a patch in the desired direction out of diff-cache.
      
       - The paths parameters are used to restrict the paths that
         appears in the output.  Again this is useful to use with
         diff-cache, which, unlike diff-tree, does not take such paths
         restriction parameters.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      d1df5743