1. 17 1月, 2015 4 次提交
    • J
      strbuf.h: format asciidoc code blocks as 4-space indent · 088c9a86
      Jeff King 提交于
      This is much easier to read when the whole thing is stuffed
      inside a comment block. And there is precedent for this
      convention in markdown (and just in general ascii text).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      088c9a86
    • J
      strbuf.h: drop asciidoc list formatting from API docs · aa07cac4
      Jeff King 提交于
      Using a hanging indent is much more readable. This means we
      won't format as asciidoc anymore, but since we don't have a
      working system for extracting these comments anyway, it's
      probably more important to just make the source readable.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aa07cac4
    • S
      strbuf.h: unify documentation comments beginnings · 6afbbdda
      Stefan Beller 提交于
      The prior patch uses "/**" to denote "documentation"
      comments that we pulled from api-strbuf.txt. Let's use a
      consistent style for similar comments that were already in
      strbuf.h.
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6afbbdda
    • J
      strbuf.h: integrate api-strbuf.txt documentation · bdfdaa49
      Jeff King 提交于
      Some of strbuf is documented as comments above functions,
      and some is separate in Documentation/technical/api-strbuf.txt.
      This makes it annoying to find the appropriate documentation.
      We'd rather have it all in one place, which means all in the
      text document, or all in the header.
      
      Let's choose the header as that place. Even though the
      formatting is not quite as pretty, this keeps the
      documentation close to the related code.  The hope is that
      this makes it easier to find what you want (human-readable
      comments are right next to the C declarations), and easier
      for writers to keep the documentation up to date.
      
      This is more or less a straight import of the text from
      api-strbuf.txt into C comments, complete with asciidoc
      formatting. The exceptions are:
      
       1. All comments created in this way are started with "/**"
          to indicate they are part of the API documentation. This
          may help later with extracting the text to pretty-print
          it.
      
       2. Function descriptions do not repeat the function name,
          as it is available in the context directly below.  So:
      
            `strbuf_add`::
      
                Add data of given length to the buffer.
      
          from api-strbuf.txt becomes:
      
            /**
             * Add data of given length to the buffer.
             */
            void strbuf_add(struct strbuf *sb, const void *, size_t);
      
          As a result, any block-continuation required in asciidoc
          for that list item was dropped in favor of straight
          blank-line paragraph (since it is not necessary when we
          are not in a list item).
      
       3. There is minor re-wording to integrate existing comments
          and api-strbuf text. In each case, I took whichever
          version was more descriptive, and eliminated any
          redundancies. In one case, for strbuf_addstr, the api
          documentation gave its inline definition; I eliminated
          this as redundant with the actual definition, which can
          be seen directly below the comment.
      
       4. The functions in the header file are re-ordered to match
          the ordering of the API documentation, under the
          assumption that more thought went into the grouping
          there.
      Helped-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bdfdaa49
  2. 09 9月, 2014 1 次提交
  3. 27 8月, 2014 1 次提交
  4. 29 7月, 2014 1 次提交
  5. 01 7月, 2014 1 次提交
  6. 20 6月, 2014 1 次提交
    • J
      strbuf: add xstrfmt helper · 30a0ddb7
      Jeff King 提交于
      You can use a strbuf to build up a string from parts, and
      then detach it. In the general case, you might use multiple
      strbuf_add* functions to do the building. However, in many
      cases, a single strbuf_addf is sufficient, and we end up
      with:
      
        struct strbuf buf = STRBUF_INIT;
        ...
        strbuf_addf(&buf, fmt, some, args);
        str = strbuf_detach(&buf, NULL);
      
      We can make this much more readable (and avoid introducing
      an extra variable, which can clutter the code) by
      introducing a convenience function:
      
        str = xstrfmt(fmt, some, args);
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      30a0ddb7
  7. 28 5月, 2014 1 次提交
  8. 24 5月, 2014 2 次提交
  9. 04 3月, 2014 1 次提交
  10. 11 4月, 2013 1 次提交
    • A
      strbuf: create strbuf_humanise_bytes() to show byte sizes · 079b546a
      Antoine Pelisse 提交于
      Humanization of downloaded size is done in the same function as text
      formatting in 'process.c'. The code cannot be reused easily elsewhere.
      
      Separate text formatting from size simplification and make the
      function public in strbuf so that it can easily be used by other
      callers.
      
      We now can use strbuf_humanise_bytes() for both downloaded size and
      download speed calculation. One of the drawbacks is that speed will
      now look like this when download is stalled: "0 bytes/s" instead of
      "0 KiB/s".
      Signed-off-by: NAntoine Pelisse <apelisse@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      079b546a
  11. 17 1月, 2013 1 次提交
    • J
      Allow custom "comment char" · eff80a9f
      Junio C Hamano 提交于
      Some users do want to write a line that begin with a pound sign, #,
      in their commit log message.  Many tracking system recognise
      a token of #<bugid> form, for example.
      
      The support we offer these use cases is not very friendly to the end
      users.  They have a choice between
      
       - Don't do it.  Avoid such a line by rewrapping or indenting; and
      
       - Use --cleanup=whitespace but remove all the hint lines we add.
      
      Give them a way to set a custom comment char, e.g.
      
          $ git -c core.commentchar="%" commit
      
      so that they do not have to do either of the two workarounds.
      
      [jc: although I started the topic, all the tests and documentation
      updates, many of the call sites of the new strbuf_add_commented_*()
      functions, and the change to git-submodule.sh scripted Porcelain are
      from Ralf.]
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NRalf Thielow <ralf.thielow@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      eff80a9f
  12. 27 11月, 2012 1 次提交
  13. 04 11月, 2012 2 次提交
  14. 16 9月, 2012 1 次提交
  15. 25 4月, 2012 1 次提交
  16. 23 2月, 2012 1 次提交
  17. 13 12月, 2011 1 次提交
  18. 09 11月, 2011 1 次提交
    • J
      fmt-merge-msg: Add contents of merged tag in the merge message · 895680f0
      Junio C Hamano 提交于
      When a contributor asks the integrator to merge her history, a signed tag
      can be a good vehicle to communicate the authenticity of the request while
      conveying other information such as the purpose of the topic.
      
      E.g. a signed tag "for-linus" can be created, and the integrator can run:
      
         $ git pull git://example.com/work.git/ for-linus
      
      This would allow the integrator to run "git verify-tag FETCH_HEAD" to
      validate the signed tag.
      
      Update fmt-merge-msg so that it pre-fills the merge message template with
      the body (but not signature) of the tag object to help the integrator write
      a better merge message, in the same spirit as the existing merge.log summary
      lines.
      
      The message that comes from GPG signature validation is also included in
      the merge message template to help the integrator verify it, but they are
      prefixed with "#" to make them comments.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      895680f0
  19. 23 6月, 2011 2 次提交
    • J
      strbuf: allow strbuf_split to work on non-strbufs · 2f1d9e2b
      Jeff King 提交于
      The strbuf_split function takes a strbuf as input, and
      outputs a list of strbufs. However, there is no reason that
      the input has to be a strbuf, and not an arbitrary buffer.
      
      This patch adds strbuf_split_buf for a length-delimited
      buffer, and strbuf_split_str for NUL-terminated strings.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2f1d9e2b
    • J
      strbuf_split: add a max parameter · 28fc3a68
      Jeff King 提交于
      Sometimes when splitting, you only want a limited number of
      fields, and for the final field to contain "everything
      else", even if it includes the delimiter.
      
      This patch introduces strbuf_split_max, which provides a
      "max number of fields" parameter; it behaves similarly to
      perl's "split" with a 3rd field.
      
      The existing 2-argument form of strbuf_split is retained for
      compatibility and ease-of-use.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28fc3a68
  20. 28 4月, 2011 1 次提交
    • R
      strbuf: clarify assertion in strbuf_setlen() · 7141efab
      René Scharfe 提交于
      Commit a8f3e221 introduced the strbuf_grow() call to strbuf_setlen() to
      make ensure that there was at least one byte available to write the
      mandatory trailing NUL, even for previously unallocated strbufs.
      
      Then b315c5c0 added strbuf_slopbuf for the same reason, only globally for
      all uses of strbufs.
      
      Thus the strbuf_grow() call can be removed now.  This avoids readers of
      strbuf.h from mistakenly thinking that strbuf_setlen() can be used to
      extend a strbuf.
      
      The following assert() needs to be changed to cope with the fact that
      sb->alloc can now be zero, which is OK as long as len is also zero.  As
      suggested by Junio, use the chance to convert it to a die() with a short
      explanatory message.  The pattern of 'die("BUG: ...")' is already used in
      strbuf.c.
      
      This was the only assert() in strbuf.[ch], so assert.h doesn't have to be
      included anymore either.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7141efab
  21. 31 3月, 2011 1 次提交
  22. 26 2月, 2011 1 次提交
  23. 28 9月, 2010 1 次提交
  24. 15 1月, 2010 1 次提交
  25. 14 1月, 2010 1 次提交
  26. 12 1月, 2010 1 次提交
  27. 16 11月, 2009 1 次提交
  28. 06 8月, 2009 1 次提交
  29. 23 4月, 2009 1 次提交
  30. 23 3月, 2009 2 次提交
  31. 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
  32. 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
  33. 26 7月, 2008 1 次提交