1. 27 Nov, 2012 1 commit
    • Fix up some missing consts in tree & index · 16248ee2
      This fixes some missed places where we can apply const-ness to
      various public APIs.
      
      There are still some index and tree APIs that cannot take const
      pointers because we sort our `git_vectors` lazily and so we can't
      reliably bsearch the index and tree content without applying a
      `git_vector_sort()` first.
      
      This also fixes some missed places where size_t can be used and
      where const can be applied to a couple internal functions.
      Russell Belfer committed
  2. 09 Nov, 2012 2 commits
    • Rework checkout with new strategy options · ad9a921b
      This is a major reworking of checkout strategy options.  The
      checkout code is now sensitive to the contents of the HEAD tree
      and the new options allow you to update the working tree so that
      it will match the index content only when it previously matched
      the contents of the HEAD.  This allows you to, for example, to
      distinguish between removing files that are in the HEAD but not
      in the index, vs just removing all untracked files.
      
      Because of various corner cases that arise, etc., this required
      some additional capabilities in rmdir and other utility functions.
      
      This includes the beginnings of an implementation of code to read
      a partial tree into the index based on a pathspec, but that is
      not enabled because of the possibility of creating conflicting
      index entries.
      Russell Belfer committed
    • Some diff refactorings to help code reuse · 55cbd05b
      There are some diff functions that are useful in a rewritten
      checkout and this lays some groundwork for that.  This contains
      three main things:
      
      1. Share the function diff uses to calculate the OID for a file
         in the working directory (now named `git_diff__oid_for_file`
      2. Add a `git_diff__paired_foreach` function to iterator over
         two diff lists concurrently.  Convert status to use it.
      3. Move all the string/prefix/index entry comparisons into
         function pointers inside the `git_diff_list` object so they
         can be switched between case sensitive and insensitive
         versions.  This makes them easier to reuse in various
         functions without replicating logic.  As part of this, move
         a couple of index functions out of diff.c and into index.c.
      Russell Belfer committed
  3. 01 Nov, 2012 1 commit
  4. 30 Oct, 2012 1 commit
  5. 17 Sep, 2012 1 commit
  6. 19 Jun, 2012 1 commit
    • Make index add/append support core.filemode flag · da825c92
      This fixes git_index_add and git_index_append to behave more like
      core git, preserving old filemode data in the index when adding
      and/or appending with core.filemode = false.
      
      This also has placeholder support for core.symlinks and
      core.ignorecase, but those flags are not implemented (well,
      symlinks has partial support for preserving mode information in
      the same way that git does, but it isn't tested).
      Russell Belfer committed
  7. 15 May, 2012 1 commit
    • Ranged iterators and rewritten git_status_file · 41a82592
      The goal of this work is to rewrite git_status_file to use the
      same underlying code as git_status_foreach.
      
      This is done in 3 phases:
      
      1. Extend iterators to allow ranged iteration with start and
         end prefixes for the range of file names to be covered.
      2. Improve diff so that when there is a pathspec and there is
         a common non-wildcard prefix of the pathspec, it will use
         ranged iterators to minimize excess iteration.
      3. Rewrite git_status_file to call git_status_foreach_ext
         with a pathspec that covers just the one file being checked.
      
      Since ranged iterators underlie the status & diff implementation,
      this is actually fairly efficient.  The workdir iterator does
      end up loading the contents of all the directories down to the
      single file, which should ideally be avoided, but it is pretty
      good.
      Russell Belfer committed
  8. 19 Mar, 2012 1 commit
    • Migrate index, oid, and utils to new errors · 7c7ff7d1
      This includes a few cleanups that came up while converting
      these files.
      
      This commit introduces a could new git error classes, including
      the catchall class: GITERR_INVALID which I'm using as the class
      for invalid and out of range values which are detected at too low
      a level of library to use a higher level classification.  For
      example, an overflow error in parsing an integer or a bad letter
      in parsing an OID string would generate an error in this class.
      Russell Belfer committed
  9. 13 Feb, 2012 1 commit
  10. 26 Nov, 2011 1 commit
    • repository: Change ownership semantics · 9462c471
      The ownership semantics have been changed all over the library to be
      consistent. There are no more "borrowed" or duplicated references.
      
      Main changes:
      
      	- `git_repository_open2` and `3` have been dropped.
      
      	- Added setters and getters to hotswap all the repository owned
      	objects:
      
      		`git_repository_index`
      		`git_repository_set_index`
      		`git_repository_odb`
      		`git_repository_set_odb`
      		`git_repository_config`
      		`git_repository_set_config`
      		`git_repository_workdir`
      		`git_repository_set_workdir`
      
      	Now working directories/index files/ODBs and so on can be
      	hot-swapped after creating a repository and between operations.
      
      	- All these objects now have proper ownership semantics with
      	refcounting: they all require freeing after they are no longer
      	needed (the repository always keeps its internal reference).
      
      	- Repository open and initialization has been updated to keep in
      	mind the configuration files. Bare repositories are now always
      	detected, and a default config file is created on init.
      
      	- All the tests affected by these changes have been dropped from the
      	old test suite and ported to the new one.
      Vicent Marti committed
  11. 14 Oct, 2011 1 commit
    • *: 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
  12. 27 Sep, 2011 1 commit
  13. 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
  14. 21 Apr, 2011 1 commit
    • index: Add API for unmerged entries · 4c0b6a6d
      New external functions:
      	- git_index_unmerged_entrycount: Counts the unmerged entries in
      	  the index
      	- git_index_get_unmerged: Gets an unmerged entry from the index
      	  by name
      
      New internal functions:
      	- read_unmerged: Wrapper for read_unmerged_internal
      	- read_unmerged_internal: Reads unmerged entries from the index
      	  if the index has the INDEX_EXT_UNMERGED_SIG set
      	- unmerged_srch: Search function for unmerged vector
      	- unmerged_cmp: Compare function for unmerged vector
      
      New data structures:
      	- git_index now contains a git_vector unmerged that stores
      	  unmerged entries
      	- git_index_entry_unmerged: Representation of an unmerged file
      	  entry. It represents all three versions of the file at the
      	  same time, with one name, three modes and three OIDs
      Jakob Pfender committed
  15. 03 Mar, 2011 1 commit
    • Fix searching in git_vector · 86d7e1ca
      We now store only one sorting callback that does entry comparison. This
      is used when sorting the entries using a quicksort, and when looking for
      a specific entry with the new search methods.
      
      The following search methods now exist:
      
      	git_vector_search(vector, entry)
      	git_vector_search2(vector, custom_search_callback, key)
      
      	git_vector_bsearch(vector, entry)
      	git_vector_bsearch2(vector, custom_search_callback, key)
      
      The sorting state of the vector is now stored internally.
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  16. 21 Feb, 2011 1 commit
    • Rewrite all file IO for more performance · 817c2820
      The new `git_filebuf` structure provides atomic high-performance writes
      to disk by using a write cache, and optionally a double-buffered scheme
      through a worker thread (not enabled yet).
      
      Writes can be done 3-layered, like in git.git (user code -> write cache
      -> disk), or 2-layered, by writing directly on the cache. This makes
      index writing considerably faster.
      
      The `git_filebuf` structure contains all the old functionality of
      `git_filelock` for atomic file writes and reads. The `git_filelock`
      structure has been removed.
      
      Additionally, the `git_filebuf` API allows to automatically hash (SHA1)
      all the data as it is written to disk (hashing is done smartly on big
      chunks to improve performance).
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  17. 17 Feb, 2011 1 commit
    • Improve the performance when writing Index files · 348c7335
      In response to issue #60 (git_index_write really slow), the write_index
      function has been rewritten to improve its performance -- it should now
      be in par with the performance of git.git.
      
      On top of that, if Posix Threads are available when compiling libgit2, a
      new threaded writing system will be used (3 separate threads take care
      of solving byte-endianness, hashing the contents of the index and
      writing to disk, respectively). For very long Index files, this method
      is up to 3x times faster than git.git.
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  18. 06 Dec, 2010 1 commit
  19. 02 Dec, 2010 1 commit
    • Refactor all 'vector' functions into common code · c4034e63
      All the operations on the 'git_index_entry' array and the
      'git_tree_entry' array have been refactored into common code in the
      src/vector.c file.
      
      The new vector methods support:
      	- insertion:	O(1) (avg)
      	- deletion:		O(n)
      	- searching:	O(logn)
      	- sorting:		O(logn)
      	- r. access:	O(1)
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  20. 29 Nov, 2010 1 commit
  21. 16 Nov, 2010 1 commit
    • Add support for 'index add' · c3a20d5c
      Actually add files to the index by creating their corresponding blob and
      storing it on the repository, then getting the hash and updating the
      index file.
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  22. 02 Nov, 2010 1 commit
    • Change git_repository initialization to use a path · 6fd195d7
      The constructor to git_repository is now called
      
      	'git_repository_open(path)'
      
      and takes a path to a git repository instead of an existing ODB object.
      Unit tests have been updated accordingly and the two test repositories
      have been merged into one.
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  23. 12 Aug, 2010 1 commit
    • Add support for git index files · 68535125
      The new 'git_index' structure is an in-memory representation
      of a git index on disk; the 'git_index_entry' structures represent
      each one of the file entries on the index.
      
      The following calls for index instantiation have been added:
      
      	git_index_alloc(): instantiate a new index structure
      	git_index_free(): free an existing index
      	git_index_clear(): clear all the entires in an existing file
      
      The following calls for index reading and writing have been added:
      
      	git_index_read(): update the contents of the index structure from
      					  its file on disk.
      
      		Internally implemented through:
      			git_index__parse()
      
      	Index files are stored on disk in network byte order; all integer fields
      	inside them are properly converted to the machine's byte order when
      	loading them in memory. The parsing engine also distinguishes
      	between normal index entries and extended entries with 2 extra bytes
      	of flags.
      
      	The 'TREE' extension for index entries is also loaded into memory:
      	Tree caches stored in Index files are loaded into the
      	'git_index_tree' structure pointed by the 'tree' pointer inside
      	'git_index'.
      
      	'index->tree' points to the root node of the tree cache; the full tree
      	can be traversed through each of the node's 'tree->children'.
      
      	Index files can be written back to disk through:
      
      	git_index_write(): atomic writing of existing index objects
      		backed by internal method git_index__write()
      
      The following calls for entry manipulation have been added:
      
      	git_index_add(): insert an empty entry to the index
      
      	git_index_find(): search an entry by its path name
      
      	git_index__append(): appends a new index entry to the end of the
      						 list, resizing the entries array if required
      
      	New index entries are always inserted at the end of the array; since the
      	index entries must be sorted for it to be internally consistent, the
      	index object is only sorted once, and if required, before accessing the
      	whole entriea array (e.g. before writing to disk, before traversing,
      	etc).
      
      	git_index__remove_pos(): remove an index entry in a specific position
      
      	git_index__sort(): sort the entries in the array by path name
      
      	The entries array is sorted stably and in place using an
      	insertion sort, which ought to be the most efficient approach
      	since the entries array is always mostly-sorted.
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed