Commit Graph

1440 Commits

Author SHA1 Message Date
Carlos Martín Nieto
07fb67f90e merge: reverse array and length parameter order
Make it pair up with the one for commits. This fixes #1691.
2013-09-22 05:59:35 +02:00
Ben Straub
32b247d5e7 Suppress noise from running Valgrind on OSX 10.8 2013-09-19 10:30:43 -07:00
Russell Belfer
f60ed4e649 Update clar and recreate cl_assert_equal_sz
This updates clar to the version without cl_assert_equal_sz and
then adds a new version of that macro the clar_libgit2.h.  The new
version works around a strange issue that seemed to be arising on
release builds with VS 10 64-bit builds.
2013-09-17 09:31:46 -07:00
Russell Belfer
eefc32d549 Bug fixes and cleanups
This contains a few bug fixes and some header and API cleanups.

The main API change is that filters should now use GIT_PASSTHROUGH
to indicate that they wish to skip processing a file instead of
GIT_ENOTFOUND.

The bug fixes include a possible out-of-range buffer access in
the ident filter, a filter ordering problem I introduced into the
custom filter tests on Windows, and a filter buf NUL termination
issue that was coming up on Linux.
2013-09-17 09:31:46 -07:00
Russell Belfer
eab3746b30 More filtering tests including order
This adds more tests of filters, including the ident filter when
mixed with custom filters.  I was able to combine with the reverse
filter and demonstrate that the order of filter application with
the default priority constants matches the order of core Git.

Also, this fixes two issues in the ident filter: preventing ident
expansion on binary files and avoiding a NULL dereference when
dollar sign characters are found without Id.
2013-09-17 09:31:46 -07:00
Russell Belfer
37f9e40939 Some tests with ident and crlf filters
Fixed the filter order to match core Git, too.

This test demonstrates an interesting behavior of core Git (which
is totally reasonable and which libgit2 matches, although mostly
by coincidence).  If you use the ident filter and commit a file
with a garbage ident in it, like '$Id: this is just garbage$' and
then immediately do a 'git checkout-index' with the new file, Git
will not consider the file out of date and will not overwrite the
file with an updated $Id$.  Libgit2 has the same behavior.  If you
remove the file and then do a checkout-index, it will be replaced
with a filtered version that has injected the OID correctly.
2013-09-17 09:31:46 -07:00
Russell Belfer
155fa2342d Add clar helper to create new commit from index
There were a lot of places in the test code base that were creating
a commit from the index on the current branch.  This just adds a
helper to handle that case pretty easily.  There was only one test
where this change ended up tweaking the test data, so pretty easy
and mostly just a cleanup.
2013-09-17 09:31:46 -07:00
Russell Belfer
13f36ffb9e Add clar helpers for testing file equality
These are a couple of new clar helpers for testing that a file
has expected contents that I extracted from the checkout code.

Actually wrote this as part of an abandoned earlier attempt at a
new filters API, but it will be useful now for some of the tests
I'm going to write.
2013-09-17 09:31:46 -07:00
Russell Belfer
fa9cc14880 Fix cleanup issues with new tests 2013-09-17 09:31:46 -07:00
Russell Belfer
8427757f78 Fixing up some win32 issues with autocrlf 2013-09-17 09:31:46 -07:00
Russell Belfer
ad7417d7a1 Make filter tests somewhat more robust
The global and system config could interfere with the filter
tests by imposing CRLF filtering where it was not anticipated.
This better isolates the tests from the system settings.
2013-09-17 09:31:45 -07:00
Russell Belfer
d5b1866cc3 Rearrange clar submodule cleanup code 2013-09-17 09:31:45 -07:00
Russell Belfer
b47349b8dc Port tests from PR 1683
This ports over some of the tests from
    https://github.com/libgit2/libgit2/pull/1683
by @yorah and @ethomson
2013-09-17 09:31:45 -07:00
Russell Belfer
a9f51e430f Merge git_buf and git_buffer
This makes the git_buf struct that was used internally into an
externally available structure and eliminates the git_buffer.

As part of that, some of the special cases that arose with the
externally used git_buffer were blended into the git_buf, such as
being careful about git_buf objects that may have a NULL ptr and
allowing for bufs with a valid ptr and size but zero asize as a
way of referring to externally owned data.
2013-09-17 09:31:45 -07:00
Russell Belfer
4b11f25a4f Add ident filter
This adds the ident filter (that knows how to replace $Id$) and
tweaks the filter APIs and code so that git_filter_source objects
actually have the updated OID of the object being filtered when
it is a known value.
2013-09-17 09:31:45 -07:00
Russell Belfer
40cb40fab9 Add functions to manipulate filter lists
Extend the git2/sys/filter API with functions to look up a filter
and add it manually to a filter list.  This requires some trickery
because the regular attribute lookups and checks are bypassed when
this happens, but in the right hands, it will allow a user to have
granular control over applying filters.
2013-09-17 09:31:45 -07:00
Russell Belfer
2a7d224f99 Extend public filter api with filter lists
This moves the git_filter_list into the public API so that users
can create, apply, and dispose of filter lists.  This allows more
granular application of filters to user data outside of libgit2
internals.

This also converts all the internal usage of filters to the public
APIs along with a few small tweaks to make it easier to use the
public git_buffer stuff alongside the internal git_buf.
2013-09-17 09:31:44 -07:00
Russell Belfer
974774c7b0 Add attributes to filters and fix registry
The filter registry as implemented was too primitive to actually
work once multiple filters were coming into play.  This expands
the implementation of the registry to handle multiple prioritized
filters correctly.

Additionally, this adds an "attributes" field to a filter that
makes it really really easy to implement filters that are based
on one or more attribute values.  The lookup and even simple value
checking can all happen automatically without custom filter code.

Lastly, with the registry improvements, this fills out the filter
lifecycle callbacks, with initialize and shutdown callbacks that
will be called before the filter is first used and after it is
last invoked.  This allows for system-wide initialization and
cleanup by the filter.
2013-09-17 09:31:44 -07:00
Russell Belfer
85d5481206 Create public filter object and use it
This creates include/sys/filter.h with a basic definition of a
git_filter and then converts the internal code to use it.  There
are related internal objects (git_filter_list) that we will want
to publish at some point, but this is a first step.
2013-09-17 09:30:06 -07:00
Russell Belfer
0cf77103b2 Start of filter API + git_blob_filtered_content
This begins the process of exposing git_filter objects to the
public API.  This includes:

* new public type and API for `git_buffer` through which an
  allocated buffer can be passed to the user
* new API `git_blob_filtered_content`
* make the git_filter type and GIT_FILTER_TO_... constants public
2013-09-17 09:30:06 -07:00
Vicent Martí
4581f9d8ab Merge pull request #1833 from libgit2/cmn/config-include
Support config includes
2013-09-17 08:09:57 -07:00
Carlos Martín Nieto
605da51a2c No such thing as an orphan branch
Unfortunately git-core uses the term "unborn branch" and "orphan
branch" interchangeably. However, "orphan" is only really there for
the checkout command, which has the `--orphan` option so it doesn't
actually create the branch.

Branches never have parents, so the distinction of a branch with no
parents is odd to begin with. Crucially, the error messages deal with
unborn branches, so let's use that.
2013-09-17 09:50:30 +02:00
Russell Belfer
e580afd863 Add tests for git_tree_walk
This tests the fixes for issues from #1849
2013-09-13 14:33:26 -07:00
nulltoken
6f2003612c clar: Move cl_assert_equal_sz() definition to clar.h 2013-09-12 13:54:33 +02:00
nulltoken
273ddc54f5 clar: Fix clar__assert_equal error message formating 2013-09-12 13:54:22 +02:00
Russell Belfer
6c38e60a00 Merge pull request #1838 from libgit2/cmn/first-parent
revwalk: allow simplifying by first-parent
2013-09-10 16:55:58 -07:00
nulltoken
209f9b67c4 odb: Teach loose backend to return EAMBIGUOUS 2013-09-10 22:36:13 +02:00
Carlos Martín Nieto
15f7b9b8d9 revwalk: allow simplifying by first-parent
When enabled, only the first parent of each commit will be queued,
enabling a simple way of using first-parent simplification.
2013-09-09 20:31:14 +02:00
nulltoken
031f3f8028 odb: Error when streaming in too [few|many] bytes 2013-09-07 23:00:20 +02:00
Carlos Martín Nieto
53ea051371 config: handle realloc issues from larger depths
As the include depth increases, the chance of a realloc
increases. This means that whenever we run git_array_alloc() or call
config_parse(), we need to remember what our reader's index is so we
can look it up again.
2013-09-07 20:51:26 +02:00
Carlos Martín Nieto
73fc5e01c2 config: fix variable overriding
When two or more variables of the same name exist and the user asks
for a scalar, we must return the latest value assign to it.
2013-09-07 20:51:26 +02:00
Carlos Martín Nieto
a9fb79896e config: refresh included files
We need to refresh the variables from the included files if they are
changed, so loop over all included files and re-parse the files if any
of them has changed.
2013-09-07 20:51:26 +02:00
Carlos Martín Nieto
d8d25acb9a config: add support for include directives
Relative, absolute and home-relative paths are supported. The
recursion limit it set at 10, just like in git.
2013-09-07 20:51:26 +02:00
Vicent Martí
ef6389ad50 Merge pull request #1836 from libgit2/ntk/fix/leaks
Fix memory leaks
2013-09-07 09:18:56 -07:00
nulltoken
e839efbe24 tests: Fix memory leaks 2013-09-07 17:51:24 +02:00
nulltoken
a8d67afe42 revparse: Prevent unnecessary odb backend calls 2013-09-07 17:48:05 +02:00
nulltoken
4047950f30 odb: Prevent stream_finalize_write() from overwriting
Now that #1785 is merged, git_odb_stream_finalize_write() calculates the object id before invoking the odb backend.

This commit gives a chance to the backend to check if it already knows this object.
2013-09-06 22:47:28 +02:00
nulltoken
ae4a486605 blob: Slightly enforce a create_fromchunks() test 2013-09-06 22:21:37 +02:00
Russell Belfer
a7fcc44dcf Better macro name for is-exec-bit-set test 2013-09-05 16:14:32 -07:00
Russell Belfer
af22dabb43 GIT_MODE_TYPE should exclude setgid bits
The GIT_MODE_TYPE macro was looking at all bits above the
permissions, but it should really just look at the top bits so
that it will give the right results for a setgid or setuid entry.

Since we're now using these macros in the tests, this was causing
a test failure on platforms that don't support setgid.
2013-09-05 12:01:17 -07:00
Russell Belfer
c97d407d9c Fix tests of file modes
This fixes an issue checking file modes in the tests that
initialize a repo from a template directory when a symlink is
used in the template.  Also, this updates some other places where
we are examining file modes to use the new macros.
2013-09-05 11:45:29 -07:00
Russell Belfer
27061b151a Fix some newer GCC compiler warnings 2013-09-05 10:25:16 -07:00
Russell Belfer
9ce4f7da4a Fix tests to use core.filemode correctly
Some windows tests were failing
2013-09-04 16:41:34 -07:00
Russell Belfer
2a54c7f447 _umask is function name on Windows 2013-09-04 16:24:36 -07:00
Russell Belfer
abfed59c27 Clean up one other mode_t assertion 2013-09-04 16:23:00 -07:00
Russell Belfer
780f3e540f Make tests take umask into account
It seems that libgit2 is correctly applying the umask when
initializing a repository from a template and when creating new
directories during checkout, but the test suite is not accounting
for possible variations due to the umask.  This updates that so
that the test suite will work regardless of the umask.
2013-09-04 16:23:00 -07:00
Russell Belfer
cf94024c58 Update clar 2013-09-04 16:23:00 -07:00
Ben Straub
61d57b7a21 Test pushing to remotes with "file:///" urls 2013-09-04 14:27:59 -07:00
Vicent Martí
e98535923b Merge pull request #1817 from libgit2/ntk/fix/backend/honor_refresh_capabilities
Of backends and refreshers...
2013-09-04 06:20:36 -07:00
Russell Belfer
cae5293854 Fix resolving relative windows network paths 2013-09-03 14:00:27 -07:00