1. 23 Apr, 2011 1 commit
    • index: Refactor add/replace methods · f7a5058a
      Removed the optional `replace` argument, we now have 4 add methods:
      
      	`git_index_add`: add or update from path
      	`git_index_add2`: add or update from struct
      	`git_index_append`: add without replacing from path
      	`git_index_append2`: add without replacing from struct
      
      Yes, this breaks the bindings.
      Vicent Marti committed
  2. 21 Apr, 2011 1 commit
  3. 09 Apr, 2011 1 commit
  4. 07 Apr, 2011 1 commit
    • index.c: Correctly check whether index contains extended entries · fd279b26
      Although write_index() supports writing extended header versions for
      index, this was never done as there was no check for extended index
      entries.
      
      Introduce function is_index_extended() that checks whether an index
      contains extended entries and check whether an index is extended before
      writing it to disk, adjusting its version number if necessary.
      Jakob Pfender committed
  5. 28 Mar, 2011 1 commit
  6. 24 Mar, 2011 1 commit
    • index.c: Read index after initialization · 3bdc0d4c
      The current behaviour of git_index_open{bare,inrepo}() is unexpected.
      When an index is opened, an in-memory index object is created that is
      linked to the index discovered by git_repository_open(). However, this
      index object is empty, as the on-disk index is not read. To fully open
      the on-disk index file, git_index_read() has to be called. This leads to
      confusing behaviour. Consider the following code:
      
      	git_index *idx;
      	git_index_open_inrepo(&idx, repo);
      	git_index_write(idx);
      
      You would expect this to have no effect, as the index is never
      ostensibly manipulated. However, what actually happens is that the index
      entries are removed from the on-disk index because the empty in-memory
      index object created by open_inrepo() is written back to the disk.
      
      This patch reads the index after opening it.
      Jakob Pfender committed
  7. 22 Mar, 2011 1 commit
  8. 20 Mar, 2011 1 commit
    • I broke your bindings · 72a3fe42
      Hey. Apologies in advance -- I broke your bindings.
      
      This is a major commit that includes a long-overdue redesign of the
      whole object-database structure. This is expected to be the last major
      external API redesign of the library until the first non-alpha release.
      
      Please get your bindings up to date with these changes. They will be
      included in the next minor release. Sorry again!
      
      Major features include:
      
      	- Real caching and refcounting on parsed objects
      	- Real caching and refcounting on objects read from the ODB
      	- Streaming writes & reads from the ODB
      	- Single-method writes for all object types
      	- The external API is now partially thread-safe
      
      The speed increases are significant in all aspects, specially when
      reading an object several times from the ODB (revwalking) and when
      writing big objects to the ODB.
      
      Here's a full changelog for the external API:
      
      blob.h
      ------
      
      	- Remove `git_blob_new`
      	- Remove `git_blob_set_rawcontent`
      	- Remove `git_blob_set_rawcontent_fromfile`
      	- Rename `git_blob_writefile` -> `git_blob_create_fromfile`
      	- Change `git_blob_create_fromfile`:
      		The `path` argument is now relative to the repository's working dir
      	- Add `git_blob_create_frombuffer`
      
      commit.h
      --------
      
      	- Remove `git_commit_new`
      	- Remove `git_commit_add_parent`
      	- Remove `git_commit_set_message`
      	- Remove `git_commit_set_committer`
      	- Remove `git_commit_set_author`
      	- Remove `git_commit_set_tree`
      
      	- Add `git_commit_create`
      	- Add `git_commit_create_v`
      	- Add `git_commit_create_o`
      	- Add `git_commit_create_ov`
      
      tag.h
      -----
      
      	- Remove `git_tag_new`
      	- Remove `git_tag_set_target`
      	- Remove `git_tag_set_name`
      	- Remove `git_tag_set_tagger`
      	- Remove `git_tag_set_message`
      
      	- Add `git_tag_create`
      	- Add `git_tag_create_o`
      
      tree.h
      ------
      
      	- Change `git_tree_entry_2object`:
      		New signature is `(git_object **object_out, git_repository *repo, git_tree_entry *entry)`
      
      	- Remove `git_tree_new`
      	- Remove `git_tree_add_entry`
      	- Remove `git_tree_remove_entry_byindex`
      	- Remove `git_tree_remove_entry_byname`
      	- Remove `git_tree_clearentries`
      	- Remove `git_tree_entry_set_id`
      	- Remove `git_tree_entry_set_name`
      	- Remove `git_tree_entry_set_attributes`
      
      object.h
      ------------
      
      	- Remove `git_object_new
      	- Remove `git_object_write`
      
      	- Change `git_object_close`:
      		This method is now *mandatory*. Not closing an object causes a
      		memory leak.
      
      odb.h
      -----
      
      	- Remove type `git_rawobj`
      	- Remove `git_rawobj_close`
      	- Rename `git_rawobj_hash` -> `git_odb_hash`
      	- Change `git_odb_hash`:
      		New signature is `(git_oid *id, const void *data, size_t len, git_otype type)`
      
      	- Add type `git_odb_object`
      	- Add `git_odb_object_close`
      
      	- Change `git_odb_read`:
      		New signature is `(git_odb_object **out, git_odb *db, const git_oid *id)`
      	- Change `git_odb_read_header`:
      		New signature is `(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)`
      	- Remove `git_odb_write`
      	- Add `git_odb_open_wstream`
      	- Add `git_odb_open_rstream`
      
      odb_backend.h
      -------------
      
      	- Change type `git_odb_backend`:
      		New internal signatures are as follows
      
      			int (* read)(void **, size_t *, git_otype *, struct git_odb_backend *, const git_oid *)
      			int (* read_header)(size_t *, git_otype *, struct git_odb_backend *, const git_oid *)
      			int (* writestream)(struct git_odb_stream **, struct git_odb_backend *, size_t, git_otype)
      			int (* readstream)( struct git_odb_stream **, struct git_odb_backend *, const git_oid *)
      
      	- Add type `git_odb_stream`
      	- Add enum `git_odb_streammode`
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  9. 03 Mar, 2011 2 commits
    • Do not free the index if it's owned by a repository · 971c90be
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
    • 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
  10. 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
  11. 18 Feb, 2011 1 commit
    • Disable threaded index writing by default · e822508a
      The interlocking on the write threads was not being done properly (index
      entries were sometimes written out of order). With proper interlocking,
      the threaded write is only marginally faster on big index files, and
      slower on the smaller ones because of the overhead when creating
      threads.
      
      The threaded index writing has been temporarily disabled; after more
      accurate benchmarks, if might be possible to enable it again only when
      writing very large index files (> 1000 entries).
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  12. 17 Feb, 2011 2 commits
    • Fix type truncation in index entries · 084c1935
      64-bit types stored in memory have to be truncated into 32 bits when
      writing to disk. Was causing warnings in MSVC.
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
    • 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
  13. 09 Feb, 2011 1 commit
    • Use the new git__joinpath to build paths in methods · 995f9c34
      The `git__joinpath` function has been changed to use a statically
      allocated buffer; we assume the buffer to be 4096 bytes, because fuck
      you.
      
      The new method also supports an arbritrary number of paths to join,
      which may come in handy in the future.
      
      Some methods which were manually joining paths with `strcpy` now use the
      new function, namely those in `index.c` and `refs.c`.
      
      Based on Emeric Fermas' original patch, which was using the old
      `git__joinpath` because I'm stupid. Thanks!
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  14. 11 Jan, 2011 1 commit
  15. 10 Jan, 2011 1 commit
    • Fix Windows build with forced bit truncation. · 0a3bcad0
      Windows uses a 64 bit time_t by default and assigning to unsigned int causes a
      64 -> 32 bit truncation warning. This change forces the truncation,
      acknowledging the implications detailed in the file comments. Also, blobs are
      limited to 32 bit file sizes for the same reason (on all platforms).
      Alex Budovski committed
  16. 06 Dec, 2010 2 commits
  17. 05 Dec, 2010 1 commit
  18. 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
  19. 29 Nov, 2010 1 commit
  20. 17 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. 11 Nov, 2010 1 commit
  23. 06 Nov, 2010 1 commit
    • Make the Index API public · 3f43678e
      Several private methods of the Index API are now public, including the
      methods to remove, get and add index entries.
      
      All the methods only take an integer value for the position of the entry
      to get/remove. To get or remove entries based on their path names, look
      them up first using the git_index_find method.
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  24. 05 Nov, 2010 1 commit
    • Improve error handling · 1795f879
      All initialization functions now return error codes instead of pointers.
      Error codes are now properly propagated on most functions. Several new
      and more specific error codes have been added in common.h
      
      Signed-off-by: Vicent Marti <tanoku@gmail.com>
      Vicent Marti committed
  25. 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
  26. 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