This changes the get_entry() method to return a refcounted version of
the config entry, which you have to free when you're done.
This allows us to avoid freeing the memory in which the entry is stored
on a refresh, which may happen at any time for a live config.
For this reason, get_string() has been forbidden on live configs and a
new function get_string_buf() has been added, which stores the string in
a git_buf which the user then owns.
The functions which parse the string value takea advantage of the
borrowing to parse safely and then release the entry.
The user may decide to return any type of credential, including ones we
did not say we support. Add a check to make sure the user returned an
object of the right type and error out if not.
repository: remove log message override for switching the active branch
We want to use the "checkout: moving from ..." message in order to let
git know when a change of branch has happened. Make the convenience
functions for this goal write this message.
The signature for the reflog is not something which changes
dynamically. Almost all uses will be NULL, since we want for the
repository's default identity to be used, making it noise.
In order to allow for changing the identity, we instead provide
git_repository_set_ident() and git_repository_ident() which allow a user
to override the choice of signature.
Edward Thomson [Mon, 2 Mar 2015 15:35:26 +0000 (10:35 -0500)]
win32: add the patch level to the .dll fileversion
Win32 DLLs have four fields for the version number (major, minor,
teeny, patch). If a consumer wants to build a custom DLL, it may
be useful to set the patchlevel version number in the DLL.
This value only affects the DLL version number, it does not affect
the resultant "version number", which remains major.minor.teeny.
Aki Koskinen [Fri, 27 Feb 2015 08:49:02 +0000 (10:49 +0200)]
Include openssl headers last
Windows headers #define some names that openssl uses too. Openssl
headers #undef the offending names before reusing them. But if those
offending Windows headers get included after the openssl headers the
namespace is polluted and nothing good happens.
Edward Thomson [Sat, 14 Feb 2015 15:33:06 +0000 (10:33 -0500)]
checkout: upgrade to `SAFE_CREATE` when no index file
When the repository does not contain an index, emulate git's behavior
and upgrade to `SAFE_CREATE`. This allows us to check out repositories
created with `git clone --no-checkout`.
Edward Thomson [Thu, 19 Feb 2015 17:14:06 +0000 (12:14 -0500)]
tests: separate INVASIVE filesystem tests
Introduce GITTEST_INVASIVE_FS_STRUCTURE for things that are invasive
to your filesystem structure (like creating folders at your filesystem
root) and GITTEST_INVASIVE_FS_SIZE for things that write lots of data.
Edward Thomson [Thu, 19 Feb 2015 15:05:33 +0000 (10:05 -0500)]
buffer: introduce git_buf_attach_notowned
Provide a convenience function that creates a buffer that can be provided
to callers but will not be freed via `git_buf_free`, so the buffer
creator maintains the allocation lifecycle of the buffer's contents.
Leo Yang [Fri, 13 Feb 2015 22:28:35 +0000 (17:28 -0500)]
Fix Mac build without OpenSSL
If OpenSSL is disabled on Mac the SHA1 implementation goes
to the CommonCrypto from the system. In this case we should
not include the generic hash impl. Otherwise there would be
duplicated impls which fail the build.
Edward Thomson [Thu, 22 Jan 2015 22:10:06 +0000 (16:10 -0600)]
filters: introduce streaming filters
Add structures and preliminary functions to take a buffer, file or
blob and write the contents in chunks through an arbitrary number
of chained filters, finally writing into a user-provided function
accept the contents.
Jason Haslam [Sun, 15 Feb 2015 06:43:26 +0000 (23:43 -0700)]
Fix race in git_packfile_unpack.
Increment refcount of newly added cache entries just like existing
entries looked up from the cache. Otherwise the new entry can be
evicted from the cache and destroyed while it's still in use.
Edward Thomson [Sun, 18 Jan 2015 05:28:53 +0000 (23:28 -0600)]
merge: lock the index at the start of the merge
Always lock the index when we begin the merge, before we write
any of the metdata files. This prevents a race where another
client may run a commit after we have written the MERGE_HEAD but
before we have updated the index, which will produce a merge
commit that is treesame to one parent. The merge will finish and
update the index and the resultant commit would not be a merge at
all.
Edward Thomson [Sun, 18 Jan 2015 02:49:04 +0000 (20:49 -0600)]
git_indexwriter: lock then write the index
Introduce `git_indexwriter`, to allow us to lock the index while
performing additional operations, then complete the write (or abort,
unlocking the index).
Edward Thomson [Sun, 18 Jan 2015 05:31:24 +0000 (23:31 -0600)]
merge test: test an actual failure, not conflict
Correct the merge failed cleanup test. Merge data should not be
cleaned up on conflicts, only on actual failure. And ORIG_HEAD
should not be removed at all.
Edward Thomson [Thu, 12 Feb 2015 17:19:37 +0000 (12:19 -0500)]
Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that
we can substitute it out with the compiler instrinsics on platforms
that support it. This means dropping the ability to pass `NULL` as
an out parameter.
As a result, the macros also get updated to reflect this as well.
Edward Thomson [Fri, 13 Feb 2015 14:18:49 +0000 (09:18 -0500)]
win32: limit the mode to `_wopen`/`_waccess`
Win32 generally ignores Unix-like mode bits that don't make any
sense on the platform (eg `0644` makes no sense to Windows). But
WINE complains loudly when presented with POSIXy bits. Remove them.
Edward Thomson [Wed, 11 Feb 2015 16:20:05 +0000 (11:20 -0500)]
Use `size_t` to hold size of arrays
Use `size_t` to hold the size of arrays to ease overflow checking,
lest we check for overflow of a `size_t` then promptly truncate
by packing the length into a smaller type.
Edward Thomson [Wed, 11 Feb 2015 04:13:49 +0000 (23:13 -0500)]
git__*allocarray: safer realloc and malloc
Introduce git__reallocarray that checks the product of the number
of elements and element size for overflow before allocation. Also
introduce git__mallocarray that behaves like calloc, but without the
`c`. (It does not zero memory, for those truly worried about every
cycle.)
Reinit `reader` pointer after reading included config file
Fixes #2869. If included file includes more files, it may reallocate
cfg_file->readers, hence invalidate not only `r` pointer, but `result`
pointer as well.
It fails at least on my computer, though it may depend on some unpredictable
factors (say, will realloc() extend the memory segment in place, or it will
allocate new memory).