Instead of trying to use the same functions by looking them up at startup, rely
on the linker to give us the right functions and simply define away the `git_`
prefix.
This should let us work with both compile-time and run-time linking, though it
introduces a lot of conditional compilation.
We cannot rely on the handle being `NULL` since `RTLD_DEFAULT` happens to have
the same value on many architectures. Keep a new variable to tell us whether
we think libssh2 has been loaded.
There is no end to the variation in the way people decide to package their
applications, and there seems to be no larger variety than in the way they
decide to deal with libssh2.
Re-introduce looking for the library at compile time, while adding the
USE_SSH_RUNTIME flag to enable detection at runtime.
The `LoadLibrary` function returns a `FARPROC` which MSVC won't convert on its
own to our function signatures. Add a void pointer cast to silence that warning.
While we can use the `typeof` extension with GCC and Clang, this is not
available on MSVC and its equivalent `decltype` is only available for C++.
As we must do this for MSVC, let's do it for all implementations.
Part of the point of this is being able to load libssh2 regardless of whether
it was available upon building, as the resulting shared object might move.
Make USE_SSH mean to try to load it at runtime. We still need to know the
signatures of the functions for our macros to work, so include a copy of the
header as a vendored dependency.
Don't compute the sha-1 in `git_futils_readbuffer_updated` unless the
checksum was requested. This means that `git_futils_readbuffer` will
not calculate the checksum unnecessarily.
An untracked file in a submodule should not prevent a rebase from
starting. Even if the submodule's SHA is changed, and that file would
conflict with a new tracked file, it's still OK to start the rebase
and discover the conflict later.
Signed-off-by: David Turner <dturner@twosigma.com>
Fixes a regression from #4092. This is a crash on 32-bit and I assume that
it doesn't do the right thing on 64-bit either. MSVC emits a warning for this,
but of course, it's easy to get lost among all of the similar 'possible loss
of data' warnings.
Provide a descriptive error message when compiling THREADSAFE on gcc
versions < 4.1. We require the atomic primitives (eg
`__sync_synchronize`) that were introduced in that version.
(Note, clang setes `__GNUC__` but appears to set its version > 4.1.)
Remove useless indirection from `git_attr_cache__init` to
`git_attr_cache__do_init`. The difference is that the
`git_attr_cache__init` macro first checks if the cache is already
initialized and, if so, not call `git_attr_cache__do_init`. But
actually, `git_attr_cache__do_init` already does the same thing and
returns immediately if the cache is already initialized.
Remove the indirection.
When doing an upsert of a file, we used to use `git__compare_and_swap`,
comparing the entry's file which is to be replaced with itself. This can
be more easily formulated by using `git__swap`, which unconditionally
replaces the value.
`snprintf` requires a _format_ but does not require _arguments_ to the
format. eg: `snprintf(buf, 42, "hi")` is perfectly legal. Expand the
macro to match.
Without this, `p_sprintf(buf, 42, "hi")` errors with:
```
error: expected expression
p_snprintf(msg, 42, "hi");
^
src/unix/posix.h:53:34: note: expanded from macro 'p_snprintf'
^
/usr/include/secure/_stdio.h:57:73: note: expanded from macro 'snprintf'
__builtin___snprintf_chk (str, len, 0, __darwin_obsz(str),
__VA_ARGS__)
```