Commit Graph

28 Commits

Author SHA1 Message Date
Russell Belfer
634f10f690 Fix incorrect return code in crlf filter
The git_buf_text_gather_stats call returns a boolean indicating if
the file looks like binary data.  That shouldn't be an error; it
should be used to skip CRLF processing though.
2013-09-24 10:11:20 -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
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
nulltoken
6f2003612c clar: Move cl_assert_equal_sz() definition to clar.h 2013-09-12 13:54:33 +02: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
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
d730d3f4f0 Major rename detection changes
After doing further profiling, I found that a lot of time was
being spent attempting to insert hashes into the file hash
signature when using the rolling hash because the rolling hash
approach generates a hash per byte of the file instead of one
per run/line of data.

To optimize this, I decided to convert back to a run-based file
signature algorithm which would be more like core Git.

After changing this, a number of the existing tests started to
fail.  In some cases, this appears to have been because the test
was coded to be too specific to the particular results of the file
similarity metric and in some cases there appear to have been bugs
in the core rename detection code where only by the coincidence
of the file similarity scoring were the expected results being
generated.

This renames all the variables in the core rename detection code
to be more consistent and hopefully easier to follow which made it
a bit easier to reason about the behavior of that code and fix the
problems that I was seeing.  I think it's in better shape now.

There are a couple of tests now that attempt to stress test the
rename detection code and they are quite slow.  Most of the time
is spent setting up the test data on disk and in the index.  When
we roll out performance improvements for index insertion, it
should also speed up these tests I hope.
2013-07-31 16:40:42 -07:00
Russell Belfer
f9775a37aa Add ignore_submodules to diff options
This adds correct support for an equivalent to --ignore-submodules
in diff, where an actual ignore value can be passed to diff to
override the per submodule settings in the configuration.

This required tweaking the constants for ignore values so that
zero would not be used and could represent an unset option to the
diff.  This was an opportunity to move the submodule values into
include/git2/types.h and to rename the poorly named DEFAULT values
for ignore and update constants to RESET instead.

Now the GIT_DIFF_IGNORE_SUBMODULES flag is exactly the same as
setting the ignore_submodules option to GIT_SUBMODULE_IGNORE_ALL
(which is actually a minor change from the old behavior in that
submodules will now be treated as UNMODIFIED deltas instead of
being left out totally - if you set GIT_DIFF_INCLUDE_UNMODIFIED).

This includes tests for the various new settings.
2013-07-10 12:15:03 -07:00
Russell Belfer
1f9e41ee86 Improve ignore handling in git_status_file
The git_status_file API was doing a hack to deal with files that
are inside ignored directories.  The status scan was not reporting
any file in this case, so git_status_file would attempt a final
"stat()" call, and return IGNORED if the file actually existed.

On case-insensitive filesystems where core.ignorecase is set
incorrectly, this magic check can "succeed" and report a file
as ignored when it should actually return ENOTFOUND.

Now that we have the GIT_STATUS_OPT_RECURSE_IGNORED_DIRS, we can
use that flag to make sure that git_status_file() will look into
ignored directories and eliminate the hack completely, so we give
the correct error.
2013-05-10 07:50:53 -07:00
Russell Belfer
1323c6d180 Add cl_repo_set_bool and cleanup tests
This adds a helper function for the cases where you want to
quickly set a single boolean config value for a repository.
This allowed me to remove a lot of code.
2013-03-22 14:27:56 -07:00
Russell Belfer
3ba0136243 Update cl_assert_equal_sz to be nicer
This makes the size_t comparison test nicer (assuming that the
values are actually not using the full length), and converts
some cases that were using it for pointer comparison to use the
macro that is designed for pointer comparison.
2013-03-22 14:23:38 -07:00
Russell Belfer
e9e20c8474 Update cl_git_pass to return more info
This adds a failure reporting function that is called by
cl_git_pass which captures the actual error return code and
the error message if available in the failure report.
2013-01-04 15:23:47 -08:00
nulltoken
f5a0e734bc tests: introduce cl_git_remove_placeholders() 2012-11-17 07:20:07 -08:00
Ben Straub
2ff1a0d0f0 Helpers for local-filesystem remote URLs 2012-11-09 16:59:46 -08:00
Philip Kelley
c08b8a3a73 Update clar and add reliable rename for Win32 2012-10-18 14:50:17 -04:00
Russell Belfer
e9ca852e4d Fix warnings and merge issues on Win64 2012-08-23 09:20:17 -07:00
Russell Belfer
da825c92d9 Make index add/append support core.filemode flag
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).
2012-06-19 14:27:02 -07:00
Russell Belfer
0abd724454 Fix filemode comparison in diffs
File modes were both not being ignored properly on platforms
where they should be ignored, nor be diffed consistently on
platforms where they are supported.

This change adds a number of diff and status filemode change
tests.  This also makes sure that filemode-only changes are
included in the diff output when they occur and that filemode
changes are ignored successfully when core.filemode is false.

There is no code that automatically toggles core.filemode
based on the capabilities of the current platform, so the user
still needs to be careful in their .git/config file.
2012-06-08 12:09:10 -07:00
Ben Straub
e272efcb20 Tests: wrap 'getenv' and friends for Win32 tests. 2012-06-08 11:24:37 -07:00
Carlos Martín Nieto
9b62e40ecd clar helper: don't dereference giterr_last() if it's NULL
It can cause segfaults if the call didn't set an error
2012-05-07 11:29:10 +02:00
Vicent Martí
3fbcac89c4 Remove old and unused error codes 2012-05-02 19:56:38 -07:00
Russell Belfer
1a6e8f8a54 Update clar and remove old helpers
This updates to the latest clar which includes the helpers
`cl_assert_equal_s` and `cl_assert_equal_i`.  Convert the code
over to use those and remove the old libgit2-only helpers.
2012-04-17 10:35:11 -07:00
Russell Belfer
7784bcbbee Refactor git_repository_open with new options
Add a new command `git_repository_open_ext` with extended options
that control how searching for a repository will be done.  The
existing `git_repository_open` and `git_repository_discover` are
reimplemented on top of it.  We may want to change the default
behavior of `git_repository_open` but this commit does not do that.

Improve support for "gitdir" files where the work dir is separate
from the repo and support for the "separate-git-dir" config.  Also,
add support for opening repos created with `git-new-workdir` script
(although I have only confirmed that they can be opened, not that
all functions work correctly).

There are also a few minor changes that came up:

- Fix `git_path_prettify` to allow in-place prettifying.

- Fix `git_path_root` to support backslashes on Win32.  This fix
  should help many repo open/discover scenarios - it is the one
  function called when opening before prettifying the path.

- Tweak `git_config_get_string` to set the "out" pointer to NULL
  if the config value is not found.  Allows some other cleanup.

- Fix a couple places that should have been calling
  `git_repository_config__weakptr` and were not.

- Fix `cl_git_sandbox_init` clar helper to support bare repos.
2012-04-11 12:11:35 -07:00
Russell Belfer
854eccbb2d Clean up GIT_UNUSED macros on all platforms
It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5
did not fix the GIT_USUSED behavior on all platforms.  This commit
walks through and really cleans things up more thoroughly, getting
rid of the unnecessary stuff.

To remove the use of some GIT_UNUSED, I ended up adding a couple
of new iterators for hashtables that allow you to iterator just
over keys or just over values.

In making this change, I found a bug in the clar tests (where we
were doing *count++ but meant to do (*count)++ to increment the
value).  I fixed that but then found the test failing because it
was not really using an empty repo.  So, I took some of the code
that I wrote for iterator testing and moved it to clar_helpers.c,
then made use of that to make it easier to open fixtures on a
per test basis even within a single test file.
2012-03-02 15:51:55 -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
ce49c7a8a9 Add filter tests and fix some bugs
This adds some initial unit tests for file filtering and fixes
some simple bugs in filter application.
2012-03-02 15:09:40 -08:00
Vicent Martí
3fd1520cd4 Rename the Clay test suite to Clar
Clay is the name of a programming language on the makings, and we want
to avoid confusions. Sorry for the huge diff!
2012-01-24 20:35:15 -08:00