Commit Graph

1970 Commits

Author SHA1 Message Date
Carlos Martín Nieto
1c3018eb12 ignore: fix directory limits when searching for star-star
In order to match the star-star, we disable the flag that's looking for
a single path element, but that leads to searching for the pattern in
the middle of elements in the input string.

Mark when we're handing a star-star so we jump over the elements in our
attempt to match the part of the pattern that comes after the star-star.

While here, tighten up the check so we don't allow invalid rules
through.
2016-04-19 19:39:05 +02:00
Carlos Martín Nieto
0d72f67f28 proxy: don't specify the protocol in the type
We leave this up to the scheme in the url field. The type should only
tell us about whether we want a proxy and whether we want to auto-detect
it.
2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
4e01741390 netops: make the path optional in URLs
When we're dealing with proxy addresses, we only want a hostname and
port, and the user would not provide a path, so make it optional so we
can use this same function to parse git as well as proxy URLs.
2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
b117721dd8 proxy: use poxy to test our Windows proxy support 2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
07bd3e57d9 proxy: ask the user for credentials if necessary 2016-04-19 13:54:19 +02:00
Antonio Scandurra
0f36271646 Add more tests for path matching with globs and path delimiters 2016-04-18 15:21:43 +02:00
Edward Thomson
bbd65ad27e tests: skip the unreadable file tests as root
When running as root, skip the unreadable file tests, because, well,
they're probably _not_ unreadable to root unless you've got some
crazy NSA clearance-level honoring operating system shit going on.
2016-04-11 15:32:38 -04:00
Edward Thomson
0e00eecf83 Merge pull request #3736 from libgit2/cmn/dwim-general-message
refs: provide a more general error message for dwim
2016-04-11 13:29:54 -04:00
Edward Thomson
d22a8b9583 refs::create: strict object creation on by default
When we turned strict object creation validation on by default, we
forgot to inform the refs::create tests of this.  They, in fact,
believed that strict object creation was off by default.  As a result,
their cleanup function went and turned strict object creation off for
the remaining tests.
2016-04-11 11:50:11 -04:00
Carlos Martín Nieto
6d22ef7a51 reset: use real ids for the tests
This lets us run with strict object creation on.
2016-04-11 11:47:56 -04:00
Carlos Martín Nieto
77965c685d refs: provide a more general error message for dwim
If we cannot dwim the input, set the error message to be explicit about
that. Otherwise we leave the error for the last failed lookup, which
can be rather unexpected as it mentions a remote when the user thought
they were trying to look up a branch.
2016-04-11 17:47:03 +02:00
Andreas Henriksson
04f47a43f9 tests: fix core/stream test when built with openssl off
When passing -DUSE_OPENSSL:BOOL=OFF to cmake the testsuite will
fail with the following error:

core::stream::register_tls [/tmp/libgit2/tests/core/stream.c:40]
  Function call failed: (error)
  error -1 - <no message>

Fix test to assume failure for tls when built without openssl.
While at it also fix GIT_WIN32 cpp to check if it's defined
or not.
2016-04-06 15:00:32 +02:00
Carlos Martín Nieto
381caf5690 Merge pull request #3724 from ethomson/submodule_start_supports_silly_slashes
iterator/diff: allow trailing `/` on start/end paths to match submodules
2016-04-02 22:19:42 -07:00
Edward Thomson
d47f7e1c15 iterator: support trailing / in start for submod
Allow callers to specify a start path with a trailing slash to match
a submodule, instead of just a directory.  This is for some legacy
behavior that's sort of dumb, but there it is.
2016-04-02 13:34:55 -07:00
Edward Thomson
2e0391f4f1 diff: test submodules are found with trailing /
Test that submodules are found when the are included in a pathspec
but have a trailing slash.
2016-04-02 13:02:41 -07:00
Carlos Martín Nieto
d364dc8b39 ignore: don't use realpath to canonicalize path
If we're looking for a symlink, realpath will give us the resolved path,
which is not what we're after, but a canonicalized version of the path
the user asked for.
2016-04-02 21:32:28 +02:00
Carlos Martín Nieto
1cac688d3f Merge pull request #3719 from libgit2/ethomson/submodule_status
WD iterator: properly identify submodules
2016-04-01 00:29:51 -07:00
Edward Thomson
74ab5f2cd0 status: test submodules with mixed case 2016-03-31 17:58:43 -04:00
Edward Thomson
17442b28f9 leaks: fix some leaks in the tests 2016-03-31 10:41:33 -04:00
Carlos Martín Nieto
f5c874a475 Plug a few leaks 2016-03-31 10:41:33 -04:00
Carlos Martín Nieto
2f0450f4d6 Merge pull request #3712 from ethomson/config_duplicate_section
config: don't write duplicate section
2016-03-29 03:26:43 -07:00
Edward Thomson
b085ecbe09 Merge pull request #3703 from libgit2/cmn/multivar-set-locked
config: don't special-case multivars that don't exist yet
2016-03-28 13:51:21 -04:00
Edward Thomson
76e1a679ea config::write::repeated: init our buffer 2016-03-28 08:56:13 -07:00
Carlos Martín Nieto
3e95bd36d9 config: show we write a spurious duplicated section header
We should notice that we are in the correct section to add. This is a
cosmetic bug, since replacing any of these settings does work.
2016-03-28 10:47:14 -04:00
Marc Strapetz
c017c18361 iterator: new workdir-iterator test for pathlist + includings trees 2016-03-24 15:59:49 -04:00
Marc Strapetz
09064f15c5 iterator: new index-iterator test for pathlist + includings trees 2016-03-24 15:59:49 -04:00
Marc Strapetz
8152a74821 iterator: more pathlist-related tests should test actual paths 2016-03-24 15:59:49 -04:00
Edward Thomson
d712c2b27f iterator: don't run the gunk test by default on CI
(It's slow!)
2016-03-24 15:59:48 -04:00
Edward Thomson
0ef0b71ca5 iterator: refactor index iterator 2016-03-24 15:59:48 -04:00
Edward Thomson
ba6f86eb2e Introduce git_path_common_dirlen 2016-03-24 15:59:48 -04:00
Edward Thomson
de034cd239 iterator: give the tests a proper hierarchy
Iterator tests were split over repo::iterator and diff::iterator,
with duplication between the two.  Move them to iterator::index,
iterator::tree, and iterator::workdir.
2016-03-24 15:59:48 -04:00
Jeff Hostetler
df25daef9b Added clar test for #3568 2016-03-23 17:17:02 -04:00
Edward Thomson
6cd9573f54 iterator: test that we can advance_into empty dirs
Prior iterator implementations returned `GIT_ENOTFOUND` when
trying to advance into empty directories.  Ensure that we no longer
do that and simply handle them gracefully.
2016-03-23 17:17:02 -04:00
joshaber
b620426006 Failing test. 2016-03-23 17:17:02 -04:00
Marc Strapetz
ae86aa5a68 iterator: test pathlist handling for directories
tree_iterator was only working properly for a pathlist containing
file paths. In case of directory paths, it didn't match children
which contradicts GIT_DIFF_DISABLE_PATHSPEC_MATCH and
is different from index_iterator and fs_iterator.

As a consequence head-to-index status reporting for a specific
directory did not work properly -- all files have been reported
as added.

Include additional tests.
2016-03-23 17:16:38 -04:00
Edward Thomson
6bcddf88b3 iterator: test advance_over with a pathlist 2016-03-23 17:16:38 -04:00
Edward Thomson
9fb2527f3c iterator: add tests for advance_over
`git_iterator_advance_over` is a gnarly bit of code with no actual
tests.
2016-03-23 17:16:37 -04:00
Edward Thomson
85541f4390 iterator: test workdir pathlist with deep paths
In the workdir iterator we do some tricky things to step down into
directories to look for things that are in our pathlist.  Make sure
that we don't confuse between folders that we're definitely going to
return everything in and folders that we're only stepping down into
to keep looking for matches.
2016-03-23 17:16:37 -04:00
Edward Thomson
908d8de8c3 iterator: workdir tests with submodules
Ensure that when specifying start/end paths, or pathlists, that we
deal correctly with submodules.
2016-03-23 17:16:37 -04:00
Edward Thomson
c3d195f1d9 iterator: expand workdir tests with pathlist
Expand the workdir tests to validate the paths in case sensitive
and insensitive tests.
2016-03-23 17:16:37 -04:00
Edward Thomson
4c88198a85 iterator: test that we're at the end of iteration
Ensure that we have hit the end of iteration; previously we tested
that we saw all the values that we expected to see.  We did not
then ensure that we were at the end of the iteration (and that there
were subsequently values in the iteration that we did *not* expect.)
2016-03-23 17:16:37 -04:00
Edward Thomson
d051de243c iterator: test fs iterator w/ many nested empty dirs 2016-03-23 17:08:37 -04:00
Edward Thomson
a4f520a6f6 iterator: skip unreadable directories in fs iterator
Do not abort iteration in the middle when encountering an unreadable
directory.  Instead, skip it, as if it didn't exist.
2016-03-23 17:08:37 -04:00
Edward Thomson
be30387e8b iterators: refactored tree iterator
Refactored the tree iterator to never recurse; simply process the
next entry in order in `advance`.  Additionally, reduce the number of
allocations and sorting as much as possible to provide a ~30% speedup
on case-sensitive iteration.  (The gains for case-insensitive iteration
are less majestic.)
2016-03-23 17:08:37 -04:00
Edward Thomson
277c85eb1c repo::iterator: don't go out of bounds 2016-03-23 17:08:37 -04:00
Edward Thomson
684b35c41b iterator: disambiguate reset and reset_range
Disambiguate the reset and reset_range functions.  Now reset_range
with a NULL path will clear the start or end; reset will leave the
existing start and end unchanged.
2016-03-23 17:08:37 -04:00
Edward Thomson
8a5a2e2f0e status: update test to include valid OID 2016-03-23 17:08:36 -04:00
Carlos Martín Nieto
661db4f482 Merge pull request #3704 from ethomson/tree-reuse
tree: drop the now-unnecessary entries vector
2016-03-23 03:45:53 -07:00
Carlos Martín Nieto
6669e3e839 blob: remove _fromchunks()
The callback mechanism makes it awkward to write data from an IO
source; move to `_fromstream()` which lets the caller remain in control,
in the same vein as we prefer iterators over foreach callbacks.
2016-03-22 20:00:25 +01:00
Carlos Martín Nieto
35e68606da blob: fix fromchunks iteration counter
By returning when the count goes to zero rather than below it, setting
`howmany` to 7 in fact writes out the string 6 times.

Correct the termination condition to write out the string the amount of
times we specify.
2016-03-22 20:00:24 +01:00
Carlos Martín Nieto
0a5c602889 blob: introduce creating a blob by writing into a stream
The pair of `git_blob_create_frombuffer()` and
`git_blob_create_frombuffer_commit()` is meant to replace
`git_blob_create_fromchunks()` by providing a way for a user to write a
new blob when they want filtering or they do not know the size.

This approach allows the caller to retain control over when to add data
to this buffer and a more natural fit into higher-level language's own
stream abstractions instead of having to handle IO wait in the callback.

The in-memory buffer size of 2MB is chosen somewhat arbitrarily to be a
round multiple of usual page sizes and a value where most blobs seem
likely to be either going to be way below or way over that size. It's
also a round number of pages.

This implementation re-uses the helper we have from `_fromchunks()` so
we end up writing everything to disk, but hopefully more efficiently
than with a default filebuf. A later optimisation can be to avoid
writing the in-memory contents to disk, with some extra complexity.
2016-03-22 19:34:08 +01:00
Edward Thomson
e2e4bae9a0 tree: drop the now-unnecessary entries vector
Remove the now-unnecessary entries vector.  Add `git_array_search`
to binary search through an array to accomplish this.
2016-03-22 06:21:13 -07:00
Carlos Martín Nieto
6f09911c0f config: don't special-case multivars that don't exist yet
This special-casing ignores that we might have a locked file, so the
hashtable does not represent the contents of the file we want to
write. This causes multivar writes to overwrite entries instead of add
to them when under lock.

There is no need for this as the normal code-path will write to the file
just fine, so simply get rid of it.
2016-03-21 22:25:12 +01:00
Carlos Martín Nieto
60a194aa86 tree: re-use the id and filename in the odb object
Instead of copying over the data into the individual entries, point to
the originals, which are already in a format we can use.
2016-03-20 11:00:12 +01:00
Edward Thomson
d953c4505e merge drivers: handle configured but not found driver 2016-03-17 11:06:00 -04:00
Edward Thomson
6d8b2cdbee merge driver: remove check callback
Since the `apply` callback can defer, the `check` callback is not
necessary.  Removing the `check` callback further makes the `payload`
unnecessary along with the `cleanup` callback.
2016-03-17 11:06:00 -04:00
Edward Thomson
58d33126d4 merge driver: tests for set and unset merge attribute
Ensure that setting the merge attribute forces the built-in default
`text` driver and does *not* honor the `merge.default` configuration
option.  Further ensure that unsetting the merge attribute forces
a conflict (the `binary` driver).
2016-03-17 11:02:27 -04:00
Edward Thomson
d3f0875a60 merge driver: tests for custom default merge drivers 2016-03-17 11:02:27 -04:00
Edward Thomson
7d307c1edc merge driver: test GIT_EMERGECONFLICT
When a `check` or `apply` callback function returns `GIT_EMERGECONFLICT`
stop and product a conflict.
2016-03-17 11:02:27 -04:00
Edward Thomson
59f2931465 merge driver: test GIT_PASSTHROUGH
When a `check` or `apply` callback function returns `GIT_PASSTHROUGH`,
move on to the default merge driver.
2016-03-17 11:02:27 -04:00
Edward Thomson
3f04219fcd merge driver: introduce custom merge drivers
Consumers can now register custom merged drivers with
`git_merge_driver_register`.  This allows consumers to support the
merge drivers, as configured in `.gitattributes`.  Consumers will be
asked to perform the file-level merge when a custom driver is
configured.
2016-03-17 11:02:26 -04:00
Stan Hu
7a74590d8f Fix rebase bug and include test for merge=union 2016-03-17 11:02:26 -04:00
Edward Thomson
ba3493228c Merge pull request #3673 from libgit2/cmn/commit-with-signature
commit: add function to attach a signature to a commit
2016-03-17 06:57:56 -07:00
Edward Thomson
a151eb544b Merge pull request #3685 from pks-t/pks/memleaks
Test memleaks
2016-03-17 06:55:24 -07:00
Carlos Martín Nieto
bf804d407e commit: fix extraction of single-line signatures
The function to extract signatures suffers from a similar bug to the
header field finding one by having an unecessary line feed check as a
break condition of its loop.

Fix that and add a test for this single-line signature situation.
2016-03-17 10:48:06 +01:00
Carlos Martín Nieto
02d61a3b66 commit: add function to attach a signature to a commit
In combination with the function which creates a commit into a buffer,
this allows us to more easily create signed commits.
2016-03-15 12:55:03 +01:00
Dirkjan Bussink
c577efbbb5 Use general cl_git_fail because the error is generic 2016-03-14 12:41:41 +00:00
Dirkjan Bussink
fa72d6daf8 Setup better defaults for OpenSSL ciphers
This ensures that when using OpenSSL a safe default set of ciphers
is selected. This is done so that the client communicates securely
and we don't accidentally enable unsafe ciphers like RC4, or even
worse some old export ciphers.

Implements the first part of https://github.com/libgit2/libgit2/issues/3682
2016-03-14 12:07:13 +00:00
Patrick Steinhardt
35b7bca28b tests: transport: fix memory leaks with registering transports 2016-03-11 11:06:42 +01:00
Patrick Steinhardt
e756877dbf tests: nsec: correctly free nsec_path
git_buf_clear does not free allocated memory associated with a
git_buf. Use `git_buf_free` instead to correctly free its memory
and plug the memory leak.
2016-03-11 09:07:42 +01:00
Carlos Martín Nieto
2ba9a0ddac Merge pull request #3623 from ethomson/rebase_with_commit
rebase: additional setup tests of exotic behavior
2016-03-09 23:45:33 +01:00
Vicent Marti
9a78665005 odb: Handle corner cases in git_odb_expand_ids
The old implementation had two issues:

1. OIDs that were too short as to be ambiguous were not being handled
properly.

2. If the last OID to expand in the array was missing from the ODB, we
would leak a `GIT_ENOTFOUND` error code from the function.
2016-03-09 11:00:27 +01:00
Vicent Marti
c68044a879 Merge pull request #3656 from ethomson/exists_prefixes
Introduce `git_odb_expand_ids`
2016-03-08 21:17:38 +01:00
Edward Thomson
62484f52d1 git_odb_expand_ids: accept git_odb_expand_id array
Take (and write to) an array of a struct, `git_odb_expand_id`.
2016-03-08 14:57:20 -05:00
Edward Thomson
4b1f0f79ac git_odb_expand_ids: rename func, return the type 2016-03-08 11:44:21 -05:00
Edward Thomson
b7809b8469 Merge pull request #3555 from cbargren/ssh-git-protocols
Support for ssh+git and git+ssh protocols
2016-03-08 13:38:55 +00:00
Edward Thomson
534ca8882d Merge pull request #3652 from libgit2/cmn/commit-to-memory
commit: split creating the commit and writing it out
2016-03-08 13:35:11 +00:00
Carlos Martín Nieto
47cb42da5a commit: split creating the commit and writing it out
Sometimes you want to create a commit but not write it out to the
objectdb immediately. For these cases, provide a new function to
retrieve the buffer instead of having to go through the db.
2016-03-08 13:11:49 +01:00
Carlos Martín Nieto
eeff96c474 Merge pull request #3655 from ethomson/nanosecond_defaults
Enable nanosecond resolution by default
2016-03-08 10:43:33 +01:00
Edward Thomson
53fb823bcc index::racy: force racy entry
Instead of hoping that we can get a racy entry by going real fast
and praying real hard, just create a racy entry.
2016-03-08 00:47:55 -05:00
Edward Thomson
565c419972 index::nsec: don't expect shit filesystems to not suck
If the underlying filesystem doesn't support better than one
second resolution, then don't expect that turning on `GIT_USE_NSEC`
does anything magical to change that.
2016-03-07 17:04:32 -05:00
Edward Thomson
6c04269c8f git_odb_exists_many_prefixes: query odb for multiple short ids
Query the object database for multiple objects at a time, given their
object ID (which may be abbreviated) and optional type.
2016-03-07 16:10:25 -05:00
Edward Thomson
6abdf52d6e merge::workdir::dirty: update to use st_ctime_nsec
Update unit test to use newfangled `st_ctime_nsec`, which provides
indirection to the platform-correct name.
2016-03-07 09:37:51 -05:00
Carlos Martín Nieto
ea5bf6bbce treebuilder: don't try to verify submodules exist in the odb
Submodules don't exist in the objectdb and the code is making us try to
look for a blob with its commit id, which is obviously not going to
work.

Skip the test if the user wants to insert a submodule.
2016-03-04 12:38:28 +01:00
Carlos Martín Nieto
e23efa6ddf tests: take the version from our define 2016-03-03 21:03:10 +01:00
Carlos Martín Nieto
9b3fc895b7 tests: plug a leak 2016-03-03 11:17:36 +01:00
Edward Thomson
09d9968014 rebase: additional tests for completing a rebase 2016-02-28 20:10:44 -05:00
Edward Thomson
f2dddf52c0 turn on strict object validation by default 2016-02-28 18:59:43 -05:00
Edward Thomson
4afe536ba1 tests: use legitimate object ids
Use legitimate (existing) object IDs in tests so that we have the
ability to turn on strict object validation when running tests.
2016-02-28 18:54:56 -05:00
Edward Thomson
98c341496f refs: honor strict object creation 2016-02-28 18:54:39 -05:00
Edward Thomson
6ddf533afc git_index_add: validate objects in index entries (optionally)
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the index entries given to `git_index_add`.
2016-02-28 18:54:39 -05:00
Edward Thomson
2bbc7d3e56 treebuilder: validate tree entries (optionally)
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the tree and parent ids given to treebuilder insertion.
2016-02-28 12:38:40 -05:00
Edward Thomson
ef63bab306 git_commit: validate tree and parent ids
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the tree and parent ids given to commit creation functions.
2016-02-28 12:38:39 -05:00
Edward Thomson
6cc4bac894 Merge pull request #3577 from rossdylan/rossdylan/pooldebug
Add a new build flag to disable the pool allocator
2016-02-28 11:31:10 -05:00
Edward Thomson
a4c55069e3 nsec: update staging test for GIT_USE_NSECS
The index::nsec::staging_maintains_other_nanos test was created to
ensure that when we stage an entry when GIT_USE_NSECS is *unset* that
we truncate the index entry and do not persist the (old, invalid)
nanosec values.  Ensure that when GIT_USE_NSECS is *set* that we do
not do that, and actually write the correct nanosecond values.
2016-02-25 11:40:40 -05:00
Edward Thomson
7bab2e8fbf git_libgit2_opts: validate key 2016-02-22 23:07:30 -05:00
Carlos Martín Nieto
5663d4f691 Merge pull request #3613 from ethomson/fixups
Remove most of the silly warnings
2016-02-18 12:31:56 +01:00
Carlos Martín Nieto
594a5d12d4 Merge pull request #3619 from ethomson/win32_forbidden
win32: allow us to read indexes with forbidden paths on win32
2016-02-18 12:28:06 +01:00
Edward Thomson
2a39818c37 rebase: additional setup tests of exotic behavior
Test some additional exotic rebase setup behavior:  that we are
able to set up properly when already in a detached HEAD state,
that the caller specifies all of branch, upstream and onto,
and that the caller specifies branch, upstream and onto by ID.
2016-02-17 16:22:15 +00:00
Edward Thomson
318b825e76 index: allow read of index w/ illegal entries
Allow `git_index_read` to handle reading existing indexes with
illegal entries.  Allow the low-level `git_index_add` to add
properly formed `git_index_entry`s even if they contain paths
that would be illegal for the current filesystem (eg, `AUX`).
Continue to disallow `git_index_add_bypath` from adding entries
that are illegal universally illegal (eg, `.git`, `foo/../bar`).
2016-02-17 13:10:33 +00:00
Edward Thomson
4be2aa57c9 win32: tests around handling forbidden paths
Introduce a repository that contains some paths that were illegal
on PC-DOS circa 1981 (like `aux`, `con`, `com1`) and that in a
bizarre fit of retrocomputing, remain illegal on some "modern"
computers, despite being "new technology".

Introduce some aspirational tests that suggest that we should be
able to cope with trees and indexes that contain paths that
would be illegal on the filesystem, so that we can at least diff
them.  Further ensure that checkout will not write a repository
with forbidden paths.
2016-02-17 13:10:33 +00:00
Carlos Martín Nieto
eadd0f05f6 commit: expose the different kinds of errors
We should be checking whether the object we're looking up is a commit,
and we should let the caller know whether the not-found return code
comes from a bad object type or just a missing signature.
2016-02-16 14:06:48 +01:00
Edward Thomson
0d9a39eaf5 win32: drop incorrect constness 2016-02-16 11:50:45 +00:00
Edward Thomson
f28bae0c38 rebase: persist a single in-memory index
When performing an in-memory rebase, keep a single index for the
duration, so that callers have the expected index lifecycle and
do not hold on to an index that is free'd out from under them.
2016-02-15 19:27:06 +00:00
Edward Thomson
35439f5997 win32: introduce p_timeval that isn't stupid
Windows defines `timeval` with `long`, which we cannot
sanely cope with.  Instead, use a custom timeval struct.
2016-02-12 10:34:15 -08:00
Carlos Martín Nieto
5a296ad07e Merge pull request #3610 from ethomson/rebase_bare
rebase: introduce bare rebasing
2016-02-12 00:55:20 +01:00
Arthur Schreiber
3679ebaef5 Horrible fix for #3173. 2016-02-11 23:41:34 +01:00
Carlos Martín Nieto
460ae11f0a commit: don't forget the last header field
When we moved the logic to handle the first one, wrong loop logic was
kept in place which meant we still finished early. But we now notice it
because we're not reading past the last LF we find.

This was not noticed before as the last field in the tested commit was
multi-line which does not trigger the early break.
2016-02-11 22:19:20 +01:00
Edward Thomson
263e674ec6 merge tests: correct casts 2016-02-11 11:41:23 -08:00
Edward Thomson
ad8aa11288 reset test: fix initialization warning 2016-02-11 11:26:42 -08:00
Edward Thomson
a202e0d45b rebase: allow custom merge_options
Allow callers of rebase to specify custom merge options.  This may
allow custom conflict resolution, or failing fast when conflicts
are detected.
2016-02-11 10:49:25 -08:00
Edward Thomson
ee6673070a rebase: introduce inmemory rebasing
Introduce the ability to rebase in-memory or in a bare repository.

When `rebase_options.inmemory` is specified, the resultant `git_rebase`
session will not be persisted to disk.  Callers may still analyze
the rebase operations, resolve any conflicts against the in-memory
index and create the commits.  Neither `HEAD` nor the working
directory will be updated during this process.
2016-02-11 10:48:48 -08:00
Vicent Marti
488e2b8505 Merge pull request #3599 from libgit2/gpgsign
Introduce git_commit_extract_signature
2016-02-09 16:26:58 +01:00
Carlos Martín Nieto
a65afb757e Introduce git_commit_extract_signature
This returns the GPG signature for a commit and its contents without the
signature block, allowing for the verification of the commit's
signature.
2016-02-09 15:58:16 +01:00
Carlos Martín Nieto
f55eca167c commit: also match the first header field when searching
We were searching only past the first header field, which meant we were
unable to find e.g. `tree` which is the first field.

While here, make sure to set an error message in case we cannot find the
field.
2016-02-09 07:17:26 +01:00
Ross Delinger
ed0571f895 Add a new build flag to disable the pool allocator and pass all git_pool_malloc calls straight to git__malloc 2016-01-12 16:08:38 -05:00
Chris Bargren
1cc7f544a0 Adding test cases that actually test the functionality of the new transport
ssh, ssh+git and git+ssh should all successfully build an SSH transport
2015-12-28 11:45:07 -07:00
Edward Thomson
62602547db git_repository_init: include dotfiles when copying templates
Include dotfiles when copying template directory, which will handle
both a template directory itself that begins with a dotfile, and
any dotfiles inside the directory.
2015-12-26 22:41:00 -06:00
Edward Thomson
002821837f repo::init tests: test a template dir with leading dot
Ensure that we can handle template directories that begin with a
leading dot.
2015-12-26 22:32:17 -06:00
Edward Thomson
5c042c5bf5 repo::init tests: test init.templatedir setting
Ensure that `git_repository_init` honors the `init.templatedir`
configuration setting.
2015-12-26 22:06:45 -06:00
Chris Bargren
0c1f56722b Adding spec coverage for ssh+git and git+ssh protocols 2015-12-22 10:56:38 -07:00
Dmitriy Olshevskiy
91f0d186b4 typos in comments 2015-12-21 22:18:07 +03:00
Vicent Marti
5951445fb3 commit: Fix memory leak in test suite 2015-12-17 10:13:04 +01:00
Edward Thomson
30c8e26074 Merge pull request #3521 from pks-t/blame-line-overflow
Line count overflow in git_blame_hunk and git_blame__entry
2015-12-14 13:53:26 -06:00
Carlos Martín Nieto
6aa06b65cf Merge pull request #3522 from pks-t/email-format-commit-message
diff: include commit message when formatting patch
2015-12-10 12:14:09 +01:00
Carlos Martín Nieto
465c3b38d5 reset: perform the checkout before moving HEAD or the index
This keeps the state of the workdir the same as one from HEAD, removing
a source of possible confusion when calculating the work that is to be
done.
2015-12-09 19:16:11 +01:00
Michał Górny
326c9fc2ed checkout test: Apply umask to file-mode test as well
Fix the file-mode test to expect system umask being applied to the
created file as well (it is currently applied to the directory only).
This fixes the test on systems where umask != 022.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2015-12-01 20:42:56 +01:00
Patrick Steinhardt
254e0a33ee diff: include commit message when formatting patch
When formatting a patch as email we do not include the commit's
message in the formatted patch output. Implement this and add a
test that verifies behavior.
2015-12-01 10:12:53 +01:00
Patrick Steinhardt
7f8fe1d45e commit: introduce git_commit_body
It is already possible to get a commit's summary with the
`git_commit_summary` function. It is not possible to get the
remaining part of the commit message, that is the commit
message's body.

Fix this by introducing a new function `git_commit_body`.
2015-12-01 10:07:00 +01:00
Patrick Steinhardt
cb1cb24ca9 blame: use size_t for line counts in git_blame_hunk
It is not unreasonable to have versioned files with a line count
exceeding 2^16. Upon blaming such files we fail to correctly keep
track of the lines as `git_blame_hunk` stores them in `uint16_t`
fields.

Fix this by converting the line fields of `git_blame_hunk` to
`size_t`. Add test to verify behavior.
2015-12-01 09:02:47 +01:00
Patrick Steinhardt
a7bd157ebf tests: fix warning for nested struct initialization 2015-11-30 17:40:49 +01:00
Carlos Martín Nieto
a27f31d8f5 Merge pull request #3513 from ethomson/merge_recursive
Recursive Merge
2015-11-30 04:49:31 +01:00
Edward Thomson
5b9c63c3f6 recursive merge: add a recursion limit 2015-11-25 16:25:47 -05:00
Edward Thomson
78859c6344 merge: handle conflicts in recursive base building
When building a recursive merge base, allow conflicts to occur.
Use the file (with conflict markers) as the common ancestor.

The user has already seen and dealt with this conflict by virtue
of having a criss-cross merge.  If they resolved this conflict
identically in both branches, then there will be no conflict in the
result.  This is the best case scenario.

If they did not resolve the conflict identically in the two branches,
then we will generate a new conflict.  If the user is simply using
standard conflict output then the results will be fairly sensible.
But if the user is using a mergetool or using diff3 output, then the
common ancestor will be a conflict file (itself with diff3 output,
haha!).  This is quite terrible, but it matches git's behavior.
2015-11-25 15:38:39 -05:00
Edward Thomson
34a51428a1 merge tests: add complex recursive example 2015-11-25 15:38:33 -05:00
Edward Thomson
651bfd699c recursive: test conflict output during recursive merge 2015-11-25 15:38:28 -05:00
Edward Thomson
dcde572042 merge tests: move expected data into own file 2015-11-25 15:38:22 -05:00
Edward Thomson
b1eef912cf merge: add recursive test with conflicting contents 2015-11-25 15:37:51 -05:00
Edward Thomson
fccad82ee8 merge: add recursive test with three merge bases 2015-11-25 15:37:39 -05:00
Edward Thomson
99d9d9a470 merge: improve test names in recursive merge tests 2015-11-25 15:37:33 -05:00
Edward Thomson
a200bcf728 merge: add a third-level recursive merge 2015-11-25 15:37:28 -05:00
Edward Thomson
cdb6c1c83d merge: add a second-level recursive merge 2015-11-25 15:37:22 -05:00
Edward Thomson
86c8d02c07 merge: add simple recursive test
Add a simple recursive test - where multiple ancestors exist and
creating a virtual merge base from them would prevent a conflict.
2015-11-25 15:37:11 -05:00
Edward Thomson
fa78782f67 merge: rename git_merge_tree_flags_t -> git_merge_flags_t 2015-11-25 15:37:05 -05:00
Patrick Steinhardt
77b79dde84 tests: win32::longpath: free expected_msg 2015-11-24 15:21:52 +01:00
Patrick Steinhardt
9031be180b tests: config::stress: free git_config structs 2015-11-24 15:21:52 +01:00
Patrick Steinhardt
c8fab201eb tests: config::global: fix memleak in open_programdata 2015-11-24 14:47:50 +01:00
Edward Thomson
c4f60543b7 Merge pull request #3517 from jacquesg/warnings-fixes
Fix some warnings
2015-11-20 17:57:04 -05:00
Jacques Germishuys
87428c556f Fix some warnings 2015-11-20 20:48:51 +02:00
Carlos Martín Nieto
2ea40fdaac repository: distinguish sequencer cherry-pick and revert
These are not quite like their plain counterparts and require special handling.
2015-11-20 13:19:23 -05:00
Carlos Martín Nieto
69d1494873 Merge pull request #3511 from ethomson/racy_fixes_2
Racy fixes for writing new indexes
2015-11-17 13:21:18 -05:00
Edward Thomson
88638f9b18 tests: use out-of-the-way config dir in sandbox
Don't put the configuration in a subdir of the sandbox named
`config`, lest some tests decide to create their own directory
called `config`.  Prefix with some underscores for uniqueness.
2015-11-17 11:22:01 -05:00
Edward Thomson
fe96374823 tests: set PROGRAMDATA directory for running tests 2015-11-17 08:47:26 -05:00
Edward Thomson
6f7c411834 config::global: use PROGRAMDATA configuration
Query the `GIT_CONFIG_LEVEL_PROGRAMDATA` location when setting it up
for tests, in case the test runner has sandboxed it.
2015-11-17 08:46:21 -05:00
Edward Thomson
5f32c50683 racy: make git_index_read_index handle raciness
Ensure that `git_index_read_index` clears the uptodate bit on
files that it modifies.

Further, do not propagate the cache from an on-disk index into
another on-disk index.  Although this should not be done, as
`git_index_read_index` is used to bring an in-memory index into
another index (that may or may not be on-disk), ensure that we do
not accidentally bring in these bits when misused.
2015-11-16 22:59:02 -05:00
Edward Thomson
c30051f0d0 racy: ensure git_index_read_tree clears uptodate
Ensure that `git_index_read_tree` clears the uptodate bit on files
that it modifies.
2015-11-16 22:59:01 -05:00
Edward Thomson
956f4da897 index: test for smudged entries on write only
Test that entries are only smudged when we write the index: the
entry smudging is to prevent us from updating an index in a way
that it would be impossible to tell that an item was racy.
Consider when we load an index:  any entries that have the same
(or newer) timestamp than the index itself are considered racy,
and are subject to further scrutiny.

If we *save* that index with the same entries that we loaded,
then the index would now have a newer timestamp than the entries,
and they would no longer be given that additional scrutiny, failing
our racy detection!  So test that we smudge those entries only on
writing the new index, but that we can detect them (in diff) without
having to write.
2015-11-16 22:58:59 -05:00
Edward Thomson
de999f260f checkout::crlf test: don't crash when no idx entry
When there's no matching index entry (for whatever reason), don't
try to dereference the null return value to get at the id.

Otherwise when we break something in the index API, the checkout
test crashes for confusing reasons and causes us to step through
it in a debugger thinking that we had broken much more than we
actually did.
2015-11-16 22:58:59 -05:00
Edward Thomson
d1101263f7 index: don't detect raciness in uptodate entries
Keep track of entries that we believe are up-to-date, because we
added the index entries since the index was loaded.  This prevents
us from unnecessarily examining files that we wrote during the
cleanup of racy entries (when we smudge racily clean files that have
a timestamp newer than or equal to the index's timestamp when we
read it).  Without keeping track of this, we would examine every
file that we just checked out for raciness, since all their timestamps
would be newer than the index's timestamp.
2015-11-16 22:58:58 -05:00
Vicent Marti
7ff7ca623e pool: Never return unaligned buffers 2015-11-13 04:57:19 +01:00
Carlos Martín Nieto
75a0ccf52f Merge pull request #3170 from CmdrMoozy/nsec_fix
git_index_entry__init_from_stat: set nsec fields in entry stats
2015-11-12 19:53:09 +01:00
Carlos Martín Nieto
2c26c8679f Merge pull request #3499 from ethomson/ref_dir_errmsgs
Improve error messages when dirs prevent ref/reflog creation
2015-11-12 19:22:31 +01:00
Carlos Martín Nieto
ecdc04287a Merge pull request #3448 from libgit2/cmn/custom-agent
Support setting custom user-agent
2015-11-12 19:20:36 +01:00
Carlos Martín Nieto
de870533e0 settings: add a setter for a custom user-agent 2015-11-12 17:18:42 +01:00
Edward Thomson
0a700ee368 reflog: error when a directory is at reflog path
When a non-empty directory exists and prevents the creation of a
reflog, provide a more informative error message.
2015-11-12 09:39:29 -05:00
Edward Thomson
b46c7ee5e2 refs: complain when a directory exists at ref
When a (non-empty) directory exists at the reference target
location, complain with a more actionable error message.
2015-11-12 09:35:51 -05:00
nulltoken
1314af8d63 Failing test for case sensitive conflicts in the index 2015-11-12 12:11:45 +01:00
Carlos Martín Nieto
1c34b717e0 Merge pull request #3498 from ethomson/windows_symlinks
Diff: Honor `core.symlinks=false` and fake symlinks
2015-11-08 05:10:18 +01:00
Carlos Martín Nieto
619488948b Merge pull request #3500 from ethomson/submodules_with_path
Handle submodules with paths in `git_submodule_update`
2015-11-08 04:54:55 +01:00
Edward Thomson
790012ce78 submodule: test updating a submodule w/ a path
Test that `git_submodule_update` can handle a submodule that is
freshly cloned and has a path differing from its name.
2015-11-04 16:53:41 -05:00
Edward Thomson
5aa28a8f2d Merge pull request #3465 from libgit2/cmn/tls-register
stream: allow registering a user-provided TLS constructor
2015-11-04 14:16:24 -05:00
Stjepan Rajko
f5f96a23ee Fix git_commit_summary to convert newlines to spaces even after
whitespace.  Collapse spaces around newlines for the summary.
2015-11-03 17:50:55 -05:00
Edward Thomson
ec50b23acc filebuf: detect directories in our way
When creating a filebuf, detect a directory that exists in our
target file location.  This prevents a failure later, when we try
to move the lock file to the destination.
2015-11-03 17:16:51 -05:00
Edward Thomson
2d556f3166 reflog: test reflog is deleted when ref is deleted 2015-11-03 14:48:31 -05:00
Edward Thomson
6cc5023bfd index: test that add_bypath preserves symlinks
Test that on platforms without `core.symlinks`, we preserve symlinks
in `git_index_add_bypath`.  (Users should correct the actual index
entry's mode to change a link to a regular file.)
2015-11-03 12:07:03 -05:00
Edward Thomson
f20480ab0c diff: test "symlinks" in wd are respected on win32
When `core.symlinks = false`, we write the symlinks content (target)
to a regular file.  We should ensure that when we later see that
regular file, we treat it specially - and that changing that regular
file would actually change the symlink target.  (For compatibility
with Git for Windows).
2015-11-03 12:06:43 -05:00
Carlos Martín Nieto
3ce6cd4bdc Merge pull request #3494 from leoyanggit/fix_unit_test_build
Fix build for unit test
2015-11-03 08:13:41 -08:00
Carlos Martín Nieto
7fafde6325 stream: allow registering a user-provided TLS constructor
This allows the application to use their own TLS stream, regardless of
the capabilities of libgit2 itself.
2015-11-03 08:10:29 -08:00
Jason Haslam
3138ad9366 Add diff progress callback. 2015-11-02 16:33:58 -05:00
Leo Yang
505e4531b7 Fix build for unit test
If none of GIT_OPENSSL, GIT_WINHTTP or GIT_SECURE_TRANSPORT
is defined we should also be able to build the unit test.
2015-11-02 16:19:25 -05:00
Edward Thomson
db1edf91e9 Merge pull request #3491 from libgit2/cmn/config-checksum
Use checksums to detect config file changes
2015-11-02 15:09:19 -05:00
Vicent Marti
b656e5eb4f merge: Fix memory leak in test 2015-11-02 13:47:04 +01:00
Vicent Marti
85196232e8 Add test case 2015-11-02 13:47:04 +01:00
Carlos Martín Nieto
a2f96479ab config: add failing test for an external modification
We currently use the timestamp in order to decide whether a config file
has changed since we last read it.

This scheme falls down if the file is written twice within the same
second, as we fail to detect the file change after the first read in
that second.
2015-10-30 19:49:34 +01:00
Carlos Martín Nieto
fd74bd0842 Merge pull request #3486 from srajko/reflog-segfault-fix
Fix segfault when reading reflog with extra newlines
2015-10-29 20:37:48 +01:00
Stjepan Rajko
335c9e2f45 Prevent segfault when parsing a reflog with oid parse error
Using calloc instead of malloc because the parse error will lead to an immediate free of committer (and its properties, which can segfault on free if undefined - test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_returns_error segfaulted before the fix).

#3458
2015-10-29 11:15:37 -07:00
Vicent Marti
66eb7660a8 pool: Handle 32 bit systems 2015-10-28 10:29:00 +01:00
Vicent Marti
1e5e02b4f4 pool: Simplify implementation 2015-10-28 10:13:13 +01:00
Edward Thomson
8683d31f08 merge: add GIT_MERGE_TREE_FAIL_ON_CONFLICT
Provide a new merge option, GIT_MERGE_TREE_FAIL_ON_CONFLICT, which
will stop on the first conflict and fail the merge operation with
GIT_EMERGECONFLICT.
2015-10-22 14:55:17 -04:00
Carlos Martín Nieto
dc2cf3eb1a Merge pull request #3480 from ethomson/nsecs
Nanoseconds in the index: ignore for diffing
2015-10-22 18:35:43 +02:00
Edward Thomson
99a09f7f18 index: test that we round-trip nsecs
Test that nanoseconds are round-tripped correctly when we read
an index file that contains them.  We should, however, ignore them
because we don't understand them, and any new entries in the index
should contain a `0` nsecs field, while existing preserving entries.
2015-10-22 09:29:40 -04:00
Edward Thomson
44b1e3e390 Merge pull request #3475 from libgit2/cmn/programdata-config
config: add a ProgramData level
2015-10-21 13:43:22 -07:00
Carlos Martín Nieto
8c7c5fa585 config: add a ProgramData level
This is where portable git stores the global configuration which we can
use to adhere to it even though git isn't quite installed on the system.
2015-10-21 15:11:18 +02:00
Vicent Marti
bbe1957b8c tests: Fix warnings 2015-10-21 12:09:29 +02:00
Vicent Marti
307c4a2b6d signature: Strip crud just like Git does 2015-10-21 11:58:44 +02:00
Edward Thomson
4280fabb9f Merge pull request #3466 from libgit2/cmn/quick-parse-64
revwalk: make commit list use 64 bits for time
2015-10-15 07:10:48 -07:00
Carlos Martín Nieto
8321596a49 Merge pull request #3444 from ethomson/add_preserves_conflict_mode
Preserve modes from a conflict in `git_index_insert`
2015-10-15 12:22:10 +02:00
Vicent Marti
a0a1b19ab0 odb: Prioritize alternate backends
For most real use cases, repositories with alternates use them as main
object storage. Checking the alternate for objects before the main
repository should result in measurable speedups.

Because of this, we're changing the sorting algorithm to prioritize
alternates *in cases where two backends have the same priority*. This
means that the pack backend for the alternate will be checked before the
pack backend for the main repository *but* both of them will be checked
before any loose backends.
2015-10-14 20:53:01 +02:00
Carlos Martín Nieto
5ffdea6f65 revwalk: make commit list use 64 bits for time
We moved the "main" parsing to use 64 bits for the timestamp, but the
quick parsing for the revwalk did not. This means that for large
timestamps we fail to parse the time and thus the walk.

Move this parser to use 64 bits as well.
2015-10-14 16:54:13 +02:00
Edward Thomson
6c014bcc54 diff: don't feed large files to xdiff 2015-10-05 22:59:50 +02:00