1. 14 Nov, 2018 1 commit
    • brian m. carlson's avatar
      hex: introduce functions to print arbitrary hashes · 47edb649
      brian m. carlson authored
      Currently, we have functions that turn an arbitrary SHA-1 value or an
      object ID into hex format, either using a static buffer or with a
      user-provided buffer.  Add variants of these functions that can handle
      an arbitrary hash algorithm, specified by constant.  Update the
      documentation as well.
      While we're at it, remove the "extern" declaration from this family of
      functions, since it's not needed and our style now recommends against
      We use the variant taking the algorithm structure pointer as the
      internal variant, since taking an algorithm pointer is the easiest way
      to handle all of the variants in use.
      Note that we maintain these functions because there are hashes which
      must change based on the hash algorithm in use but are not object IDs
      (such as pack checksums).
      Signed-off-by: brian m. carlson's avatarbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
  2. 16 Jul, 2018 1 commit
  3. 01 Nov, 2017 1 commit
  4. 27 Mar, 2017 1 commit
  5. 20 Feb, 2017 1 commit
  6. 26 Oct, 2016 1 commit
    • René Scharfe's avatar
      hex: make wraparound of the index into ring-buffer explicit · bb84735c
      René Scharfe authored
      Overflow is defined for unsigned integers, but not for signed ones.
      We could make the ring-buffer index in sha1_to_hex() and
      get_pathname() unsigned to be on the safe side to resolve this, but
      let's make it explicit that we are wrapping around at whatever the
      number of elements the ring-buffer has.  The compiler is smart enough
      to turn modulus into bitmask for these codepaths that use
      ring-buffers of a size that is a power of 2.
      Signed-off-by: 's avatarRené Scharfe <l.s.r@web.de>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
  7. 07 Sep, 2016 1 commit
  8. 28 Jun, 2016 1 commit
  9. 25 Sep, 2015 1 commit
    • Jeff King's avatar
      add reentrant variants of sha1_to_hex and find_unique_abbrev · af49c6d0
      Jeff King authored
      The sha1_to_hex and find_unique_abbrev functions always
      write into reusable static buffers. There are a few problems
      with this:
        - future calls overwrite our result. This is especially
          annoying with find_unique_abbrev, which does not have a
          ring of buffers, so you cannot even printf() a result
          that has two abbreviated sha1s.
        - if you want to put the result into another buffer, we
          often strcpy, which looks suspicious when auditing for
      This patch introduces sha1_to_hex_r and find_unique_abbrev_r,
      which write into a user-provided buffer. Of course this is
      just punting on the overflow-auditing, as the buffer
      obviously needs to be GIT_SHA1_HEXSZ + 1 bytes. But it is
      much easier to audit, since that is a well-known size.
      We retain the non-reentrant forms, which just become thin
      wrappers around the reentrant ones. This patch also adds a
      strbuf variant of find_unique_abbrev, which will be handy in
      later patches.
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
  10. 14 Mar, 2015 1 commit
    • brian m. carlson's avatar
      define utility functions for object IDs · aa1c6fdf
      brian m. carlson authored
      There are several utility functions (hashcmp and friends) that are used
      for comparing object IDs (SHA-1 values).  Using these functions, which
      take pointers to unsigned char, with struct object_id requires tiresome
      access to the sha1 member, which bloats code and violates the desired
      encapsulation.  Provide wrappers around these functions for struct
      object_id for neater, more maintainable code.  Use the new constants to
      avoid the hard-coded 20s and 40s throughout the original functions.
      These functions simply call the underlying pointer-to-unsigned-char
      versions to ensure that any performance improvements will be passed
      through to the new functions.
      Signed-off-by: brian m. carlson's avatarbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
  11. 13 Feb, 2015 1 commit
  12. 05 Oct, 2011 1 commit
  13. 22 Jan, 2010 1 commit
    • Linus Torvalds's avatar
      slim down "git show-index" · a5031214
      Linus Torvalds authored
      As the documentation says, this is primarily for debugging, and
      in the longer term we should rename it to test-show-index or something.
      In the meantime, just avoid xmalloc (which slurps in the rest of git), and
      separating out the trivial hex functions into "hex.o".
      This results in
        [torvalds@nehalem git]$ size git-show-index
             text    data     bss     dec     hex filename
           222818    2276  112688  337782   52776 git-show-index (before)
             5696     624    1264    7584    1da0 git-show-index (after)
      which is a whole lot better.
      Signed-off-by: 's avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>