Commit Graph

1970 Commits

Author SHA1 Message Date
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
Edward Thomson
e43520660c merge_file: treat large files as binary
xdiff craps the bed on large files.  Treat very large files as binary,
so that it doesn't even have to try.

Refactor our merge binary handling to better match git.git, which
looks for a NUL in the first 8000 bytes.
2015-10-05 22:59:46 +02:00
Axel Rasmussen
c7b17fb5cd Merge branch 'master' into nsec_fix_next 2015-10-01 18:01:32 -07:00
Arthur Schreiber
d3b29fb94b refdb and odb backends must provide free function
As refdb and odb backends can be allocated by client code, libgit2
can’t know whether an alternative memory allocator was used, and thus
should not try to call `git__free` on those objects.

Instead, odb and refdb backend implementations must always provide
their own `free` functions to ensure memory gets freed correctly.
2015-10-01 00:50:37 +02:00
Edward Thomson
21515f228b index: also try conflict mode when inserting
When we do not trust the on-disk mode, we use the mode of an existing
index entry.  This allows us to preserve executable bits on platforms
that do not honor them on the filesystem.

If there is no stage 0 index entry, also look at conflicts to attempt
to answer this question:  prefer the data from the 'ours' side, then
the 'theirs' side before falling back to the common ancestor.
2015-09-30 09:06:09 -04:00
Carlos Martín Nieto
72b7c57093 Merge pull request #3411 from spraints/custom-push-headers
Include custom HTTP headers
2015-09-30 09:17:18 +02:00
Edward Thomson
10df661b8c index: test that add_bypath preserves mode 2015-09-29 14:16:51 -04:00
Edward Thomson
ea467e7487 win32::longpath: don't print path 2015-09-28 16:46:09 -04:00
Edward Thomson
fc3ef147ec Merge pull request #3441 from libgit2/cmn/badssl
net: add tests against badssl.com
2015-09-28 06:41:00 -07:00
Carlos Martín Nieto
5c5df666b0 Plug some leaks 2015-09-27 23:32:20 +02:00
Carlos Martín Nieto
53a2870514 net: add tests against badssl.com
These provide bad X.509 certificates, which we should refuse to connect
to by default.
2015-09-27 22:56:25 +02:00
Guille -bisho-
e4b2b919bb Fix binary diffs
git expects an empty line after the binary data:

literal X
...binary data...
<empty_line>

The last literal block of the generated patches were not containing the required empty line. Example:

	diff --git a/binary_file b/binary_file
	index 3f1b3f9098131cfecea4a50ff8afab349ea66d22..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644
	GIT binary patch
	literal 8
	Pc${NM&PdElPvrst3ey5{

	literal 6
	Nc${NM%g@i}0ssZ|0lokL
	diff --git a/binary_file2 b/binary_file2
	index 31be99be19470da4af5b28b21e27896a2f2f9ee2..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644
	GIT binary patch
	literal 8
	Pc${NM&PdElPvrst3ey5{

	literal 13
	Sc${NMEKbZyOexL+Qd|HZV+4u-

git apply of that diff results in:

	error: corrupt binary patch at line 9: diff --git a/binary_file2 b/binary_file2
	fatal: patch with only garbage at line 10

The proper formating is:

	diff --git a/binary_file b/binary_file
	index 3f1b3f9098131cfecea4a50ff8afab349ea66d22..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644
	GIT binary patch
	literal 8
	Pc${NM&PdElPvrst3ey5{

	literal 6
	Nc${NM%g@i}0ssZ|0lokL
	diff --git a/binary_file2 b/binary_file2
	index 31be99be19470da4af5b28b21e27896a2f2f9ee2..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644
	GIT binary patch
	literal 8
	Pc${NM&PdElPvrst3ey5{

	literal 13
	Sc${NMEKbZyOexL+Qd|HZV+4u-
2015-09-25 10:37:41 -07:00
Edward Thomson
9768ebb1f3 win32: test checkout msg on long path err 2015-09-23 08:27:24 -04:00
Carlos Martín Nieto
aebddbe736 Merge pull request #3434 from ethomson/reservednames
Win32 Reserved names: don't reserve names outside the working directory
2015-09-21 06:01:03 +02:00
Axel Rasmussen
0226f7dd36 diff/index: respect USE_NSEC for racily clean file detection 2015-09-18 23:33:56 -07:00
Axel Rasmussen
e9e6df2c8f cmake: Only provide USE_NSEC if struct stat members are avilable.
This allows us to remove OS checks from source code, instead relying
on CMake to detect whether or not `struct stat` has the nanoseconds
members we rely on.
2015-09-18 23:33:56 -07:00
Axel Rasmussen
2be7855727 caps: add test for GIT_FEATURES_NSEC 2015-09-18 23:33:56 -07:00
Axel Rasmussen
e7de893ef8 cmake: add USE_NSEC, and only check nanosec m/ctime if enabled 2015-09-18 23:33:55 -07:00
Edward Thomson
e8ddd8d76c repo::reservedname: test a submodule update
Test an initial submodule update, where we are trying to checkout
the submodule for the first time, and placing a file within the
submodule working directory with the same name as the submodule
(and consequently, the same name as the repository itself).
2015-09-18 12:17:49 -04:00
Linquize
08313c4b12 config: test that comments are left as with git 2015-09-18 12:09:33 +02:00
Carlos Martín Nieto
dfe2856d0f Fix a couple of warnings 2015-09-18 12:06:55 +02:00
Edward Thomson
e24c60dba4 mkdir: find component paths for mkdir_relative
`git_futils_mkdir` does not blindly call `git_futils_mkdir_relative`.

`git_futils_mkdir_relative` is used when you have some base directory
and want to create some path inside of it, potentially removing blocking
symlinks and files in the process.  This is not suitable for a general
recursive mkdir within the filesystem.

Instead, when `mkdir` is being recursive, locate the first existent
parent directory and use that as the base for `mkdir_relative`.
2015-09-17 10:11:56 -04:00
Edward Thomson
0862ec2eb9 core::mkdir tests: ensure we don't stomp symlinks in mkdir
In `mkdir` and `mkdir_r`, ensure that we don't try to remove symlinks
that are in our way.
2015-09-17 10:11:38 -04:00
Edward Thomson
08df66301e core::mkdir tests: include absolute mkdirs 2015-09-17 10:00:35 -04:00
Edward Thomson
ac2fba0ecd git_futils_mkdir_*: make a relative-to-base mkdir
Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter
assumes that we own everything beneath the base, as if it were
being called with a base of the repository or working directory,
and is tailored towards checkout and ensuring that there is no
bogosity beneath the base that must be cleaned up.

This is (at best) slow and (at worst) unsafe in the larger context
of a filesystem where we do not own things and cannot do things like
unlink symlinks that are in our way.
2015-09-17 10:00:35 -04:00
Edward Thomson
eea7c85024 checkout: overwrite files with differing modes
When a file exists on disk and we're checking out a file that differs
in executableness, remove the old file.  This allows us to recreate the
new file with p_open, which will take the new mode into account and
handle setting the umask properly.

Remove any notion of chmod'ing existing files, since it is now handled
by the aforementioned removal and was incorrect, as it did not take
umask into account.
2015-09-16 10:33:59 -04:00
Edward Thomson
6fe322843b checkout::tree tests: don't use hardcoded mode 2015-09-16 10:33:53 -04:00
Edward Thomson
b4d183a77a checkout::tree tests: don't use static buffer 2015-09-16 04:12:47 +00:00
Matti Virolainen
33cad99589 Check that checkout preserves filemode in working directory. 2015-09-16 04:07:48 +00:00
Matti Virolainen
6124d983b6 Check that an executable in index is not an executable after checkout. 2015-09-16 04:07:43 +00:00
Edward Thomson
8452fecc8f cl_git_path_url: assert sane static buffer size 2015-09-14 14:05:01 -04:00
Edward Thomson
4cc355c97b clone::nonetwork: don't use fixed size buffer 2015-09-14 13:58:38 -04:00
Carlos Martín Nieto
b0885675f7 Merge pull request #3425 from ethomson/diriter_root
Handle `git_path_diriter` instances at the drive root on Windows
2015-09-13 23:21:14 +02:00
Edward Thomson
2cde210d47 diriter: test we can iterate root
Ensure that we can iterate the filesystem root and that paths come
back well-formed, not with an additional '/'.  (eg, when iterating
`c:/`, expect that we do not get some path like `c://autoexec.bat`).
2015-09-13 13:52:23 -04:00
Carlos Martín Nieto
f2b25261cf Merge pull request #3423 from libgit2/cmn/push-tests-inline-oid
push: put the git_oid inline in the test structure
2015-09-13 19:43:55 +02:00
Arthur Schreiber
548cb33434 Don't free config in git_transaction_commit.
The config is not owned by the transaction, so please don’t free it.
2015-09-13 16:32:24 +02:00
Carlos Martín Nieto
1e80bf27ea Merge branch 'cmn/ignore-dir-check' 2015-09-13 06:21:18 +02:00
Carlos Martín Nieto
657afd359e ignore: add test and adjust style and comment for dir with wildmatch
The previous commit left the comment referencing the earlier state of
the code, change it to explain the current logic. While here, change the
logic to avoid repeating the copy of the base pattern.
2015-09-13 06:18:49 +02:00
Carlos Martín Nieto
305407e1bb Merge pull request #3370 from libgit2/cmn/submodule-refactor
submodule: refactor to be more explicit in the search
2015-09-13 06:03:12 +02:00
Carlos Martín Nieto
1af5aecb96 push: put the git_oid inline in the test structure
These are small pieces of data, so there is no advantage to allocating
them separately. Include the two ids inline in the struct we use to
check that the expected and actual ids match.
2015-09-13 05:38:29 +02:00
Edward Thomson
92f7d32b59 diff::workdir: ensure ignored files are not returned
Ensure that a diff with the workdir is not erroneously returning
directories.
2015-09-12 13:46:22 -04:00
Carlos Martín Nieto
a3b9731ff8 submodule: add a test for a renamed submdoule dir 2015-09-10 21:23:03 +02:00
Matt Burke
3245896bb7 Add a test for custom header validation
Also, *some* custom headers actually are valid.
2015-09-10 13:18:26 -04:00
Edward Thomson
8e736a73ca futils: ensure we can write a hidden file 2015-09-08 15:56:50 -04:00
Edward Thomson
ea3f2c296a filebuf: ensure we can lock a hidden file 2015-09-08 15:56:35 -04:00
Matt Burke
4f2b6093a6 Tell the git_transport about the custom_headers 2015-09-08 14:02:33 -04:00
Carlos Martín Nieto
6d6020defc Merge pull request #3353 from ethomson/wrongcase_add
index: canonicalize directory case when adding
2015-09-08 18:34:51 +02:00
Edward Thomson
2964cbeae1 Merge pull request #3381 from leoyanggit/index_directory_iterator
New feature: add the ablility to iterate through a directory in index
2015-09-08 11:50:08 -04:00
Edward Thomson
a32bc85e84 git_index_add: allow case changing renames
On case insensitive platforms, allow `git_index_add` to provide a new
path for an existing index entry.  Previously, we would maintain the
case in an index entry without the ability to change it (except by
removing an entry and re-adding it.)

Higher-level functions (like `git_index_add_bypath` and
`git_index_add_frombuffers`) continue to keep the old path for easier
usage.
2015-09-08 11:34:00 -04:00
Edward Thomson
280adb3f94 index: canonicalize directory case when adding
On case insensitive systems, when given a user-provided path in the
higher-level index addition functions (eg `git_index_add_bypath` /
`git_index_add_frombuffer`), examine the index to try to match the
given path to an existing directory.

Various mechanisms can cause the on-disk representation of a folder
to not match the representation in HEAD or the index - for example,
a case changing rename of some file `a/file.txt` to `A/file.txt`
will update the paths in the index, but not rename the folder on
disk.

If a user subsequently adds `a/other.txt`, then this should be stored
in the index as `A/other.txt`.
2015-09-08 11:32:40 -04:00
Edward Thomson
e1d27bcaaf Merge pull request #3413 from libgit2/cmn/follow-symlink
filebuf: follow symlinks when creating a lock file
2015-09-06 10:51:29 -04:00
Edward Thomson
9fd4c9c867 Merge pull request #3366 from libgit2/cmn/index-hashmap
Use a hashmap for path-based lookups in the index
2015-09-06 10:50:22 -04:00
Carlos Martín Nieto
d83b2e9f51 filebuf: follow symlinks when creating a lock file
We create a lockfile to update files under GIT_DIR. Sometimes these
files are actually located elsewhere and a symlink takes their place. In
that case we should lock and update the file at its final location
rather than overwrite the symlink.
2015-09-05 16:43:49 +02:00
Leo Yang
c097f7173d New API: git_index_find_prefix
Find the first index entry matching a prefix.
2015-09-04 12:24:36 -04:00
Carlos Martín Nieto
21e7015ca3 Merge pull request #3402 from ethomson/faster_diff
Provide path matching in the iterators (for faster diffs)
2015-09-01 02:26:11 +02:00
Edward Thomson
03210cfa00 iterator test: handle case (in)sensitivity 2015-08-31 12:16:16 -04:00
Edward Thomson
4d19bced3f iterator test: use new iter opts in fifo test 2015-08-31 11:48:12 -04:00
Edward Thomson
d53c888069 iterator: saner pathlist matching for idx iterator
Some nicer refactoring for index iteration walks.

The index iterator doesn't binary search through the pathlist space,
since it lacks directory entries, and would have to binary search
each index entry and all its parents (eg, when presented with an index
entry of `foo/bar/file.c`, you would have to look in the pathlist for
`foo/bar/file.c`, `foo/bar` and `foo`).  Since the index entries and the
pathlist are both nicely sorted, we walk the index entries in lockstep
with the pathlist like we do for other iteration/diff/merge walks.
2015-08-31 11:48:06 -04:00
Edward Thomson
71ef639e5f status test: brackets are now literal 2015-08-30 18:57:06 -04:00
Edward Thomson
1af84271dd tree_iterator: use a pathlist 2015-08-30 18:55:18 -04:00
Edward Thomson
4a0dbeb0d3 diff: use new iterator pathlist handling
When using literal pathspecs in diff with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`
turn on the faster iterator pathlist handling.

Updates iterator pathspecs to include directory prefixes (eg, `foo/`)
for compatibility with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`.
2015-08-30 17:06:26 -04:00
Edward Thomson
3273ab3f0b diff: better document GIT_DIFF_PATHSPEC_DISABLE
Document that `GIT_DIFF_PATHSPEC_DISABLE` is not necessarily about
explicit path matching, but also includes matching of directory
names.  Enforce this in a test.
2015-08-28 20:45:08 -04:00
Edward Thomson
aa06ecaf5b Merge pull request #3352 from ethomson/hidden
win32: ensure hidden files can be staged
2015-08-28 19:30:08 -04:00
Edward Thomson
6c9352bf30 iterator: sort subdirs properly with pathlist
When given a pathlist, don't assume that directories sort before
files.  Walk through any list of entries sorting before us to make
sure that we've exhausted all entries that *aren't* directories.

Eg, if we're searching for 'foo/bar', and we have a 'foo.c', keep
advancing the pathlist to keep looking for an entry prefixed with
'foo/'.
2015-08-28 18:40:02 -04:00
Edward Thomson
ef206124de Move filelist into the iterator handling itself. 2015-08-28 18:39:52 -04:00
Edward Thomson
ed1c64464a iterator: use an options struct instead of args 2015-08-28 18:39:47 -04:00
Carlos Martín Nieto
e451cd5c03 diff: don't error out on an invalid regex
When parsing user-provided regex patterns for functions, we must not
fail to provide a diff just because a pattern is not well
formed. Ignore it instead.
2015-08-15 18:46:38 +02:00
Carlos Martín Nieto
c232d6c32d index: add tests around case switching
We were missing tests for switching the case-sensitivity of an index
in-memory and then looking up entries in it.
2015-08-14 21:06:51 +02:00
Edward Thomson
9f1af7f279 Merge pull request #3168 from libgit2/cmn/config-tx
Locking and transactional/atomic updates for config
2015-08-13 10:22:50 -07:00
Carlos Martín Nieto
5340d63d38 config: perform unlocking via git_transaction
This makes the API for commiting or discarding changes the same as for
references.
2015-08-12 04:09:38 +02:00
Carlos Martín Nieto
36f784b538 config: expose locking via the main API
This lock/unlock pair allows for the cller to lock a configuration file
to avoid concurrent operations.

It also allows for a transactional approach to updating a configuration
file. If multiple updates must be made atomically, they can be done
while the config is locked.
2015-08-12 04:09:38 +02:00
Carlos Martín Nieto
b166703964 config: implement basic transactional support
When a configuration file is locked, any updates made to it will be done
to the in-memory copy of the file. This allows for multiple updates to
happen while we hold the lock, preventing races during complex
config-file manipulation.
2015-08-12 04:09:09 +02:00
Carlos Martín Nieto
a879276783 remote: add failing test for a mirror refspec
While we download the remote's remote-tracking branches, we don't
download the tag. This points to the tag auto-follow rules interfering
with the refspec.
2015-08-11 20:44:19 +02:00
Edward Thomson
ef4857c2b3 errors: tighten up git_error_state OOMs a bit more
When an error state is an OOM, make sure that we treat is specially
and do not try to free it.
2015-08-03 19:44:51 -04:00
Edward Thomson
bdec336301 win32: ensure hidden files can be staged 2015-08-03 18:33:15 -05:00
Michael Procter
988ea59443 Test: check restored oom error points to static buffer 2015-08-03 15:23:17 +01:00
Michael Procter
5ef4b86015 Add failing test for capture/restore oom error 2015-08-03 15:23:17 +01:00
Edward Thomson
69adb781e1 Merge pull request #3325 from libgit2/cmn/filebuf-rename-error
filebuf: remove lockfile upon rename errors
2015-08-03 08:33:53 -05:00
Carlos Martín Nieto
b426ac90a9 index: test that an unregistered submodule gets staged
When we pass the path of a repository to `_bypath()`, we should behave
like git and stage it as a `_COMMIT` regardless of whether it is
registered a a submodule.
2015-08-01 19:52:25 +02:00
Linquize
63e5b55122 index: add test for adding an old-style submodule to index 2015-08-01 19:35:59 +02:00
Edward Thomson
9d4b7d2524 Merge pull request #3328 from libgit2/cmn/iterator-skip-diriter
iterator: skip over errors in diriter init
2015-07-29 16:46:47 -05:00
Carlos Martín Nieto
0e391d8526 iterator: adjust unreadable-dir test to new behaviour
We don't want the iterator to make us stop whenever we hit an unreadable
dir. We should instead move over to the next item.
2015-07-27 13:31:06 +02:00
Carlos Martín Nieto
19d9beb7ff filebuf: remove lockfile upon rename errors
When we have an error renaming the lockfile, we need to make sure
that we remove it upon cleanup. For this, we need to keep track of
whether we opened the file and whether the rename succeeded.

If we did create the lockfile but the rename did not succeed, we
remove the lockfile. This won't protect against all errors, but
the most common ones (target file is open) does get handled.
2015-07-24 23:02:11 +02:00
Carlos Martín Nieto
668053befe filebuf: failing test for leaving the lockfile when failing to rename
When we fail to rename, we currently leave the lockfile laying
around. This shows that behaviour.
2015-07-24 22:55:43 +02:00
Edward Thomson
2dfd5eae33 Merge pull request #3307 from libgit2/cmn/submodule-backslash
Normalize submodule urls before looking at them
2015-07-24 15:05:16 -05:00
Edward Thomson
759b2230a5 Merge pull request #3303 from libgit2/cmn/index-add-submodule
Allow adding a submodule through git_index_add_bypath
2015-07-24 15:04:20 -05:00
Edward Thomson
91dad18143 Merge pull request #3305 from libgit2/cmn/reflog-del-backend
refdb: delete a ref's reflog upon deletion
2015-07-24 15:01:04 -05:00
Carlos Martín Nieto
ceb5873913 Merge pull request #3302 from libgit2/cmn/submodule-foreach-diff-path
List a submodule only once when the path matches a submodule in the index
2015-07-13 18:50:39 +02:00
Carlos Martín Nieto
aa51fa1e03 submodule: add failing test for backslash in url 2015-07-13 08:39:35 +02:00
Carlos Martín Nieto
f861abadfe Merge branch 'portable-zu' 2015-07-12 19:56:19 +02:00
Matthew Plough
768f8be31c Fix #3094 - improve use of portable size_t/ssize_t format specifiers.
The header src/cc-compat.h defines portable format specifiers PRIuZ, PRIdZ, and PRIxZ. The original report highlighted the need to use these specifiers in examples/network/fetch.c.  For this commit, I checked all C source and header files not in deps/ and transitioned to the appropriate format specifier where appropriate.
2015-07-12 19:55:19 +02:00
Carlos Martín Nieto
01d0c02dba refdb: delete a ref's reflog upon deletion
Removing a reflog upon ref deletion is something which only some
backends might wish to do. Backends which are database-backed may wish
to archive a reflog, log-based ones may not need to do anything.
2015-07-12 19:08:06 +02:00
Carlos Martín Nieto
247d27c2c6 index: allow add_bypath to update submodules
Similarly to how git itself does it, allow the index update operation to
stage a change in a submodule's HEAD.
2015-07-12 12:11:22 +02:00
Carlos Martín Nieto
0d98af0911 blob: fail to create a blob from a dir with EDIRECTORY
This also affects `git_index_add_bypath()` by providing a better error
message and a specific error code when a directory is passed.
2015-07-12 12:11:22 +02:00
Carlos Martín Nieto
a34c4f8dce submdule: reproduce double-reporting of a submodule in foreach
When we rename a submodule, we should be merging two sets of information
based on whether their path is the same. We currently only deduplicate
on equal name, which causes us to double-report.
2015-07-11 13:32:57 +02:00
Edward Thomson
9a99ca7b21 wildcard filters: move CHANGELOG message to 0.23+1 2015-07-10 09:53:30 -05:00
Edward Thomson
bae467aec4 wildcard filters: clean up some warnings in tests 2015-07-10 09:53:29 -05:00
Carlos Martín Nieto
9847d80ddc Merge pull request #3281 from ethomson/wildcard_filters
filters: custom filters with wildcard attributes
2015-07-09 18:21:31 +02:00
Edward Thomson
43ce8cb52e revert: correct test that added trailing newline 2015-07-07 17:01:49 -05:00
Edward Thomson
ae8f7260ec merge_files: don't add trailing newlines
When invoked with three files that each lack a trailing newline,
the merge result should also lack a trailing newline.
2015-07-07 17:01:48 -05:00
Carlos Martín Nieto
3704ac35d3 Merge pull request #3277 from git-up/git_diff_index_to_index
Added git_diff_index_to_index()
2015-07-07 12:38:47 +02:00