Commit Graph

3508 Commits

Author SHA1 Message Date
Edward Thomson
ae3d81e2b8 wip - refactoring stream interface 2023-08-21 22:14:46 +01:00
Edward Thomson
c8dfd09454 url: move git_net_url into net/url.[ch] 2023-08-20 15:34:54 +01:00
Edward Thomson
d6fb8bfde0 streams: renaming for consistency 2023-08-20 15:34:54 +01:00
Edward Thomson
f11f6b952e 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-08-20 14:57:23 +01:00
Edward Thomson
f32c5c48c3 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-08-20 14:57:23 +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
5a64922408 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 09:46:12 +01:00
Edward Thomson
8749655745 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-01 14:12:01 +01:00
Edward Thomson
8c2c0fa80a 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-01 14:12:01 +01:00
Edward Thomson
40ce52e51f config: provide two memory-backed config backends
Provide two memory-backed configuration backends -- one that takes a
string in config file format `[section] key=value` and one that takes a
list of strings in `section.key=value` format.
2023-07-21 11:18:44 +01:00
Edward Thomson
248ac08cb8 config: memory backends have an optional type 2023-07-20 10:54:14 +01:00
Edward Thomson
0e0781f6f3 config: provide origin in git_config_entry
A git_config_entry now knows the type of the origin for the entry
("file", "memory", etc) and the path details (for files, the path on
disk). This is propagated through snapshots.
2023-07-20 10:29:41 +01:00
lmcglash
d48a5d5104 Validate proxy URL on Windows. 2023-07-19 14:33:39 +01:00
lmcglash
89bc8ff982 Return an error for invalid proxy URLs instead of crashing. 2023-07-17 21:43:55 +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