3499 Commits

Author SHA1 Message Date
Edward Thomson
00c62ab0ad http: test proxies in url and host:port format
Test proxies specified by both host:port format in configuration
options, environment variables, and `http.proxy` configuration.
2023-08-02 21:36:30 +01:00
Edward Thomson
1d7d6ff95a net: introduce http-biased url parsing
Introduce a url parser that defaults to treating poorly specified URLs
as http URLs. For example: `localhost:8080` is treated as
`http://localhost:8080/` by the http-biased url parsing, instead of a
URL with a scheme `localhost` and a path of `8080`..
2023-08-02 21:36:30 +01:00
Edward Thomson
95d4cb6eac net: refactor url parsing
Refactor url parsing to simplify the state-passing (introducing a
struct) and add a path parser for future reusability.
2023-08-02 21:36:30 +01:00
lmcglash
5a13d4ca56 Validate proxy URL on Windows. 2023-08-02 21:36:30 +01:00
lmcglash
402f63a46b Return an error for invalid proxy URLs instead of crashing. 2023-08-02 21:36:30 +01:00
Edward Thomson
e3e0564a5f Merge pull request #6577 from cavaquinho/fix/workdir_to_index_untracked_reverse
#6576 git_diff_index_to_workdir reverse now loads untracked content
2023-07-15 14:57:09 +01:00
Edward Thomson
58be98b71b Merge pull request #6563 from libgit2/pks/test-allocator
tests: add allocator with limited number of bytes
2023-07-15 14:00:35 +01:00
Edward Thomson
47dcc4bc49 Merge pull request #6345 from arroz/fix/branch-move-reflog
Fixes #6344: git_branch_move now renames the reflog instead of deleting.
2023-07-15 09:55:59 +01:00
Miguel Arroz
4a2c4cc93f #6576 git_diff_index_to_workdir reverse now loads untracked content 2023-06-09 18:21:13 -07:00
Reginald McLean
0fd80681f9 Added missing is_prunable test 2023-05-16 12:31:16 +01:00
Edward Thomson
2757641620 tests: only copy when ptr is non-NULL
Avoid passing a `NULL` ptr to `memcpy` -- that's UB (even if size is 0)
2023-05-15 11:04:37 +01:00
Patrick Steinhardt
8e5281c88b tests: add allocation failure test for buffers
Test that `git_buf` correctly fails if no more bytes can be allocated.
This is mostly for demonstration purposes.
2023-05-15 09:30:48 +01:00
Patrick Steinhardt
90cc07711c tests: add allocator with limited number of bytes
In several circumstances, we get bug reports about things that happen in
situations where the environment is quite limited with regards to
available memory. While it's expected that functionality will fail if
memory allocations fail, the assumption is that we should do so in a
controlled way. Most importantly, we do not want to crash hard due to
e.g. accessing NULL pointers.

Naturally, it is quite hard to debug such situations. But since our
addition of pluggable allocators, we are able to implement allocators
that fail in deterministic ways, e.g. after a certain amount of bytes
has been allocated. This commit does exactly that.

To be able to properly keep track of the amount of bytes currently
allocated, allocated pointers contain tracking information. This
tracking information is currently limited to the number of bytes
allocated, so that we can correctly replenish them on calling `free` on
the pointer. In the future, it would be feasible to extend the tracked
information even further, e.g. by adding information about file and line
where the allocation has been performed. As this introduced some
overhead to allocations though, only information essential to limited
allocations is currently tracked.
2023-05-15 09:28:47 +01:00
Edward Thomson
8f695c806b clone: skip timeout tests on WinHTTP 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
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
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
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
Edward Thomson
19ccab005e shallow: cleanup whitespace in tests 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
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
d69c7a7238 transport: transports understand oid type
Teach the smart transport more about oid types, instead of assuming SHA1.
2023-04-25 10:34:43 +01:00
Edward Thomson
6cec01b4d8 shallow: move tests to online 2023-04-24 11:49:16 +01:00
Edward Thomson
dd15c615bd shallow: remove feature flag
The opt mechanism isn't _really_ meant to be for feature flags, and it's
weird to feature flag shallow / unshallow at all.
2023-04-24 11:49:12 +01:00
Edward Thomson
190a4c55df Merge remote-tracking branch 'origin/main' into shallow-clone-network 2023-04-22 23:17:32 +01:00
Edward Thomson
8a62616f43 Merge pull request #6549 from libgit2/ethomson/sha256_experimental
sha256: less hardcoded SHA1 types and lengths
2023-04-22 23:09:32 +01:00
Edward Thomson
54bcafeb1e config: return GIT_ENOTFOUND for missing programdata
When the programdata path is missing, ensure that we pass down the
`GIT_ENOTFOUND` error to the caller instead of converting it to a
generic `-1`.
2023-04-11 10:13:46 +01:00
Edward Thomson
b899fda3d8 commit graph: support sha256 2023-04-10 14:21:16 +01:00
Edward Thomson
be484d355b midx: support sha256 2023-04-10 14:21:16 +01:00
Edward Thomson
db2a794dda diff: parse patches with sha256 2023-04-10 14:21:16 +01:00
Edward Thomson
523f893f6f index: add sha256 support 2023-04-10 11:02:12 +01:00
Edward Thomson
389f9b10e6 repo: honor GIT_CONFIG_* environment variables
When the repository is opened with `GIT_REPOSITORY_OPEN_FROM_ENV`, honor
the `GIT_CONFIG_GLOBAL`, `GIT_CONFIG_SYSTEM` and `GIT_CONFIG_NOSYSTEM`
environment variables.
2023-04-04 09:05:16 +01:00
Edward Thomson
24b9c4b633 repo: honor GIT_COMMON_DIR when respecting env
When the repository is opened with `GIT_REPOSITORY_OPEN_FROM_ENV`, honor
the `GIT_COMMON_DIR` environment variable.
2023-04-04 09:05:16 +01:00
Edward Thomson
b41c3dfce6 repo: honor GIT_WORK_TREE environment variable
When the repository is opened with `GIT_REPOSITORY_OPEN_FROM_ENV`, honor
the `GIT_WORK_TREE` environment variable.
2023-04-04 09:05:16 +01:00
Edward Thomson
dc7bca58ee repo: free data in the discovery tests
Shocked that our leak checkers didn't find this earlier.
2023-04-04 09:05:15 +01:00
Edward Thomson
2f20fe8869 Merge pull request #6505 from libgit2/ethomson/extension_madness
repo: don't allow repeated extensions
2023-03-27 11:58:42 +01:00
Edward Thomson
0d7f3f5291 utf8: add conversion with size and refactor names
Add functions to use convert a string with length, instead of assuming
NUL termination.

In addition, move the utf8 to 16 conversion routines into the `git_utf8`
namespace instead of using namespaceless `git__` prefixed names.
2023-03-21 09:14:06 +00:00
Edward Thomson
f68f542eb6 http: introduce schannel streams for windows
Provide a stream interface for Schannel - the native crypto APIs - on
Windows. This allows Windows to use the same HTTP transport that all the
other platforms use, with its own native crypto.

Ultimately this allows us to deprecate WinHTTP and we need not add
support for our socket changes in two places (our HTTP stack and the
WinHTTP stack).
2023-03-21 09:09:48 +00:00
lmcglash
570ef74a07 Merge commit 'd066d0d95c43e97df6624292f3f527f9372ca8fe' 2023-03-10 08:51:43 +00:00
Edward Thomson
309befe413 index: test git_index_add_all with force
Ensure that when all files beneath a directory are ignored that we
add the files when FORCE is specified.
2023-03-02 23:21:50 +00:00
Edward Thomson
6fb5ab3723 index: test git_index_add_all with ignored folder
Ensure that when all files beneath a directory are ignored that we
actually ignore the files.
2023-03-02 23:09:36 +00:00
Edward Thomson
af12fc11c5 Merge pull request #6520 from libgit2/ethomson/git_odb_open
odb: restore `git_odb_open`
2023-03-02 01:31:57 -08:00
Edward Thomson
7445d510be Merge pull request #6513 from libgit2/ethomson/util_test_root
fs_path: let root run the ownership tests
2023-03-01 16:19:56 -08:00
Edward Thomson
e1e0d77c6f odb: restore git_odb_open
`git_odb_open` was erroneously removed during a refactoring; add it
back.
2023-03-01 22:16:31 +00:00
Edward Thomson
a7561e0eda Merge pull request #6512 from libgit2/ethomson/odb_loose 2023-02-27 14:23:35 -08:00
Edward Thomson
59bb933c17 odb: test git_odb_backend_loose 2023-02-27 21:54:59 +00:00