1. 23 Jun, 2013 1 commit
    • Constrain mkdir calls to avoid extra mkdirs · 8294e8cf
      This updates the calls that make the subdirectories for objects
      to use a base directory above which git_futils_mkdir won't walk
      any higher.  This prevents attempts to mkdir all the way up to
      the root of the filesystem.
      
      Also, this moves the objects_dir into the loose backend structure
      and removes the separate allocation, plus does some preformatting
      of the objects_dir value to guarantee a trailing slash, etc.
      Russell Belfer committed
  2. 21 Apr, 2013 1 commit
    • Move odb_backend implementors stuff into git2/sys · 83cc70d9
      This moves some of the odb_backend stuff that is related to the
      internals of an odb_backend implementation into include/git2/sys.
      
      Some of the stuff related to streaming I left in include/git2
      because it seemed like it would be reasonably needed by a normal
      user who wanted to stream objects into and out of the ODB.
      
      Also, I added APIs for traversing the list of backends so that
      some of the tests would not need to access ODB internals.
      Russell Belfer committed
  3. 08 Jan, 2013 1 commit
  4. 21 Dec, 2012 1 commit
  5. 30 Nov, 2012 1 commit
  6. 27 Nov, 2012 1 commit
  7. 04 Aug, 2012 1 commit
    • Update iterators for consistency across library · 5dca2010
      This updates all the `foreach()` type functions across the library
      that take callbacks from the user to have a consistent behavior.
      The rules are:
      
      * A callback terminates the loop by returning any non-zero value
      * Once the callback returns non-zero, it will not be called again
        (i.e. the loop stops all iteration regardless of state)
      * If the callback returns non-zero, the parent fn returns GIT_EUSER
      * Although the parent returns GIT_EUSER, no error will be set in
        the library and `giterr_last()` will return NULL if called.
      
      This commit makes those changes across the library and adds tests
      for most of the iteration APIs to make sure that they follow the
      above rules.
      Russell Belfer committed
  8. 24 Jul, 2012 1 commit
  9. 12 Jul, 2012 1 commit
  10. 03 Jul, 2012 1 commit
  11. 17 May, 2012 2 commits
  12. 04 May, 2012 1 commit
    • Fix valgrind issues · 282283ac
      There are three changes here:
      - correctly propogate error code from failed object lookups
      - make zlib inflate use our allocators
      - add OID to notfound error in ODB lookups
      Russell Belfer committed
  13. 30 Apr, 2012 1 commit
  14. 04 Apr, 2012 1 commit
  15. 16 Mar, 2012 1 commit
  16. 13 Mar, 2012 1 commit
    • Migrate ODB files to new error handling · e1de726c
      This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to
      the new style of error handling.  Also got the unix and win32
      versions of map.c.  There are some minor changes to other
      files but no others were completely converted.
      
      This also contains an update to filebuf so that a zeroed out
      filebuf will not think that the fd (== 0) is actually open
      (and inadvertently call close() on fd 0 if cleaned up).
      
      Lastly, this was built and tested on win32 and contains a
      bunch of fixes for the win32 build which was pretty broken.
      Russell Belfer committed
  17. 06 Mar, 2012 2 commits
  18. 05 Mar, 2012 1 commit
  19. 27 Feb, 2012 1 commit
    • buffer: Unify `git_fbuffer` and `git_buf` · 13224ea4
      This makes so much sense that I can't believe it hasn't been done
      before. Kill the old `git_fbuffer` and read files straight into
      `git_buf` objects.
      
      Also: In order to fully support 4GB files in 32-bit systems, the
      `git_buf` implementation has been changed from using `ssize_t` for
      storage and storing negative values on allocation failure, to using
      `size_t` and changing the buffer pointer to a magical pointer on
      allocation failure.
      
      Hopefully this won't break anything.
      Vicent Martí committed
  20. 15 Feb, 2012 1 commit
  21. 13 Feb, 2012 1 commit
  22. 17 Jan, 2012 1 commit
    • Move path related functions from fileops to path · 1744fafe
      This takes all of the functions that look up simple data about
      paths (such as `git_futils_isdir`) and moves them over to path.h
      (becoming `git_path_isdir`).  This leaves fileops.h just with
      functions that actually manipulate the filesystem or look at
      the file contents in some way.
      
      As part of this, the dir.h header which is really just for win32
      support was moved into win32 (with some minor changes).
      Russell Belfer committed
  23. 08 Dec, 2011 1 commit
    • Use git_buf for path storage instead of stack-based buffers · 97769280
      This converts virtually all of the places that allocate GIT_PATH_MAX
      buffers on the stack for manipulating paths to use git_buf objects
      instead.  The patch is pretty careful not to touch the public API
      for libgit2, so there are a few places that still use GIT_PATH_MAX.
      
      This extends and changes some details of the git_buf implementation
      to add a couple of extra functions and to make error handling easier.
      
      This includes serious alterations to all the path.c functions, and
      several of the fileops.c ones, too.  Also, there are a number of new
      functions that parallel existing ones except that use a git_buf
      instead of a stack-based buffer (such as git_config_find_global_r
      that exists alongsize git_config_find_global).
      
      This also modifies the win32 version of p_realpath to allocate whatever
      buffer size is needed to accommodate the realpath instead of hardcoding
      a GIT_PATH_MAX limit, but that change needs to be tested still.
      Russell Belfer committed
  24. 22 Nov, 2011 1 commit
  25. 18 Nov, 2011 1 commit
  26. 29 Oct, 2011 1 commit
  27. 24 Oct, 2011 1 commit
    • Tolerate zlib deflation with window size < 32Kb · c51065e3
      libgit2 currently identifies loose objects as corrupt if they've been
      deflated using a window size less than 32Kb, because the
      is_zlib_compressed_data() function doesn't recognise the header
      byte as a zlib header. This patch makes the method tolerant of
      all valid window sizes (15-bit to 8-bit) - but doesn't sacrifice
      it's accuracy in distingushing the standard loose-object format
      from the experimental (now abandoned) format. It's based on a patch
      which has been merged into C-Git master branch:
      
      https://github.com/git/git/commit/7f684a2aff636f44a506
      
      On memory constrained systems zlib may use a much smaller window
      size - working on Agit, I found that Android uses a 4KB window;
      giving a header byte of 0x48, not 0x78. Consequently all loose
      objects generated by the Android platform appear 'corrupt' :(
      
      It might appear that this patch changes isStandardFormat() to the
      point where it could incorrectly identify the experimental format as
      the standard one, but the two criteria (bitmask & checksum) can only
      give a false result for an experimental object where both of the
      following are true:
      
      1) object size is exactly 8 bytes when uncompressed (bitmask)
      2) [single-byte in-pack git type&size header] * 256
         + [1st byte of the following zlib header] % 31 = 0 (checksum)
      
      As it happens, for all possible combinations of valid object type
      (1-4) and window bits (0-7), the only time when the checksum will be
      divisible by 31 is for 0x1838 - ie object type *1*, a Commit - which,
      due the fields all Commit objects must contain, could never be as
      small as 8 bytes in size.
      
      Given this, the combination of the two criteria (bitmask & checksum)
      always correctly determines the buffer format, and is more tolerant
      than the previous version.
      
      References:
      
      Android uses a 4KB window for deflation:
      http://android.git.kernel.org/?p=platform/libcore.git;a=blob;f=luni/src/main/native/java_util_zip_Deflater.cpp;h=c0b2feff196e63a7b85d97cf9ae5bb258
      
      Code snippet searching for false positives with the zlib checksum:
      https://gist.github.com/1118177
      
      Change-Id: Ifd84cd2bd6b46f087c9984fb4cbd8309f483dec0
      Roberto Tyley committed
  28. 14 Oct, 2011 2 commits
    • *: correct and codify various file permissions · 01ad7b3a
      The following files now have 0444 permissions:
      
      - loose objects
      - pack indexes
      - pack files
      - packs downloaded by fetch
      - packs downloaded by the HTTP transport
      
      And the following files now have 0666 permissions:
      
      - config files
      - repository indexes
      - reflogs
      - refs
      
      This brings libgit2 more in line with Git.
      
      Note that git_filebuf_commit() and git_filebuf_commit_at() have both
      gained a new mode parameter.
      
      The latter change fixes an important issue where filebufs created with
      GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3)
      usage). Now we chmod() the file before renaming it into place.
      
      Tests have been added to confirm that new commit, tag, and tree
      objects are created with the right permissions. I don't have access to
      Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
      Brodie Rao committed
    • fileops/repository: create (most) directories with 0777 permissions · ce8cd006
      To further match how Git behaves, this change makes most of the
      directories libgit2 creates in a git repo have a file mode of
      0777. Specifically:
      
      - Intermediate directories created with git_futils_mkpath2file() have
        0777 permissions. This affects odb_loose, reflog, and refs.
      
      - The top level folder for bare repos is created with 0777
        permissions.
      
      - The top level folder for non-bare repos is created with 0755
        permissions.
      
      - /objects/info/, /objects/pack/, /refs/heads/, and /refs/tags/ are
        created with 0777 permissions.
      
      Additionally, the following changes have been made:
      
      - fileops functions that create intermediate directories have grown a
        new dirmode parameter. The only exception to this is filebuf's
        lock_file(), which unconditionally creates intermediate directories
        with 0777 permissions when GIT_FILEBUF_FORCE is set.
      
      - The test runner now sets the umask to 0 before running any
        tests. This ensurses all file mode checks are consistent across
        systems.
      
      - t09-tree.c now does a directory permissions check. I've avoided
        adding this check to other tests that might reuse existing
        directories from the prefabricated test repos. Because they're
        checked into the repo, they have 0755 permissions.
      
      - Other assorted directories created by tests have 0777 permissions.
      Brodie Rao committed
  29. 29 Sep, 2011 2 commits
  30. 19 Sep, 2011 1 commit
    • Tabify everything · 87d9869f
      There were quite a few places were spaces were being used instead of
      tabs. Try to catch them all. This should hopefully not break anything.
      Except for `git blame`. Oh well.
      Vicent Marti committed
  31. 18 Sep, 2011 1 commit
    • Cleanup legal data · bb742ede
      1. The license header is technically not valid if it doesn't have a
      copyright signature.
      
      2. The COPYING file has been updated with the different licenses used in
      the project.
      
      3. The full GPLv2 header in each file annoys me.
      Vicent Marti committed
  32. 08 Sep, 2011 1 commit
  33. 30 Aug, 2011 1 commit
  34. 09 Jul, 2011 1 commit
    • odb: Direct writes are back · afeecf4f
      DIRECT WRITES ARE BACK AND FASTER THAN EVER. The streaming writer to the
      ODB was an overkill for the smaller objects like Commit and Tags; most
      of the streaming logic was taking too long.
      
      This commit makes Commits, Tags and Trees to be built-up in memory, and
      then written to disk in 2 pushes (header + data), instead of streaming
      everything.
      
      This is *always* faster, even for big files (since the git_filebuf class
      still does streaming writes when the memory cache overflows). This is
      also a gazillion lines of code smaller, because we don't have to
      precompute the final size of the object before starting the stream (this
      was kind of defeating the point of streaming, anyway).
      
      Blobs are still written with full streaming instead of loading them in
      memory, since this is still the fastest way.
      
      A new `git_buf` class has been added. It's missing some features, but
      it'll get there.
      Vicent Marti committed
  35. 05 Jul, 2011 1 commit
    • fileops: Cleanup · f79026b4
      Cleaned up the structure of the whole OS-abstraction layer.
      
      fileops.c now contains a set of utility methods for file management used
      by the library. These are abstractions on top of the original POSIX
      calls.
      
      There's a new file called `posix.c` that contains
      emulations/reimplementations of all the POSIX calls the library uses.
      These are prefixed with `p_`. There's a specific posix file for each
      platform (win32 and unix).
      
      All the path-related methods have been moved from `utils.c` to `path.c`
      and have their own prefix.
      Vicent Marti committed
  36. 16 Jun, 2011 1 commit