Commit Graph

15091 Commits

Author SHA1 Message Date
Fabio Alessandrelli
933c09dbec CMake: Search for ssh2 instead of libssh2.
Fixes "CMake Error: could not resolve ssh2" on Windows-MSVC.
2023-06-25 07:15:02 +02:00
Edward Thomson
f041a94e2c Merge branch 'worktree_prunable' (PR #5712) 2023-05-16 12:41:41 +01:00
Edward Thomson
12b54ae009 worktree: document that is_prunable sets error messages
When a worktree is not prunable, an error message will be set with
information about why. Document that.
2023-05-16 12:40:16 +01:00
Edward Thomson
372143244d worktree: update prunable to reflect refactorings
PR #5712 predates several refactorings to move the utility code into a
more general purpose codebase. Update to reflect the refactorings.
2023-05-16 12:38:43 +01:00
Reginald McLean
05719c55ff Refactor git_worktree_is_prunable slightly to fix memory leak 2023-05-16 12:32:35 +01:00
Reginald McLean
86db1ad5dc Added check if gitdir exists in is_prunable()
Fixes #5598
2023-05-16 12:31:46 +01:00
Reginald McLean
0fd80681f9 Added missing is_prunable test 2023-05-16 12:31:16 +01:00
Edward Thomson
9d41a3fd69 Merge pull request #6535 from libgit2/ethomson/timeouts 2023-05-13 17:11:56 +01:00
Edward Thomson
8f695c806b clone: skip timeout tests on WinHTTP 2023-05-13 16:42:04 +01:00
Edward Thomson
14c820b191 win32: use WSAGetLastError to determine blocking 2023-05-13 16:42:04 +01:00
Edward Thomson
03eebab8a9 win32: getsockopt takes a char * instead of a void *
Monsters.
2023-05-13 16:42:04 +01:00
Edward Thomson
02ab53ce05 cmake: use check_symbol_exists for rand functions
`check_symbol_exists` is superior to `check_function_exists`; use it
consistently in our cmake configuration
2023-05-13 16:42:04 +01:00
Edward Thomson
9908c076ab posix: use WSAPoll on win32 2023-05-13 16:42:04 +01:00
Edward Thomson
94f98400bf posix: introduce p_poll emulation with select
Not all systems have poll(2); emulate it with select(2).
2023-05-13 16:42:04 +01:00
Edward Thomson
fad9042897 streams: sockets are non-blocking and can timeout
Make socket I/O non-blocking and add optional timeouts.

Users may now set `GIT_OPT_SET_SERVER_CONNECT_TIMEOUT` to set a shorter
connection timeout. (The connect timeout cannot be longer than the
operating system default.) Users may also now configure the socket read
and write timeouts with `GIT_OPT_SET_SERVER_TIMEOUT`.

By default, connects still timeout based on the operating system
defaults (typically 75 seconds) and socket read and writes block.

Add a test against our custom testing git server that ensures that we
can timeout reads against a slow server.
2023-05-13 16:42:04 +01:00
Edward Thomson
933b04c219 ci: update to poxygit v0.6.0
v0.6.0 of poxygit add support for throttling connections to test
timeouts and low-bandwidth situations.
2023-05-13 16:42:04 +01:00
Edward Thomson
11c89c386c net: move gitno buffer to staticstr
The `gitno` buffer interface is another layer on top of socket reads.
Abstract it a bit into a "static string" that has `git_str` like
semantics but without heap allocation which moves the actual reading
logic into the socket / stream code, and allows for easier future usage
of a static / stack-allocated `git_str`-like interface.
2023-05-13 16:42:04 +01:00
Edward Thomson
6e4bbf222d net: move rfc2818 hostname / wildcard matching to util 2023-05-13 16:42:04 +01:00
Edward Thomson
dbe343b6e3 stransport: store error information
We lose some error information from the read / write callbacks to
stransport. Store our own error value in the object so that we can
ensure that we rely upon it.
2023-05-13 16:42:04 +01:00
Edward Thomson
6c0d5b11c0 util: make monotonic time fn return ms
`git__timer` is now `git_time_monotonic`, and returns milliseconds
since an arbitrary epoch.

Using a floating point to store the number of seconds elapsed was
clever, as it better supports the wide range of precision from the
different monotonic clocks of different systems. But we're a version
control system, not a real-time clock.

Milliseconds is a good enough precision for our work _and_ it's the
units that system calls like `poll` take and that our users interact
with.

Make `git_time_monotonic` return the monotonically increasing number
of milliseconds "ticked" since some arbitrary epoch.
2023-05-13 16:42:04 +01:00
Edward Thomson
905e4d19c2 Merge pull request #5722 from libgit2/ethomson/tlsdata_fail
Thread-local storage: handle failure cases
2023-05-13 14:33:23 +01:00
Edward Thomson
ebf2991f06 threadstate: don't use an unnecessary macro
Now that we've reduced the usage of GIT_THREADSTATE, remove it entirely
in favor of git_threadstate_get().
2023-05-13 14:09:51 +01:00
Edward Thomson
4f76ef568d oid: don't assume thread local state was initialized
git_oid_tostr_s could fail if thread-local state initialization fails.
In that case, it will now return `NULL`.  Callers should check for
`NULL` and propagate the failure.
2023-05-13 14:09:25 +01:00
Edward Thomson
ce488be46e errors: don't rely on tls data working
Thread-local storage data may fail to initialize; in this case, do not
try to set the error message into it.  When the thread state has not
been initialized, return a hardcoded message to that affect.
2023-05-13 14:09:23 +01:00
Edward Thomson
4be63a6866 errors: drop unneccessary g_git prefix 2023-05-13 13:47:06 +01:00
Edward Thomson
3a4e08a78b Merge pull request #6488 from libgit2/ethomson/workflow
actions: simplify execution with composite action
2023-05-13 13:45:19 +01:00
Edward Thomson
c87a3f8f6c Merge pull request #6561 from libgit2/ethomson/xdiff
Update xdiff to git 2.40.1's version
2023-05-13 13:42:24 +01:00
Edward Thomson
213d35ea6d Merge pull request #6558 from DimitryAndric/fix-qsort-variants-2
Work around -Werror problems when detecting qsort variants
2023-05-12 22:24:49 +01:00
Edward Thomson
3335738579 cmake: refactor check_prototype_definition
Introduce `check_prototype_definition_safe` that is safe for `Werror`
usage.
2023-05-12 21:49:29 +01:00
Edward Thomson
767a9a733c cmake: simplify QSORT names
`QSORT_R` and `QSORT_S` -> `QSORT`
2023-05-12 21:40:55 +01:00
Edward Thomson
027630ddd4 xdiff: update to xdiff from git 2.40.1 2023-05-11 21:44:17 +01:00
Edward Thomson
a821455ee4 util: add GIT_UNUSED_ARG
Add `GIT_UNUSED_ARG` which is an attribute for arguments, for
compatibility with dependencies.
2023-05-11 21:43:38 +01:00
Edward Thomson
2bbcdee6b6 Merge pull request #6557 from libgit2/ethomson/shallow
Shallow (#6396) with some fixes from review
2023-05-09 20:38:04 +01:00
Edward Thomson
437c5f5a0b fetch: remove unshallow option
The `depth` field is suitable to specify unshallowing; provide an enum
to aide in specifying the `unshallow` value.
2023-05-09 17:14:08 +01:00
Edward Thomson
0a7e32b232 oid: use an oid array instead of shallowarray
Users should provide us an array of object ids; we don't need a separate
type. And especially, we should not be mutating user-providing values.
Instead, use `git_oid *` in the shallow code.
2023-05-09 17:14:08 +01:00
Dimitry Andric
3d9cb5e0c6 Work around -Werror problems when detecting qsort variants
If `ENABLE_WERROR` is on, the CMake configure tests for the `qsort_r`
and `qsort_s` variants may fail due to warnings about unused functions
or unused parameters. These warnings can be ignored, so disable them
specifically for running those tests.
2023-05-09 17:38:50 +02:00
Edward Thomson
251408cfd4 Merge pull request #6555 from DimitryAndric/fix-qsort-variants-1
util: detect all possible qsort_r and qsort_s variants
2023-05-09 15:40:39 +01:00
Dimitry Andric
d873966fde util: detect all possible qsort_r and qsort_s variants
As reported in https://bugs.freebsd.org/271234, recent versions of
FreeBSD have adjusted the prototype for qsort_r() to match the POSIX
interface. This causes libgit2's CMake configuration check to fail to
detect qsort_r(), making it fall back to qsort_s(), which in libgit2
also has an incompatible interface. With recent versions of clang this
results in a "incompatible function pointer types" compile error.

Summarizing, there are four variations of 'qsort-with-context':
* old style BSD qsort_r(), used in FreeBSD 13 and earlier, where the
  comparison function has the context parameter first
* GNU or POSIX qsort_r(), also used in FreeBSD 14 and later, where the
  comparison function has the context parameter last
* C11 qsort_s(), where the comparison function has the context parameter
  last
* Microsoft qsort_s(), where the comparison function has the context
  parameter first

Add explicit detections for all these variants, so they get detected as
(in the same order as above):

* `GIT_QSORT_R_BSD`
* `GIT_QSORT_R_GNU`
* `GIT_QSORT_S_C11`
* `GIT_QSORT_S_MSC`

An additional complication is that on FreeBSD 14 and later, <stdlib.h>
uses the C11 _Generic() macro mechanism to automatically select the
correct qsort_r() prototype, depending on the caller's comparison
function argument. This breaks CMake's check_prototype_definition()
functionality, since it tries to redefine the function, and _Generic
macro is expanded inline causing a compile error.

Work around that problem by putting the function names in parentheses,
to prevent the preprocessor from using a macro to replace the function
name.

Also, in `git__qsort_r()`, change the `#if` order so the variants that
do not have to use glue are preferred.
2023-05-08 20:29:26 +02:00
Edward Thomson
04cddffea9 cli: add --depth option to clone 2023-05-08 15:06:41 +01:00
Edward Thomson
43db928895 grafts: make from_file be open_or_refresh
The semantics of `from_file` are weird - it looks like a function that
just opens a file, but it actually inspects the pointer, which is
unexpected and could make things very crashy.

Make an `open` function that just does an open, and move the magic to
`open_or_refresh` whose name better indicates that it may do weird
stuff.
2023-05-08 15:06:41 +01:00
Edward Thomson
19ccab005e shallow: cleanup whitespace in tests 2023-05-08 15:06:41 +01:00
Edward Thomson
3388f5ba1b shallow: don't default to -1 for depth
Depth of `0` should indicate full depth. Disallow negative values (they
may have a future meaning) and use `0` as the default.
2023-05-08 15:06:41 +01:00
Edward Thomson
7d7f3059de grafts: handle SHA256 graft files 2023-05-08 15:06:41 +01:00
Edward Thomson
69592bde1f grafts: use git_parse to parse object IDs
Don't mix parsing by hand and using `git_parse` to parse.
2023-05-08 15:06:41 +01:00
Edward Thomson
6a02b459ab futils: use SHA256 for checksums always
Use SHA256 for file checksums. SHA1 makes no sense as a default in 2023.

Given that we're just looking at a file checksum to see if it's changed,
this does not need to take repository's OID type into account or
otherwise be configurable.
2023-05-08 15:06:41 +01:00
Edward Thomson
8f7fc2ee50 shallow: avoid unnecessary pkt free
Looks like a double-free here.
2023-05-08 15:06:38 +01:00
Edward Thomson
fc4c00b219 Merge pull request #6556 from libgit2/ethomson/wrap_odb
Support SHA256 in git_repository_wrap_odb
2023-05-06 14:57:46 +01:00
Edward Thomson
161d8a12e7 sha256: wrap_odb supports SHA256 2023-05-06 14:33:49 +01:00
Edward Thomson
f1ef8ebee3 odb: test object lookups from git_repository_wrap_odb 2023-05-06 14:33:49 +01:00
Edward Thomson
30917576ad Merge pull request #6554 from oreiche/oreiche/fix-oid-type-fake-repo 2023-05-06 13:16:36 +01:00