Commit Graph

15211 Commits

Author SHA1 Message Date
Edward Thomson
823d798bf4 streams: refactor as init / connect phase
Add a separate init and connect phase, instead of always connecting in
the constructor. This allows us to be more flexible in the future with
our streams implementations.
2023-09-05 22:47:23 +01:00
Edward Thomson
b6e0866f99 streams: remove proxy idea
Streams don't have proxies. Remove this concept.
2023-09-05 22:41:22 +01:00
Edward Thomson
44b42169b0 url: move git_net_url into net/url.[ch] 2023-09-05 22:41:21 +01:00
Edward Thomson
f10520512a http: move httpclient into utils
The httpclient pieces are not git-specific code, and should (ideally)
belong in the utility area. Move them there.
2023-09-05 22:40:10 +01:00
Edward Thomson
ab899d03ba http: teach httpclient user-agent as options 2023-09-05 22:40:10 +01:00
Edward Thomson
5565eb67ff streams: move to util 2023-09-05 22:40:10 +01:00
Edward Thomson
a8dc731d8a streams: renaming for consistency 2023-09-05 22:40:09 +01:00
Edward Thomson
991587543c https: rename constants for consistency
Rename constants like `GIT_OPENSSL` to (eg) `GIT_HTTPS_OPENSSL` to be
nice and hierarchical and match things like our `GIT_SHA1` constants.
2023-09-05 22:37:18 +01:00
Edward Thomson
5a63b43d97 threadstate: remove the thread state object
We now have no "big single object" that contains thread state.
2023-09-03 14:00:35 +01:00
Edward Thomson
1265986b69 oid: move thread local storage into oid.c
Now that thread-local error data is handled in error, move the thread
local data out of the `threadstate` object, since it has now become
useless indirection.
2023-09-03 14:00:35 +01:00
Edward Thomson
36b52506ff errors: move into util 2023-09-03 14:00:35 +01:00
Edward Thomson
7572d539f9 errors: keep thread-local state internal 2023-09-03 14:00:35 +01:00
Edward Thomson
f451cb18df errors: simplify the saved-state handling
Instead of having a separate type for saving state, we can re-use the
`git_error` structure. In practice, saving the error code along with the
`git_error` information has not proven necessary or useful, so it can be
removed to simplify down to re-using a single structure.
2023-09-03 14:00:35 +01:00
Edward Thomson
f78ae89bf1 errors: move systems things into the sys includes
Most callers only need to _get_ error messages. Only callers implemented
more complicated functions (like a custom ODB for example) need to set
them.

(Callback users should likely ferry their own error information in their
callback payload.)
2023-09-03 14:00:35 +01:00
Edward Thomson
3618a2aa45 errors: never return a NULL error
Callers want to be able to simply call `git_error_last()->message`,
not have to worry about whether `git_error_last()` returns NULL or not.
2023-09-03 14:00:35 +01:00
Edward Thomson
9a9f220119 ssh: refactor to avoid using error state
The error handling in the ssh certificate callback is straightforward.
There's no error messages from an external library that need to be
saved, we populate the error message ourselves. Since there's nothing
custom here, it does not need to use the error saving mechanism.
2023-09-03 14:00:35 +01:00
Edward Thomson
f51e70dc50 Merge pull request #6617 from libgit2/ethomson/openssh
Add OpenSSH support
2023-08-31 09:34:17 +01:00
Edward Thomson
ac399148d2 net: don't free wrapped transport on failure 2023-08-30 21:41:05 +01:00
Edward Thomson
f26d92a4e2 ssh: exec with paths for OpenSSH
Handle custom paths for OpenSSH.
2023-08-30 20:46:23 +01:00
Edward Thomson
3eb7ff2bf9 ci: specify full path to certificate/key
This helped when troubleshooting issues running the `ci/test.sh` script
locally.
2023-08-30 20:46:23 +01:00
Edward Thomson
019cf6c24f ssh: honor core.sshcommand
Callers can specify the ssh command to invoke using `core.sshcommand` or
the `GIT_SSH` environment variable. This is useful for specifying
alternate configuration, and is particularly useful for our testing
environment.
2023-08-30 20:46:23 +01:00
Edward Thomson
d7060aff36 process: provide cmdline-handling and execv style
Provide both cmdline-style handling (passing it to the shell on POSIX,
or directly to CreateProcess on win32) and execv style (passing it
directly to execv on POSIX, and mangling it into a single command-line
on win32).
2023-08-30 20:46:23 +01:00
Edward Thomson
23424f43e1 ssh: don't capture stderr
Don't capture stderr, optimize for the CLI case.
2023-08-30 20:46:23 +01:00
Edward Thomson
bc124bb435 transport: provide clearer / unique error messages
Provide more user-friendly error messages in smart protocol negotiation
failures.
2023-08-30 20:46:23 +01:00
Edward Thomson
18474f7d69 process: reader for stderr
Provide a mechanism for callers to read from stderr.
2023-08-30 20:46:23 +01:00
Edward Thomson
ac07db3fb7 process: sigpipe suppression
Suppress SIGPIPEs during writes to our piped process. On single-threaded
applications, this is as simple as ignoring the signal. But since this
is process-wide, on multi-threaded applications, we need to use some
cumbersome `pthread_sigmask` manipulation.

Thanks to https://www.doof.me.uk/2020/09/23/sigpipe-and-how-to-ignore-it/
and http://www.microhowto.info:80/howto/ignore_sigpipe_without_affecting_other_threads_in_a_process.html
2023-08-30 20:46:23 +01:00
Edward Thomson
0e62615515 smart: unique error messages
Instead of "early EOF", provide information on _when_ we're seeing the
EOF for debugging.
2023-08-30 20:46:23 +01:00
Edward Thomson
1c72c59aa5 smart: don't assume directionality
A transport may want to validate that it's in a sane state; when
flushing on close, don't assume that we're doing an upload-pack; send
the correct direction.
2023-08-30 20:46:23 +01:00
Edward Thomson
a283c1bd1b ci: valgrind shouldn't report on exited children
Now that we (may) exec a child process to do ssh, we don't want valgrind
reporting on that. Suppress children in valgrind runs.
2023-08-30 20:46:23 +01:00
Edward Thomson
10fbb5c940 ssh: only test callbacks for libssh2
There are no custom callbacks for OpenSSH; don't test them.
2023-08-30 20:46:23 +01:00
Edward Thomson
cf133a8221 tests: use cl_fail_with correctly 2023-08-30 20:46:22 +01:00
Edward Thomson
7a8c4d8bd2 process: test SIGTERM detection
We can't reliably detect SIGPIPE on close because of platform
differences. Track `pid` and send `SIGTERM` to a function and ensure
that we can detect it.
2023-08-30 20:46:22 +01:00
Edward Thomson
38b16b01e3 ci: split ssh into exec and libssh2 2023-08-30 20:46:22 +01:00
Edward Thomson
a8b052faab ssh: introduce GIT_SSH_EXEC for external OpenSSH
We can now use the `git_process` class to invoke OpenSSH and use it as
an SSH transport. This may be preferred over libssh2 for a variety of
callers.
2023-08-30 20:46:22 +01:00
Edward Thomson
3fccf7468b ssh: GIT_SSH_LIBSSH2 is now distinct from GIT_SSH
We may want to support SSH but with a different provider that is not
libssh2. Add GIT_SSH to indicate that we have some inbuilt SSH support
and GIT_SSH_LIBSSH2 to indicate that support is via libssh2. This is
similar to how we support GIT_HTTPS and GIT_OPENSSL, for example.
2023-08-30 20:46:21 +01:00
Edward Thomson
67ab8f07c9 ssh: refactor libssh2-specific bits into their own file 2023-08-30 20:45:13 +01:00
Edward Thomson
bc97d01c03 Introduce git_process class that invokes processes 2023-08-30 20:45:13 +01:00
Edward Thomson
0181b4cb82 Introduce git_strlist to manage string lists 2023-08-30 20:45:12 +01:00
Edward Thomson
da265cdf2e Merge pull request #6629 from libgit2/ethomson/flakes
ci: update to macOS 12
2023-08-25 15:22:48 +01:00
Edward Thomson
14fa2ad703 Update macOS build image to macos-12 2023-08-25 13:12:07 +01:00
Edward Thomson
1fc9cd5292 ci: retry (more) flaky online tests 2023-08-23 13:50:33 +01:00
Edward Thomson
91b91f9da7 Merge pull request #6628 from libgit2/ethomson/flakes
ci: retry flaky online tests
2023-08-23 13:17:37 +01:00
Edward Thomson
2a99bc7b07 ci: retry flaky online tests 2023-08-23 11:00:25 +01:00
Edward Thomson
80efb3a45f Merge pull request #6626 from lazka/fix-win32-openssl
cmake: fix openssl build on win32
2023-08-19 16:06:19 +01:00
Christoph Reiter
86872834c5 cmake: fix openssl build on win32
since f15c8ac71a libgit unconditionally depends on secur32 on Windows
but only added it in cmake for the winhttp and schannel variants.
In case libgit is built against openssl it would fail to link.

This moves secur32 out of the https backend selection code into
the global win32 condition (and while at it also adds ws2_32 to the .pc file)
2023-08-19 10:44:25 +02:00
Edward Thomson
8ffdc5a90c Merge pull request #6616 from libgit2/ethomson/config_cmd
cli: add a `git config` command
2023-08-14 20:41:10 +01:00
Edward Thomson
45647b721c Merge pull request #6615 from libgit2/ethomson/config_origin
config: provide an "origin" for config entries
2023-08-14 20:40:47 +01:00
Edward Thomson
af15738151 Merge pull request #6621 from mathworks/conan-link-update
README.md: Fix link to conan packages
2023-08-14 16:22:59 +01:00
Laurence McGlashan
7f098da459 README.md: Fix link to conan packages 2023-08-14 16:11:32 +01:00
Edward Thomson
95f3d41364 Merge pull request #6619 from libgit2/revert-6586-fix/cmake_msvc
Revert "CMake: Search for ssh2 instead of libssh2."
2023-08-10 10:39:04 +01:00