Edward Thomson [Wed, 4 Nov 2015 21:17:51 +0000 (16:17 -0500)]
submodule: reload HEAD/index after reading config
Reload the HEAD and index data for a submodule after reading the
configuration. The configuration may specify a `path`, so we must
update HEAD and index data with that path in mind.
Edward Thomson [Tue, 3 Nov 2015 16:27:31 +0000 (11:27 -0500)]
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.)
Edward Thomson [Tue, 3 Nov 2015 14:43:18 +0000 (09:43 -0500)]
diff: on win32, treat fake "symlinks" specially
On platforms that lack `core.symlinks`, we should not go looking for
symbolic links and `p_readlink` their target. Instead, we should
examine the file's contents.
Edward Thomson [Tue, 3 Nov 2015 14:40:30 +0000 (09:40 -0500)]
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).
This reduces the chances of a crash in the thread tests. This shouldn't
affect general usage too much, since the main usage of these functions
are to read into an empty buffer.
Instead of relying on the size and timestamp, which can hide changes
performed in the same second, hash the file content's when we care about
detecting changes.
Stjepan Rajko [Mon, 26 Oct 2015 22:33:00 +0000 (15:33 -0700)]
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).
Vicent Marti [Tue, 27 Oct 2015 21:17:32 +0000 (22:17 +0100)]
reuc: Be smarter when inserting new REUC entries
Inserting new REUC entries can quickly become pathological given that
each insert unsorts the REUC vector, and both subsequent lookups *and*
insertions will require sorting it again before being successful.
To avoid this, we're switching to `git_vector_insert_sorted`: this keeps
the REUC vector constantly sorted and lets us use the `on_dup` callback
to skip an extra binary search on each insertion.
Edward Thomson [Fri, 23 Oct 2015 01:17:19 +0000 (20:17 -0500)]
cmake: split sources into original paths for Xcode and MSVC
The MSVC_SPLIT_SOURCES function is helpful for other IDEs, like Xcode,
and will split the source files up into their target directories,
instead of merely placing them all in a "Sources" directory.
Rename MSVC_SPLIT_SOURCES to IDE_SPLIT_SOURCES and enable it for Xcode.
Edward Thomson [Thu, 22 Oct 2015 18:39:20 +0000 (14:39 -0400)]
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.
Edward Thomson [Thu, 22 Oct 2015 14:29:51 +0000 (10:29 -0400)]
xdiff: reference util.h in parent directory
Although CMake will correctly configure include directories for us,
some people may use their own build system, and we should reference
`util.h` based on where it actually lives.
Edward Thomson [Thu, 22 Oct 2015 13:30:41 +0000 (09:30 -0400)]
diff: ignore nsecs when diffing
Although our index contains the literal time present in the index,
we do not read nanoseconds from disk, and thus we should not use
them in any comparisons, lest we always think our working directory
is dirty.
Guard this behind a `GIT_USE_NSECS` for future improvement.
Edward Thomson [Thu, 22 Oct 2015 13:29:40 +0000 (09:29 -0400)]
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.
Linquize [Wed, 21 Oct 2015 23:56:34 +0000 (07:56 +0800)]
inttypes.h is built-in header file since MSVC 2013
The reason is that the types defined in libgit2's inttypes.h collide with system inttypes.h
3rd party library header files may directly reference MSVC's built-in inttypes.h
Vicent Marti [Wed, 14 Oct 2015 17:31:54 +0000 (19:31 +0200)]
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.
Vicent Marti [Wed, 14 Oct 2015 17:24:07 +0000 (19:24 +0200)]
odb: Be smarter when refreshing backends
In the current implementation of ODB backends, each backend is tasked
with refreshing itself after a failed lookup. This is standard Git
behavior: we want to e.g. reload the packfiles on disk in case they have
changed and that's the reason we can't find the object we're looking
for.
This behavior, however, becomes pathological in repositories where
multiple alternates have been loaded. Given that each alternate counts
as a separate backend, a miss in the main repository (which can
potentially be very frequent in cases where object storage comes from
the alternate) will result in refreshing all its packfiles before we
move on to the alternate backend where the object will most likely be
found.
To fix this, the code in `odb.c` has been refactored as to perform the
refresh of all the backends externally, once we've verified that the
object is nowhere to be found.
If the refresh is successful, we then perform the lookup sequentially
through all the backends, skipping the ones that we know for sure
weren't refreshed (because they have no refresh API).
The on-disk pack backend has been adjusted accordingly: it no longer
performs refreshes internally.
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.
Arthur Schreiber [Wed, 30 Sep 2015 22:50:37 +0000 (00:50 +0200)]
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.
Edward Thomson [Tue, 29 Sep 2015 19:49:16 +0000 (15:49 -0400)]
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.
openssl: don't try to teardown an unconnected SSL context
SSL_shutdown() does not like it when we pass an unitialized ssl context
to it. This means that when we fail to connect to a host, we hide the
error message saying so with OpenSSL's indecipherable error message.