Commit Graph

1970 Commits

Author SHA1 Message Date
Edward Thomson
98f5387233 Merge pull request #4016 from novalis/submodule-optimization
Submodule optimization
2017-01-21 18:57:28 +00:00
Edward Thomson
52949c806b Merge branch 'pr/4060' 2017-01-21 18:30:12 +00:00
Brock Peabody
4d99c4cfc6 Allow for caching of submodules.
Added `git_repository_submodule_cache_all` to initialze a cache of
submodules on the repository so that operations looking up N
submodules are O(N) and not O(N^2).  Added a
`git_repository_submodule_cache_clear` function to remove the cache.

Also optimized the function that loads all submodules as it was itself
O(N^2) w.r.t the number of submodules, having to loop through the
`.gitmodules` file once per submodule.  I changed it to process the
`.gitmodules` file once, into a map.

Signed-off-by: David Turner <dturner@twosigma.com>
2017-01-20 17:33:56 -05:00
Edward Thomson
cb76eed5ce Merge pull request #4054 from jfultz/jfultz/fix_GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH
Fix handling of GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH flag.
2017-01-14 17:41:49 +00:00
Carlos Martín Nieto
2854e61956 Merge pull request #4061 from libgit2/ethomson/merge_opts
merge: set default rename threshold
2017-01-14 17:12:23 +00:00
lhchavez
f5586f5c73 Addressed review feedback 2017-01-14 16:37:00 +00:00
Carlos Martín Nieto
a6d833a29e Merge pull request #4049 from libgit2/ethomson/error_msgs
giterr_set: consistent error messages
2017-01-13 17:05:58 +01:00
Carlos Martín Nieto
2ac57aa89b https: don't test that RC4 is invalid
None of our crypto backends actually reject RC4 as a cipher so don't
test for it and instead keep it as something we'd like to do.
2017-01-09 18:32:11 +00:00
Carlos Martín Nieto
3829ba2e71 http: correct the expected error for RC4
We must make sure that we're getting a certificate error from the
library so we know that we're testing the right thing.
2017-01-09 17:58:58 +00:00
Carlos Martín Nieto
98d66240ec http: perform 'badssl' check also via certificate callback
Make sure that the callbacks do also get a 'valid' value of zero when
the certificate we're looking at is in valid and assert that within the
test.
2017-01-06 17:09:52 +00:00
lhchavez
a7ff6e5e5e Fix the memory leak 2017-01-03 18:24:51 -08:00
lhchavez
def644e48a Add a test 2017-01-01 17:35:29 -08:00
Edward Thomson
19ed4d0ca3 merge: set default rename threshold
When `GIT_MERGE_FIND_RENAMES` is set, provide a default for
`rename_threshold` when it is unset.
2017-01-01 22:34:43 +00:00
John Fultz
5f959dca0d Fix handling of GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH flag.
git_checkout_tree() sets up its working directory iterator to respect the
pathlist if GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH is present, which is great.
What's not so great is that this iterator is then used side-by-side with
an iterator created by git_checkout_iterator(), which did not set up its
pathlist appropriately (although the iterator mirrors all other iterator
options).

This could cause git_checkout_tree() to delete working tree files which
were not specified in the pathlist when GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH
was used, as the unsynchronized iterators causes git_checkout_tree() to think
that files have been deleted between the two trees.  Oops.

And added a test which fails without this fix (specifically, the final check
for "testrepo/README" to still be present fails).
2016-12-29 20:13:03 -06:00
Edward Thomson
8f0d5cdef9 tests: update error message checking 2016-12-29 12:55:49 +00:00
Edward Thomson
8d7717c471 Merge pull request #4034 from libgit2/cmn/sysdir-no-reguess
sysdir: don't re-guess when using variable substitution
2016-12-20 15:32:49 +00:00
Carlos Martín Nieto
410855fc4b sysdir: add failing test for variable substitution
When given $PATH as part of a search path, we guess again instead of
substituting what the user already set.
2016-12-18 14:47:27 +00:00
Carlos Martín Nieto
f7dcd58cc7 rebase: plug a leak in the tests 2016-12-17 00:55:06 +00:00
Edward Thomson
c5e6ba2892 Merge pull request #4029 from libgit2/cmn/windows-no-concurrent-compress
refdb: disable concurrent compress in the threading tests on Windows
2016-12-15 18:19:49 -06:00
Carlos Martín Nieto
b31283a658 refdb: disable concurrent compress in the threading tests on Windows
This is far from an ideal situation, but this causes issues on Windows which
make it harder to develop anything, as these tests hit issues which relate
specifically to the Windows filesystem like permission errors for files we
should be able to access. There is an issue likely related to the ordering of
the repack, but there's enough noise that it does not currently help us to run
this aspect of the test in CI.
2016-12-12 17:09:12 +00:00
Patrick Steinhardt
ab0cc5a059 clar: mark cl_git_thread_check() as inline
The function `cl_git_thread_check()` is defined as static. As the
function is defined in a header file which is included by our
tests, this can result in warnings for every test file where
`cl_git_thread_check` is never used.

Fix the issue by marking it as inline instead.
2016-12-12 09:16:33 +01:00
David Turner
4db1fc7e5e git_rebase_init: correctly handle detached HEAD
git_rebase_finish relies on head_detached being set, but
rebase_init_merge was only setting it when branch->ref_name was unset.
But branch->ref_name would be set to "HEAD" in the case of detached
HEAD being either implicitly (NULL) or explicitly passed to
git_rebase_init.
2016-12-01 23:11:57 -05:00
Edward Thomson
6367c58cd4 tests: handle life without threads 2016-11-18 19:00:14 +00:00
Edward Thomson
6a05c7a0ef threads::refdb tests: use new threaded clar assert 2016-11-18 16:52:28 +00:00
Edward Thomson
bbf22f8229 clar: Introduce assertion helpers for threads
Don't `cl_git_pass` in a child thread.  When the assertion fails, clar
will `longjmp` to its error handler, but:

> The effect of a call to longjmp() where initialization of the jmp_buf
> structure was not performed in the calling thread is undefined.

Instead, set up an error context that threads can populate, and the
caller can check.
2016-11-18 16:52:28 +00:00
Edward Thomson
99479062db core::init tests: reverse init/shutdown
We want a predictable number of initializations in our multithreaded
init test, but we also want to make sure that we have _actually_
initialized `git_libgit2_init` before calling `git_thread_create` (since
it now has a sanity check that `git_libgit2_init` has been called).

Since `git_thread_create` is internal-only, keep this sanity check.
Flip the invocation so that we `git_libgit2_init` before our thread
tests and `git_libgit2_shutdown` again after.
2016-11-18 16:52:28 +00:00
Edward Thomson
82f15896de threads: introduce git_thread_exit
Introduce `git_thread_exit`, which will allow threads to terminate at an
arbitrary time, returning a `void *`.  On Windows, this means that we
need to store the current `git_thread` in TLS, so that we can set its
`return` value when terminating.

We cannot simply use `ExitThread`, since Win32 returns `DWORD`s from
threads; we return `void *`.
2016-11-18 07:34:09 -05:00
Carlos Martín Nieto
a39f18ac77 Merge pull request #3998 from pks-t/pks/repo-discovery
Repository discovery starting from files
2016-11-14 17:10:43 +01:00
Edward Thomson
df045cef68 Merge pull request #4003 from libgit2/cmn/tree-updater-ordering
Use the sorted input in the tree updater
2016-11-14 12:12:38 +00:00
Carlos Martín Nieto
1d41b86cd0 tree: add a failing test for unsorted input
We do not currently use the sorted version of this input in the
function, which means we produce bad results.
2016-11-14 12:22:20 +01:00
Carlos Martín Nieto
aef54a466a refdb: use a constant for the number of per-thread creations/deletes 2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
ce5553d48b refdb: bubble up locked files on the read side
On Windows we can find locked files even when reading a reference or the
packed-refs file. Bubble up the error in this case as well to allow
callers on Windows to retry more intelligently.
2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
7c32d87450 refdb: expect threaded test deletes to race
At times we may try to delete a reference which a different thread has
already taken care of.
2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
26416f6d20 refdb: add retry logic to the threaded tests
The logic simply consists of retrying for as long as the library says
the data is locked, but it eventually gets through.
2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
7da4c429ea refdb: adjust the threading tests to what we promise
We say it's going to work if you use a different repository in each
thread. Let's do precisely that in our code instead of hoping re-using
the refdb is going to work.

This test does fail currently, surfacing existing bugs.
2016-11-14 11:25:58 +01:00
Patrick Steinhardt
0f31609611 repository: do not interpret all files as gitlinks in discovery
When trying to find a discovery, we walk up the directory
structure checking if there is a ".git" file or directory and, if
so, check its validity. But in the case that we've got a ".git"
file, we do not want to unconditionally assume that the file is
in fact a ".git" file and treat it as such, as we would error out
if it is not.

Fix the issue by only treating a file as a gitlink file if it
ends with "/.git". This allows users of the function to discover
a repository by handing in any path contained inside of a git
repository.
2016-11-14 10:53:08 +01:00
Patrick Steinhardt
4dbaf3cd62 test: discover: fix indentation 2016-11-14 10:53:08 +01:00
Patrick Steinhardt
5242c42488 test: discover: split up monolithic test into smaller ones 2016-11-14 10:53:08 +01:00
Patrick Steinhardt
07afeb23ae test: discover: pass constants to ensure_repository_discover 2016-11-14 10:53:08 +01:00
Patrick Steinhardt
2382b0f877 test: discover: move layout creation into test initializer 2016-11-14 10:53:08 +01:00
Patrick Steinhardt
5fe5557e8a Merge pull request #3974 from libgit2/pks/synchronize-shutdown
global: synchronize initialization and shutdown with pthreads
2016-11-04 18:18:46 +01:00
Patrick Steinhardt
6e2fab9ede Merge pull request #3977 from jfultz/fix-forced-branch-creation-on-bare-repo 2016-11-04 18:14:00 +01:00
John Fultz
f9793884a3 branch: fix forced branch creation on HEAD of a bare repo
The code correctly detects that forced creation of a branch on a
nonbare repo should not be able to overwrite a branch which is
the HEAD reference.  But there's no reason to prevent this on
a bare repo, and in fact, git allows this.  I.e.,

   git branch -f master new_sha

works on a bare repo with HEAD set to master.  This change fixes
that problem, and updates tests so that, for this case, both the
bare and nonbare cases are checked for correct behavior.
2016-11-04 18:12:35 +01:00
Patrick Steinhardt
1c33ecc445 tests: core: test deinitialization and concurrent initialization
Exercise the logic surrounding deinitialization of the libgit2
library as well as repeated concurrent de- and reinitialization.
This tries to catch races and makes sure that it is possible to
reinitialize libgit2 multiple times.

After deinitializing libgit2, we have to make sure to setup
options required for testing. Currently, this only includes
setting up the configuration search path again. Before, this has
been set up once in `tests/main.c`.
2016-11-02 08:53:52 +01:00
Patrick Steinhardt
95fa38802f pqueue: resolve possible NULL pointer dereference
The `git_pqueue` struct allows being fixed in its total number of
entries. In this case, we simply throw away items that are
inserted into the priority queue by examining wether the new item
to be inserted has a higher priority than the previous smallest
one.

This feature somewhat contradicts our pqueue implementation in
that it is allowed to not have a comparison function. In fact, we
also fail to check if the comparison function is actually set in
the case where we add a new item into a fully filled fixed-size
pqueue.

As we cannot determine which item is the smallest item in absence
of a comparison function, we fix the `NULL` pointer dereference
by simply dropping all new items which are about to be inserted
into a full fixed-size pqueue.
2016-10-28 16:19:24 +02:00
Patrick Steinhardt
30a876cda6 tests: fetchhead: fix memory leak 2016-10-27 11:29:15 +02:00
Patrick Steinhardt
61ad9bcd38 tests: vector: fix memory leak 2016-10-27 11:26:52 +02:00
Edward Thomson
610cff13a3 Merge branch 'pr/3809' 2016-10-09 16:05:48 +01:00
Sim Domingo
dc5cfdbab9 make git_diff_stats_to_buf not show 0 insertions or 0 deletions 2016-10-09 16:03:00 +01:00
Arthur Schreiber
361179786d Fix the existence check for regcomp_l.
`xlocale.h` only defines `regcomp_l` if `regex.h` was included as well.

Also change the test cases to actually test `p_regcomp` works with
a multibyte locale.
2016-10-07 12:47:04 -07:00