Commit Graph

824 Commits

Author SHA1 Message Date
Carlos Martín Nieto
430866d28c Fix a leak in the tests 2014-05-20 08:29:51 +02:00
Vicent Marti
124a45ead3 Merge pull request #2354 from libgit2/cmn/clone-into-mirror
Allow mirror-clone via `git_clone_into()`
2014-05-19 15:00:50 +02:00
Carlos Martín Nieto
b206724863 clone: add failing test for a mirror-clone with clone_into
Show a failure to perform a mirror-clone from a repository, both local
and remote.
2014-05-19 14:24:43 +02:00
Carlos Martín Nieto
49e369b29d message: don't assume the comment char
The comment char is configurable and we need to provide a way for the
user to specify which comment char they chose for their message.
2014-05-18 10:06:49 +02:00
Philip Kelley
d7a294633d Fix a bug in the pack::packbuilder suite 2014-05-17 16:58:09 -04:00
Vicent Marti
191ff93609 Merge pull request #2362 from libgit2/rb/update-4k-to-8k
Test and fix Git diff binary detection compatibility
2014-05-17 02:37:13 +02:00
Russell Belfer
8af4966db1 Git binary check compat tests
A variety of data patterns for diffs verified to match the
behavior of binary detection with Git on the command line.
2014-05-16 16:30:58 -07:00
Vicent Marti
228272ef58 Merge pull request #2313 from libgit2/cmn/remote-delete
Remote deletion
2014-05-16 11:56:37 +02:00
Carlos Martín Nieto
ec8a949a58 remote: remove remote-tracking branches on delete
When we delete a remote, we also need to go through its fetch refspecs
and remove the references they create locally.
2014-05-16 10:02:07 +02:00
Russell Belfer
8487e23797 Better search path sandboxing
There are a number of tests that modify the global or system
search paths during the tests.  This adds a helper function to
make it easier to restore those paths and makes sure that they
are getting restored in a manner that preserves test isolation.
2014-05-15 10:56:28 -07:00
Vicent Marti
03fcef1889 Merge pull request #2328 from libgit2/rb/how-broken-can-ignores-be
Improve checks for ignore containment
2014-05-13 12:40:13 +02:00
Russell Belfer
df3419269b Merge pull request #2336 from libgit2/rb/unicode-branch-names
Pass unconverted Unicode path data when iconv doesn't like it
2014-05-12 10:51:56 -07:00
Russell Belfer
af567e8853 Merge pull request #2334 from libgit2/rb/fix-2333
Be more careful with user-supplied buffers
2014-05-12 10:44:13 -07:00
Russell Belfer
ce3b71d91b Don't scale diff stat when not needed 2014-05-12 10:28:45 -07:00
Russell Belfer
7bcced44b7 Merge pull request #2300 from libgit2/cmn/match-host-tests
Some improvements to the cert checking
2014-05-12 10:15:30 -07:00
Russell Belfer
d2c4d1c63d Merge pull request #2188 from libgit2/cmn/config-snapshot
Configuration snapshotting
2014-05-12 10:04:52 -07:00
Vicent Marti
e18d5e52e3 Merge pull request #2331 from libgit2/rb/dont-stop-diff-on-safecrlf
Add filter options and ALLOW_UNSAFE
2014-05-09 08:59:59 +02:00
Russell Belfer
bb45e39063 Disable threads::refdb::edit_while_iterate test
It seems that with the various recent changes to reference updating
and reflog writing, that the thread safety of refdb updates has
been reduced (either that or it was never thread safe and the
window for error has increased).  Either way, this test is now
sometimes segfaulting which is no good, so let's disable the test
for now.  We don't really make any public promises about thread
safety for this type of operation, so I think this is acceptable,
at least in the short term.
2014-05-08 15:01:07 -07:00
Russell Belfer
8a2ef218b9 Don't always test composed-insensitive lookups
Only on a filesystem that is composed/decomposed insensitive,
should be testing that a branch can be looked up by the opposite
form and still work correctly.
2014-05-08 14:48:27 -07:00
Russell Belfer
be20ac5a1d Allow cl_repo_get_bool to work with missing key
One of the test helpers provides a quick way for looking up a
boolean key.  But if the key way missing completely, the check
would actually raise an error.  Given the way we use this helper,
if the key is missing, this should just return false, I think.
2014-05-08 14:33:37 -07:00
Russell Belfer
43a0413524 Pass unconverted data when iconv doesn't like it
When using Iconv to convert unicode data and iconv doesn't like
the source data (because it thinks that it's not actual UTF-8),
instead of stopping the operation, just use the unconverted data.
This will generally do the right thing on the filesystem, since
that is the source of the non-UTF-8 path data anyhow.

This adds some tests for creating and looking up branches with
messy Unicode names.  Also, this takes the helper function that
was previously internal to `git_repository_init` and makes it
into `git_path_does_fs_decompose_unicode` which is a useful in
tests to understand what the expected results should be.
2014-05-08 13:52:46 -07:00
Russell Belfer
1e4976cb01 Be more careful with user-supplied buffers
This adds in missing calls to `git_buf_sanitize` and fixes a
number of places where `git_buf` APIs could inadvertently write
NUL terminator bytes into invalid buffers.  This also changes the
behavior of `git_buf_sanitize` to NUL terminate a buffer if it can
and of `git_buf_shorten` to do nothing if it can.

Adds tests of filtering code with zeroed (i.e. unsanitized) buffer
which was previously triggering a segfault.
2014-05-08 10:17:14 -07:00
Russell Belfer
5269008cf6 Add filter options and ALLOW_UNSAFE
Diff and status do not want core.safecrlf to actually raise an
error regardless of the setting, so this extends the filter API
with an additional options flags parameter and adds a flag so that
filters can be applied with GIT_FILTER_OPT_ALLOW_UNSAFE, indicating
that unsafe filter application should be downgraded from a failure
to a warning.
2014-05-06 16:01:49 -07:00
Russell Belfer
f554611a27 Improve checks for ignore containment
The diff code was using an "ignored_prefix" directory to track if
a parent directory was ignored that contained untracked files
alongside tracked files. Unfortunately, when negative ignore rules
were used for directories inside ignored parents, the wrong rules
were applied to untracked files inside the negatively ignored
child directories.

This commit moves the logic for ignore containment into the workdir
iterator (which is a better place for it), so the ignored-ness of
a directory is contained in the frame stack during traversal.  This
allows a child directory to override with a negative ignore and yet
still restore the ignored state of the parent when we traverse out
of the child.

Along with this, there are some problems with "directory only"
ignore rules on container directories.  Given "a/*" and "!a/b/c/"
(where the second rule is a directory rule but the first rule is
just a generic prefix rule), then the directory only constraint
was having "a/b/c/d/file" match the first rule and not the second.
This was fixed by having ignore directory-only rules test a rule
against the prefix of a file with LEADINGDIR enabled.

Lastly, spot checks for ignores using `git_ignore_path_is_ignored`
were tested from the top directory down to the bottom to deal with
the containment problem, but this is wrong. We have to test bottom
to top so that negative subdirectory rules will be checked before
parent ignore rules.

This does change the behavior of some existing tests, but it seems
only to bring us more in line with core Git, so I think those
changes are acceptable.
2014-05-06 12:41:26 -07:00
Carlos Martín Nieto
ee311907ee odb: ignore files in the objects dir
We assume that everything under GIT_DIR/objects/ is a directory. This is
not necessarily the case if some process left a stray file in there.

Check beforehand if we do have a directory and ignore the entry
otherwise.
2014-05-05 16:34:18 +02:00
Vicent Marti
272b462db7 Merge pull request #2308 from libgit2/rb/diff-update-index-stat-cache
Reduce excessive OID calculation for diff and stat
2014-05-02 09:50:15 -07:00
Russell Belfer
9862ef8ef8 Merge pull request #2310 from libgit2/cmn/commit-create-safe
commit: safer commit creation with reference update
2014-05-02 09:42:07 -07:00
Russell Belfer
99dfa47039 Some further sandboxing cleanups to tests
Trying to find other issues where tests may not clean up quite
properly when they are through...
2014-05-02 09:21:33 -07:00
Russell Belfer
0f603132bc Improve handling of fake home directory
There are a few tests that set up a fake home directory and a
fake GLOBAL search path so that we can test things in global
ignore or attribute or config files.  This cleans up that code to
work more robustly even if there is a test failure.  This also
fixes some valgrind warnings where scanning search paths for
separators could end up doing a little bit of sketchy data access
when coming to the end of search list.
2014-05-02 09:21:33 -07:00
Russell Belfer
bc91347b58 Fix remaining init_options inconsistencies
There were a couple of "init_opts()" functions a few more cases
of structure initialization that I somehow missed.
2014-05-02 09:21:33 -07:00
Russell Belfer
9c8ed49997 Remove trace / add git_diff_perfdata struct + api 2014-05-02 09:21:33 -07:00
Russell Belfer
7a2e56a3f6 Get rid of redundant git_diff_options_init fn
Since git_diff_init_options was introduced, remove this old fn.
2014-05-02 09:21:33 -07:00
Russell Belfer
b23b112dfe Add payloads, bitmaps to trace API
This is a proposed adjustment to the trace APIs.  This makes the
trace levels into a bitmask so that they can be selectively enabled
and adds a callback-level payload, plus a message-level payload.

This makes it easier for me to a GIT_TRACE_PERF callbacks that
are simply bypassed if the PERF level is not set.
2014-05-02 09:21:33 -07:00
Russell Belfer
225aab5d6a Don't use trace if GIT_TRACE not defined 2014-05-02 09:21:33 -07:00
Russell Belfer
cd424ad551 Add GIT_STATUS_OPT_UPDATE_INDEX and use trace API
This adds an option to refresh the stat cache while generating
status.  It also rips out the GIT_PERF stuff I had an makes use
of the trace API to keep statistics about what happens during diff.
2014-05-02 09:21:33 -07:00
Russell Belfer
94fb4aadc8 Add diff option to update index stat cache
When diff is scanning the working directory, if it finds a file
where it is not sure if the index entry matches the working dir,
it will recalculate the OID (which is pretty expensive).  This
adds a new flag to diff so that if the OID calculation finds that
the file actually has not changed (i.e. just the modified time was
altered or such), then it will refresh the stat cache in the index
so that future calls to diff will not have to check the oid again.
2014-05-02 09:21:33 -07:00
Russell Belfer
8ef4e11a76 Skip diff oid calc when size definitely changed
When we think the stat cache in the index seems valid and the size
or mode of a file has definitely changed, then don't bother trying
to recalculate the OID of the workdir bits to confirm that it is
modified - just accept that it is modified.

This can result in files that show as modified with no actual diff,
but the behavior actually appears to match Git on the command line.

This also includes a minor optimization to not perform a submodule
lookup on the ".git" directory itself.
2014-05-02 09:21:32 -07:00
Russell Belfer
240f4af321 Add build option for diff internal statistics 2014-05-02 09:21:32 -07:00
Russell Belfer
d19b2f9f9f Make ** pattern eat trailing slash
This allows "foo/**/*.html" to match "foo/file.html"
2014-05-01 12:46:46 -07:00
nulltoken
40e48ea40f remote: Introduce git_remote_delete() 2014-04-30 11:45:49 +02:00
nulltoken
48ebea662a tests: Introduce count_config_entries_match() helper 2014-04-30 07:24:20 +02:00
Carlos Martín Nieto
217c029b54 commit: safer commit creation with reference update
The current version of the commit creation and amend function are unsafe
to use when passing the update_ref parameter, as they do not check that
the reference at the moment of update points to what the user expects.

Make sure that we're moving history forward when we ask the library to
update the reference for us by checking that the first parent of the new
commit is the current value of the reference. We also make sure that the
ref we're updating hasn't moved between the read and the write.

Similarly, when amending a commit, make sure that the current tip of the
branch is the commit we're amending.
2014-04-30 00:41:37 +02:00
Carlos Martín Nieto
1f0d4f3d8d netops: unit-test the cert host-name pattern matching
This kind of stuff should have unit tests, even if it's just to show
what we expect to match successfully.
2014-04-26 17:27:42 +02:00
Jiri Pospisil
7b8d564d5d Reset tests: Use sandboxed index 2014-04-25 15:49:58 +02:00
Vicent Marti
8443ed6c1d Merge pull request #2284 from jacquesg/push-progress-callback
Fire progress and update tips callbacks also for pushes.
2014-04-25 02:10:19 -07:00
Vicent Marti
332e4f2027 Merge pull request #2297 from libgit2/rb/status-with-precomposed-changes
Improve test coverage of status with different core.precomposeunicode settings
2014-04-25 02:07:42 -07:00
Vicent Marti
2ad51b81d2 Merge pull request #2241 from libgit2/rb/stash-skip-submodules
Improve stash and checkout for ignored + untracked items
2014-04-25 02:04:12 -07:00
Russell Belfer
af9eeac939 Merge pull request #2294 from ethomson/merge_checkout_strategy
Merge checkout strategy
2014-04-24 16:20:08 -07:00
Russell Belfer
6b833e3a4a Improve docs for status rename detection limits
and make tests empty on platforms without iconv support.
2014-04-24 15:40:50 -07:00
Russell Belfer
f608f3bb27 Test toggling core.precomposeunicode yields rename
There is an interesting difference with core Git here, though.
Because libgit2 will do rename detection with the working directory,
in the last case where the HEAD and the working directory both
have the decomposed data and the index has the composed data, we
generate a single status record with two renames whereas Git will
generate one rename (head to index) and one untracked file.
2014-04-24 15:25:01 -07:00