1. 03 Jan, 2009 5 commits
    • 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
  2. 01 Jan, 2009 3 commits
  3. 31 Dec, 2008 19 commits
  4. 30 Dec, 2008 5 commits
    • Add a routine to determine a git_oid given an git_obj · c960d6a3
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Add some routines for SHA1 hash computation · 007e0753
      [sp: Changed signature for output to use git_oid, and added
           a test case to verify an allocated git_hash_ctx can be
           reinitialized and reused.]
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Fix a bug in gitfo_read_file() · 42fd40db
      In particular, when asked to read an empty file, this function
      calls malloc() with a zero size allocation request. Standard C
      says that the behaviour of malloc() in this case is implementation
      defined.
      
      [C99, 7.20.3 says "... If the size of the space requested is zero,
      the behavior is implementation-defined: either a null pointer is
      returned, or the behavior is as if the size were some nonzero
      value, except that the returned pointer shall not be used to
      access an object."]
      
      Finesse the issue by over-allocating by one byte. Setting the extra
      byte to '\0' may also provide a useful sentinel for text files.
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Add pkg-config support. · d7fbfe15
      The libgit2.pc is generated on make install and installed, to allow
      using the lib through the pkg-config helper.
      
      Signed-off-by: Steve Frécinaux <code@istique.net>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Steve Frécinaux committed
    • Add make install and uninstall targets. · 5ddbd5ed
      It accepts a prefix= parameter (default: /usr/local).
      
      Signed-off-by: Steve Frécinaux <code@istique.net>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Steve Frécinaux committed
  5. 19 Dec, 2008 2 commits
    • Implement git_odb__read_loose() · 3d3552e8
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Add a file reading routine along with an io buffer type · 75d58430
      In particular, the gitfo_read_file() routine can be used to slurp
      the complete file contents into an gitfo_buf structure. The buffer
      content will be allocated by malloc() and may be released by the
      gitfo_free_buf() routine. The io buffer type can be initialised
      on the stack with the GITFO_BUF_INIT macro.
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
  6. 18 Dec, 2008 2 commits
  7. 10 Dec, 2008 1 commit
  8. 09 Dec, 2008 3 commits
    • Fix an "implicit function definition" warning on cygwin · b3be0fc7
      In particular, the warning relates to malloc(), which is
      declared in <stdlib.h>.  This header is now included,
      indirectly, via the "common.h" header.
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Add a GIT_PATH_MAX constant · 5ee2fe77
      The PATH_MAX symbol is often, but not always, defined
      in the <limits.h> header.  In particular, on cygwin you
      need to include this header to avoid a compilation error.
      
      However, some systems define PATH_MAX to be something as
      small as 256, which POSIX is happy to allow, while others
      allow much larger values.  In general it can vary from
      one filesystem to another.
      
      In order to avoid the vagaries of different systems, define
      our own symbol.
      
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed
    • Fix some doxygen warnings and errors · 192678b5
      Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
      Ramsay Jones committed