1. 18 Mar, 2009 7 commits
  2. 11 Feb, 2009 5 commits
    • Correct some comments in readloose tests · 04c9c16e
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Add the git_odb_exists() object query function · 82324ac1
      This function determines if the given object can be found
      in the object database. At present, only the local object
      database is searched.
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Rearrange some code to improve clarity · e9f5e877
      In particular, the test for z-stream input completion
      (zs.avail_in != 0) logically belongs with the test for
      the Z_STREAM_END stream status. This is also consistent
      with the identical check in finish_inflate().
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Check for error returns from inflateInit() · 236e7579
      At present, it is sufficient to ensure that an error return
      from inflateInit() is not ignored. Most error returns, like
      Z_VERSION_ERROR and Z_STREAM_ERROR, indicate programming or
      build errors. These errors could, perhaps, be handled with
      simple asserts. However, for a Z_MEM_ERROR, we may want to
      perform some further error handling in the future.
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Fix a potential memory leak · c94eb4aa
      In particular, neglecting to call inflateEnd() along various
      codepaths in the inflate_tail() routine, would result in the
      failure to release zlib internal state.
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
  3. 01 Feb, 2009 4 commits
  4. 28 Jan, 2009 4 commits
  5. 03 Jan, 2009 8 commits
    • Add the binary delta apply algorithm for pack style deltas · c23841c8
      The git__delta_apply() function can be used to apply a Git style
      delta, such as those used in pack files or in git patch files,
      to recover the original object stream.
      
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Shawn O. Pearce committed
    • Precompute the fanout decoding and the oid offset in a pack-*.idx · bed3229b
      The fanout table is fairly commonly accessed, we need to read it
      twice for each object we lookup in any given pack file.  Most of
      the processors running Git are running in little-endian mode, as
      they are variants of the x86 platform, so reading the fanout is
      a costly operation as we need to convert from network byte order
      to local byte order.  By decoding the fanout table into a malloc
      obtained buffer we can save these 2 decode operations per lookup
      and make search go more quickly.
      
      This also cleans up the initialization of the search functions
      by cutting out a few instructions, saving a small amount of time.
      
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Shawn O. Pearce committed
    • Add basic support to read pack-*.idx v1 and v2 files · a7c60cfc
      The index data is mapped into memory and then scanned using a
      binary search algorithm to locate the matching entry for the
      supplied git_oid.  The standard fanout hash trick is applied to
      reduce the search space by 8 iterations.
      
      Since the v1 and v2 file formats differ in their search function,
      due to the different layouts used for the object records, we use
      two different search implementations and a virtual function pointer
      to jump to the correct version of code for the current pack index.
      The single function jump per-pack should be faster then computing
      a branch point inside the inner loop of a common binary search.
      
      To improve concurrency during read operations the pack lock is only
      held while verifying the index is actually open, or while opening
      the index for the first time.  This permits multiple concurrent
      readers to scan through the same index.
      
      If an invalid index file is opened we close it and mark the
      git_pack's invalid bit to true.  The git_pack structure is kept
      around in its parent git_packlist, but the invalid bit will cause
      all future readers to skip over the pack entirely.  Pruning the
      invalid entries is relatively unimportant because they shouldn't
      be very common, a $GIT_DIRECTORY/objects/pack directory tends to
      only have valid pack files.
      
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Shawn O. Pearce committed
    • Add a simple mmap wrapper for cross-platform mmap usage · 20e7f426
      Win32 has a variant of mmap that is harder to use than POSIX, but
      to run natively and efficiently on Win32 we need some form of it.
      
      gitfo_map_ro() provides a basic mmap function for use in locations
      where we need read-only random data access to large ranges of a file,
      such as a pack-*.idx.
      
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Shawn O. Pearce committed
    • Refactor pack memory management and locking to be safer · 098ac57a
      Using an atomic reference counter is difficult to make
      cross-platform, as the reference count implementations
      are generally processor specific.  Its also hard to do
      a proper multi-read/single-write implementation.
      
      We now use a simple mutex around the reference count for the list
      of packs.  Readers grab the mutex and either build the list, or
      increment the existing one's reference count.  When the reader is
      done with the list, the reference count is decremented.  In this way
      parallel readers are able to operate on the list without worrying
      about it being deallocated out from under them.
      
      Individual pack structures are held by reference counts, but we
      only care about the list the pack structure is held in.  There is
      no need to increment/decrement the pack reference counts as we
      scan through them during a read operation, the caller holds the
      git_packlist and that is sufficient to hold the packs it references.
      
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Shawn O. Pearce committed
    • Fix snprintf compiler warning on cygwin · 3a33c7b3
      As far as gcc is concerned, the "z size specifier" is available as
      an extension to the language, which is available with or without any
      -std= switch.  (I think you have to go back to 2.95 for a version
      of gcc which doesn't work.)  Many other compilers have this as an
      extension as well (ie without the equivalent of -std=c99).
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Change the use of asm/atomic.h to require -DGIT_HAS_ASM_ATOMIC · 51eb2f90
      These headers aren't always available; they typically come from the
      Linux kernel, but aren't supposed to be exported into the userspace
      /usr/include.  Modern kernels won't install these and some distros
      rm -rf the directory post kernel header install.
      
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Shawn O. Pearce committed
    • Fix pthread_mutex based gitrc_dec · 11bb049b
      The function should return true only when the counter drops to 0.
      
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Shawn O. Pearce committed
  6. 01 Jan, 2009 3 commits
  7. 31 Dec, 2008 9 commits