Commit Graph

27 Commits

Author SHA1 Message Date
Edward Thomson
f45ec1a076 index refactoring 2012-10-29 20:04:21 -05:00
Philip Kelley
ec40b7f99f Support for core.ignorecase 2012-09-17 15:42:41 -04:00
nulltoken
b8457baae2 portability: Improve x86/amd64 compatibility 2012-07-24 16:10:12 +02:00
Russell Belfer
41a82592ef Ranged iterators and rewritten git_status_file
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.
2012-05-15 14:34:15 -07:00
Russell Belfer
44ef8b1b30 Fix warnings on 64-bit windows builds
This fixes all the warnings on win64 except those in deps, which
come from the regex code.
2012-04-17 10:47:39 -07:00
Russell Belfer
ae9e29fde7 Migrating diff to new error handling
Ended up migrating a bunch of upstream functions as well
including vector, attr_file, and odb in order to get this
to work right.
2012-03-06 16:27:13 -08:00
Russell Belfer
74fa4bfae3 Update diff to use iterators
This is a major reorganization of the diff code.  This changes
the diff functions to use the iterators for traversing the
content.  This allowed a lot of code to be simplified.  Also,
this moved the functions relating to outputting a diff into a
new file (diff_output.c).

This includes a number of other changes - adding utility
functions, extending iterators, etc. plus more tests for the
diff code.  This also takes the example diff.c program much
further in terms of emulating git-diff command line options.
2012-03-02 15:49:29 -08:00
Russell Belfer
0534641dfe Fix iterators based on pull request feedback
This update addresses all of the feedback in pull request #570.

The biggest change was to create actual linked list stacks for
storing the tree and workdir iterator state.  This cleaned up
the code a ton.  Additionally, all of the static functions had
their 'git_' prefix removed, and a lot of other unnecessary
changes were removed from the original patch.
2012-02-22 15:15:35 -08:00
Russell Belfer
b6c93aef42 Uniform iterators for trees, index, and workdir
This create a new git_iterator type of object that provides a
uniform interface for iterating over the index, an arbitrary
tree, or the working directory of a repository.

As part of this, git ignore support was extended to support
push and pop of directory-based ignore files as the working
directory is being traversed (so the array of ignores does
not have to be recreated at each directory during traveral).

There are a number of other small utility functions in buffer,
path, vector, and fileops that are included in this patch
that made the iterator implementation cleaner.
2012-02-21 14:46:24 -08:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +01:00
Russell Belfer
bd370b14fe Improved gitattributes macro implementation
This updates to implementation of gitattribute macros to be much more
similar to core git (albeit not 100%) and to handle expansion of
macros within macros, etc.  It also cleans up the refcounting usage
with macros to be much cleaner.

Also, this adds a new vector function `git_vector_insert_sorted()`
which allows you to maintain a sorted list as you go.  In order to
write that function, this changes the function `git__bsearch()` to
take a somewhat different set of parameters, although the core
functionality is still the same.
2011-12-30 15:00:14 -08:00
Russell Belfer
ee1f0b1aed Add APIs for git attributes
This adds APIs for querying git attributes.  In addition to
the new API in include/git2/attr.h, most of the action is in
src/attr_file.[hc] which contains utilities for dealing with
a single attributes file, and src/attr.[hc] which contains
the implementation of the APIs that merge all applicable
attributes files.
2011-12-20 16:32:58 -08:00
Vicent Marti
3286c408ec global: Properly use git__ memory wrappers
Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
2011-10-28 19:02:36 -07:00
Vicent Marti
bb742ede3d Cleanup legal data
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.
2011-09-19 01:54:32 +03:00
Vicent Marti
de18f27668 vector: Timsort all of the things
Drop the GLibc implementation of Merge Sort and replace it with Timsort.

The algorithm has been tuned to work on arrays of pointers (void **),
so there's no longer a need to abstract the byte-width of each element
in the array.

All the comparison callbacks now take pointers-to-elements, not
pointers-to-pointers, so there's now one less level of dereferencing.

E.g.

	 int index_cmp(const void *a, const void *b)
	 {
	-	const git_index_entry *entry_a = *(const git_index_entry **)(a);
	+	const git_index_entry *entry_a = (const git_index_entry *)(a);

The result is up to a 40% speed-up when sorting vectors. Memory usage
remains lineal.

A new `bsearch` implementation has been added, whose callback also
supplies pointer-to-elements, to uniform the Vector API again.
2011-07-07 02:54:07 +02:00
Kirill A. Shutemov
476c42acc5 vector: implement git_vector_uniq()
The routine remove duplictes from the vector. Only the last added element
of elements with equal keys remains in the vector.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-05 17:52:39 +03:00
Kirill A. Shutemov
0b0a6b115d vector, index: use git__msort() for vector sorting
Index operation use git_vector_sort() to sort index entries. Since index
support adding duplicates (two or more entries with the same path), it's
important to preserve order of elements. Preserving order of elements
allows to make decisions based on order. For example it's possible to
implement function witch removes all duplicates except last added.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-05 17:52:39 +03:00
Kirill A. Shutemov
932d1baf29 cleanup: remove trailing spaces
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-01 18:02:56 +02:00
schu
86f5fa7810 Move vector.c to the new error handling
Remove "redundant" check for v->_cmp in wrapper function
git_vector_bsearch().

Signed-off-by: schu <schu-github@schulog.org>
2011-05-11 14:00:53 +02:00
Vicent Marti
3c41c635fb Fix compilation in MSVC
MSVC cannot substract void pointers. Go figure.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 21:58:37 +02:00
Vicent Marti
48c27f86bb Implement reference counting for git_objects
All `git_object` instances looked up from the repository are reference
counted. User is expected to use the new `git_object_close` when an
object is no longer needed to force freeing it.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:52 +02:00
Vicent Marti
86d7e1ca6f Fix searching in git_vector
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>
2011-03-03 20:23:52 +02:00
Vicent Marti
da7c3c71c0 Fix warnings in vector.c
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:49 +02:00
Vicent Marti
86194b2433 Split packed from unpacked references
These two reference types are now stored separately to eventually allow
the removal/renaming of loose references and rewriting of the refs
packfile.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:49 +02:00
Alex Budovski
a17777d161 Fixed two buffer handling errors in vector.c
- remove() would read one-past array bounds.
- resize() would fail if the initial size was 1, because it multiplied by 1.75
  and truncated the resulting value. The buffer would always remain at size 1,
  but elements would repeatedly be appended (via insert()) causing a crash.
2011-01-08 22:17:52 +02:00
Vicent Marti
a44fc1d413 Fix type-conversion warnings
The types in the git_index_entry struct are now system-defaults, and get
truncated to uint32_t's when written back on the index.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-12-06 23:36:21 +02:00
Vicent Marti
c4034e63f3 Refactor all 'vector' functions into common code
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>
2010-12-02 04:31:54 +02:00