Commit Graph

4366 Commits

Author SHA1 Message Date
Russell Belfer
0c46863384 Improved tree iterator internals
This updates the tree iterator internals to be more efficient.

The tree_iterator_entry objects are now kept as pointers that are
allocated from a git_pool, so that we may use git__tsort_r for
sorting (which is better than qsort, given that the tree is
likely mostly ordered already).

Those tree_iterator_entry objects now keep direct pointers to the
data they refer to instead of keeping indirect index values.  This
simplifies a lot of the data structure traversal code.

This also adds bsearch to find the start item position for range-
limited tree iterators, and is more explicit about using
git_path_cmp instead of reimplementing it.  The git_path_cmp
changed a bit to make it easier for tree_iterators to use it (but
it was barely being used previously, so not a big deal).

This adds a git_pool_free_array function that efficiently frees a
list of pool allocated pointers (which the tree_iterator keeps).
Also, added new tests for the git_pool free list functionality
that was not previously being tested (or used).
2013-03-14 13:40:15 -07:00
Vicent Martí
6950dca42e Merge pull request #1411 from arrbee/workdir-iterator-depth-limit-bug
Fix workdir iterator bugs
2013-03-13 15:50:13 -07:00
Russell Belfer
bbb1364671 Fix workdir iterator bugs
This fixes two bugs with the workdir iterator depth check: first
that the depth was not being decremented and second that empty
directories were counting against the depth even though a frame
was not being created for them.

This also fixes a bug with the ENOTFOUND return code for workdir
iterators when you attempt to advance_into an empty directory.
Actually, that works correctly, but it was incorrectly being
propogated into regular advance() calls in some circumstances.

Added new tests for the above that create a huge hierarchy on
the fly and try using the workdir iterator to traverse it.
2013-03-13 14:59:51 -07:00
Vicent Marti
ad003763cc MSVC: What could possibly be the size of a void*? 2013-03-12 20:36:35 +01:00
Vicent Martí
c6d7d877fc Merge pull request #1410 from phkelley/push_sideband
Advertise and support side-band-64k when calling receive-pack
2013-03-12 12:32:12 -07:00
Philip Kelley
f58983246d Style: Reverse lhs and rhs of == comparisons 2013-03-12 15:31:14 -04:00
Philip Kelley
b8c325806f Advertise and support side-band-64k when calling receive-pack 2013-03-12 15:19:32 -04:00
Vicent Martí
1ac10aae1d Merge pull request #1408 from arrbee/refactor-iterators
Refactor iterators
2013-03-12 09:23:53 -07:00
Russell Belfer
62beacd300 Sorting function cleanup and MinGW fix
Clean up some sorting function stuff including fixing qsort_r
on MinGW, common function pointer type for comparison, and basic
insertion sort implementation (which we, regrettably, fall back
on for MinGW).
2013-03-11 16:43:58 -07:00
Vicent Martí
b70bf922a1 Merge pull request #1406 from cpthamilton/local_push
Implemented push on the local transport
2013-03-11 14:35:49 -07:00
abepern
20858f6ea6 Implemented push on the local transport 2013-03-11 17:32:33 -04:00
Russell Belfer
a5eea2d7b7 Stabilize order for equiv tree iterator entries
Given a group of case-insensitively equivalent tree iterator
entries, this ensures that the case-sensitively first trees will
be used as the representative items.  I.e. if you have conflicting
entries "A/B/x", "a/b/x", and "A/b/x", this change ensures that
the earliest entry "A/B/x" will be returned.  The actual choice
is not that important, but it is nice to have it stable and to
have it been either the first or last item, as opposed to a
random item from within the equivalent span.
2013-03-11 11:31:50 -07:00
Edward Thomson
eef7e80e68 Merge pull request #1407 from ethomson/tform_small_files
handle small files in similarity metrics
2013-03-11 10:57:19 -07:00
Edward Thomson
aa408cbfc4 handle small files in similarity metrics 2013-03-11 12:47:01 -05:00
Russell Belfer
aec4f6633c Fix tree iterator advance using wrong name compare
Tree iterator advance was moving forward without taking the
filemode of the entries into account, equating "a" and "a/".
This makes the tree entry comparison code more easily reusable
and fixes the problem.
2013-03-11 10:37:12 -07:00
Russell Belfer
92028ea585 Fix tree iterator path for tree issue + cleanups
This fixes an off by one error for generating full paths for
tree entries in tree iterators when INCLUDE_TREES is set.  Also,
contains a bunch of small code cleanups with a couple of small
utility functions and macro changes to eliminate redundant code.
2013-03-11 09:53:49 -07:00
Russell Belfer
61c7b61e6f Use correct case path in icase tree iterator
If there are case-ambiguities in the path of a case insensitive
tree iterator, it will now rewrite the entire path when it gives
the path name to an entry, so a tree with "A/b/C/d.txt" and
"a/B/c/E.txt" will give the true full paths (instead of case-
folding them both to "A/B/C/d.txt" or "a/b/c/E.txt" or something
like that.
2013-03-10 22:38:53 -07:00
Russell Belfer
a03beb7ba6 Add tests for case insensitive tree iterator
This adds a test case for ci tree iteration when there is a name
conflict.  This points out a behavior quirk in the current version
that I'd like to fix - namely, all tree entries get mapped to one
version of the case pattern in the ci code - i.e. even if you have
A/1.txt and a/2.txt, both will be reported as a/1.txt and a/2.txt
because we only copy the name of a file at a given frame once. It
would be nice to fix this, but I'm worried about how complex that
is if you get a/B/c/1.txt and A/b/C/2.txt.  It may require a walk
up the frames whenever you advance to the next item in a blended
equivalence class.
2013-03-10 21:04:35 -07:00
Carlos Martín Nieto
d768f9add9 travis: join-less notifications 2013-03-10 21:37:09 +01:00
Russell Belfer
57e765b2e8 Merge pull request #1175 from carlosmn/diff-0-ctx
Can't perform diff with no context lines
2013-03-09 08:09:17 -08:00
Carlos Martín Nieto
1aa5318a9e diff: allow asking for diffs with no context
Previously, 0 meant default. This is problematic, as asking for 0
context lines is a valid thing to do.

Change GIT_DIFF_OPTIONS_INIT to default to three and stop treating 0
as a magic value. In case no options are provided, make sure the
options in the diff object default to 3.
2013-03-09 16:04:34 +01:00
Russell Belfer
e40f1c2d23 Make tree iterator handle icase equivalence
There is a serious bug in the previous tree iterator implementation.
If case insensitivity resulted in member elements being equivalent
to one another, and those member elements were trees, then the
children of the colliding elements would be processed in sequence
instead of in a single flattened list.  This meant that the tree
iterator was not truly acting like a case-insensitive list.

This completely reworks the tree iterator to manage lists with
case insensitive equivalence classes and advance through the items
in a unified manner in a single sorted frame.

It is possible that at a future date we might want to update this
to separate the case insensitive and case sensitive tree iterators
so that the case sensitive one could be a minimal amount of code
and the insensitive one would always know what it needed to do
without checking flags.

But there would be so much shared code between the two, that I'm
not sure it that's a win.  For now, this gets what we need.

More tests are needed, though.
2013-03-08 16:39:57 -08:00
Carlos Martín Nieto
0887b580bf Use C99 stdio in mingw-w64
MinGW >= 3.14 does this automatically, but mingw-64 wants us to define
it.
2013-03-08 15:30:18 +01:00
Vicent Martí
92ebbe99c9 Merge pull request #1399 from nathan-osman/development
Add SONAME build option to facilitate building for Android.
2013-03-07 12:06:18 -08:00
Vicent Martí
6f83a78133 Merge pull request #1403 from ethomson/tracing
Optional tracing back to consumers
2013-03-07 11:14:03 -08:00
Edward Thomson
b5ec5430a8 optional tracing 2013-03-07 12:42:33 -06:00
Vicent Marti
33abaad809 refs: Dude, you're OUT. 2013-03-07 18:58:34 +01:00
Vicent Marti
cdaef180ce Merge remote-tracking branch 'ethomson/immutable_refs' into development 2013-03-07 18:44:10 +01:00
Edward Thomson
d00d54645d immutable references and a pluggable ref database 2013-03-07 11:01:52 -06:00
Vicent Martí
6a9ef01237 Merge pull request #1401 from carlosmn/leading-slash
refs: explicitly catch leading slashes
2013-03-07 07:47:20 -08:00
Carlos Martín Nieto
bb45c57f94 refs: explicitly catch leading slashes
It's somewhat common to try to write "/refs/tags/something". There is
no easy way to catch it during the main body of the function, as there
is no way to distinguish whether it's a leading slash or a double
slash somewhere in the middle.

Catch this at the beginning so we don't trigger the assert in
is_all_caps_and_underscore().
2013-03-07 16:38:44 +01:00
Nathan Osman
e7da9acdcd Added build option SONAME to control whether VERSION and SOVERSION were set for the git2 target, as some platforms require that this NOT be set. 2013-03-06 17:51:38 -08:00
Russell Belfer
9bea03ce77 Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flags
This standardizes iterator behavior across all three iterators
(index, tree, and working directory).  Previously the working
directory iterator behaved differently from the other two.

Each iterator can now operate in one of three modes:

1. *No tree results, auto expand trees* means that only non-
   tree items will be returned and when a tree/directory is
   encountered, we will automatically descend into it.
2. *Tree results, auto expand trees* means that results will
   be given for every item found, including trees, but you
   only need to call normal git_iterator_advance to yield
   every item (i.e. trees returned with pre-order iteration).
3. *Tree results, no auto expand* means that calling the
   normal git_iterator_advance when looking at a tree will
   not descend into the tree, but will skip over it to the
   next entry in the parent.

Previously, behavior 1 was the only option for index and tree
iterators, and behavior 3 was the only option for workdir.

The main public API implications of this are that the
`git_iterator_advance_into()` call is now valid for all
iterators, not just working directory iterators, and all the
existing uses of working directory iterators explicitly use
the GIT_ITERATOR_DONT_AUTOEXPAND (for now).

Interestingly, the majority of the implementation was in the
index iterator, since there are no tree entries there and now
have to fake them.  The tree and working directory iterators
only required small modifications.
2013-03-06 16:52:01 -08:00
Russell Belfer
cc216a01ee Retire spoolandsort iterator
Since the case sensitivity is moved into the respective iterators,
this removes the spoolandsort iterator code.
2013-03-06 16:52:01 -08:00
Russell Belfer
169dc61607 Make iterator APIs consistent with standards
The iterator APIs are not currently consistent with the parameter
ordering of the rest of the codebase.  This rearranges the order
of parameters, simplifies the naming of a number of functions, and
makes somewhat better use of macros internally to clean up the
iterator code.

This also expands the test coverage of iterator functionality,
making sure that case sensitive range-limited iteration works
correctly.
2013-03-06 16:52:01 -08:00
Russell Belfer
ed4f95e5d9 Add const to some buffer functions 2013-03-06 16:44:53 -08:00
Russell Belfer
9952f24e6c No longer need clar_main.c 2013-03-06 16:02:26 -08:00
Russell Belfer
1b405a232f Merge pull request #1396 from cholin/features/note-iterator
[RFC] basic note iterator implementation
2013-03-06 13:58:21 -08:00
Nico von Geyso
aa518c709c added missing free for git_note in clar tests 2013-03-06 22:51:20 +01:00
Nico von Geyso
f7b1850215 fixed minor issues with new note iterator
* fixed style issues
* use new iterator functions for git_note_foreach()
2013-03-06 22:36:19 +01:00
Philip Kelley
69c28b75df MSVC: Define NDEBUG to disable asserts in release builds 2013-03-06 13:22:50 -05:00
Nico von Geyso
1a90dcf64e use git_note_iterator type instead of non-public git_iterator one 2013-03-06 19:07:56 +01:00
Nico von Geyso
6edb427b76 basic note iterator implementation
* git_note_iterator_new() - create a new note iterator
* git_note_next() - retrieves the next item of the iterator
2013-03-06 17:01:33 +01:00
Vicent Martí
d1bcc1a874 Merge pull request #1392 from ethomson/push_test_fix
remote push test fix
2013-03-06 03:05:10 -08:00
Edward Thomson
4cc326e9dd remote push test fix 2013-03-05 22:45:26 -06:00
Vicent Martí
b72f5d4038 Merge pull request #1369 from arrbee/repo-init-template-hooks
More tests (and fixes) for initializing repo from template
2013-03-05 15:35:28 -08:00
Carlos Martín Nieto
3d74702eec Make sure docurium can see git_packbuilder_foreach 2013-03-05 23:50:43 +01:00
Vicent Martí
b8daa9e0fc Merge pull request #1380 from phkelley/index_icase
Disable ignore_case when writing the index to a tree
2013-03-04 16:19:38 -08:00
Vicent Martí
f6d96409a8 Merge pull request #1390 from ethomson/reuc_clear
clear REUC on checkout
2013-03-04 16:13:31 -08:00
Edward Thomson
5bddabcca5 clear REUC on checkout 2013-03-04 18:10:57 -06:00