1. 31 Mar, 2014 1 commit
  2. 18 Jun, 2009 1 commit
    • Linus Torvalds's avatar
      Fix big left-shifts of unsigned char · 48fb7deb
      Linus Torvalds authored
      Shifting 'unsigned char' or 'unsigned short' left can result in sign
      extension errors, since the C integer promotion rules means that the
      unsigned char/short will get implicitly promoted to a signed 'int' due to
      the shift (or due to other operations).
      
      This normally doesn't matter, but if you shift things up sufficiently, it
      will now set the sign bit in 'int', and a subsequent cast to a bigger type
      (eg 'long' or 'unsigned long') will now sign-extend the value despite the
      original expression being unsigned.
      
      One example of this would be something like
      
      	unsigned long size;
      	unsigned char c;
      
      	size += c << 24;
      
      where despite all the variables being unsigned, 'c << 24' ends up being a
      signed entity, and will get sign-extended when then doing the addition in
      an 'unsigned long' type.
      
      Since git uses 'unsigned char' pointers extensively, we actually have this
      bug in a couple of places.
      
      I may have missed some, but this is the result of looking at
      
      	git grep '[^0-9 	][ 	]*<<[ 	][a-z]' -- '*.c' '*.h'
      	git grep '<<[   ]*24'
      
      which catches at least the common byte cases (shifting variables by a
      variable amount, and shifting by 24 bits).
      
      I also grepped for just 'unsigned char' variables in general, and
      converted the ones that most obviously ended up getting implicitly cast
      immediately anyway (eg hash_name(), encode_85()).
      
      In addition to just avoiding 'unsigned char', this patch also tries to use
      a common idiom for the delta header size thing. We had three different
      variations on it: "& 0x7fUL" in one place (getting the sign extension
      right), and "& ~0x80" and "& 0x7f" in two other places (not getting it
      right). Apart from making them all just avoid using "unsigned char" at
      all, I also unified them to then use a simple "& 0x7f".
      
      I considered making a sparse extension which warns about doing implicit
      casts from unsigned types to signed types, but it gets rather complex very
      quickly, so this is just a hack.
      Signed-off-by: 's avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      48fb7deb
  3. 12 Jul, 2007 1 commit
  4. 15 May, 2006 1 commit
  5. 05 May, 2006 1 commit
  6. 25 Apr, 2006 1 commit
    • Nicolas Pitre's avatar
      split the diff-delta interface · 08abe669
      Nicolas Pitre authored
      This patch splits the diff-delta interface into index creation and delta
      generation.  A wrapper is provided to preserve the diff-delta() call.
      
      This will allow for an optimization in pack-objects.c where the source
      object could be fixed and a full window of objects tentatively tried
      against
      that same source object without recomputing the source index each time.
      
      This patch only restructure things, plus a couple cleanups for good
      measure. There is no performance change yet.
      Signed-off-by: 's avatarNicolas Pitre <nico@cam.org>
      08abe669
  7. 07 Apr, 2006 1 commit
  8. 02 Mar, 2006 1 commit
    • Nicolas Pitre's avatar
      diff-delta: allow reusing of the reference buffer index · 38fd0721
      Nicolas Pitre authored
      When a reference buffer is used multiple times then its index can be
      computed only once and reused multiple times.  This patch adds an extra
      pointer to a pointer argument (from_index) to diff_delta() for this.
      
      If from_index is NULL then everything is like before.
      
      If from_index is non NULL and *from_index is NULL then the index is
      created and its location stored to *from_index.  In this case the caller
      has the responsibility to free the memory pointed to by *from_index.
      
      If from_index and *from_index are non NULL then the index is reused as
      is.
      
      This currently saves about 10% of CPU time to repack the git archive.
      Signed-off-by: 's avatarNicolas Pitre <nico@cam.org>
      Signed-off-by: 's avatarJunio C Hamano <junkio@cox.net>
      38fd0721
  9. 10 Feb, 2006 1 commit
  10. 13 Dec, 2005 1 commit
  11. 12 Dec, 2005 1 commit
  12. 29 Jun, 2005 1 commit
  13. 27 Jun, 2005 1 commit
  14. 26 Jun, 2005 1 commit
    • Linus Torvalds's avatar
      Add a "max_size" parameter to diff_delta() · 75c42d8c
      Linus Torvalds authored
      Anything that generates a delta to see if two objects are close usually
      isn't interested in the delta ends up being bigger than some specified
      size, and this allows us to stop delta generation early when that
      happens.
      75c42d8c
  15. 08 Jun, 2005 1 commit
  16. 20 May, 2005 1 commit
  17. 19 May, 2005 1 commit