Commit Graph

130 Commits

Author SHA1 Message Date
Edward Thomson
df57b2eade warning: allow callers to configure a warning callback 2025-02-26 17:24:26 +01:00
Edward Thomson
1509637751 Introduce git_libgit2_buildinfo
Track some information about the compilation at compile time, and allow
consumers to query it.
2025-01-15 09:28:26 +00:00
Edward Thomson
67900a0fcb options: update X509 cert constant
By placing the X509 cert constant option in the middle of the existing
options, it renumbers everything unnecessarily. Move it to the end in
to avoid breaking changes.
2024-12-23 09:47:03 +00:00
Edward Thomson
19a031d075 Introduce git_libgit2_feature_backend API
Provide a mechanism to understand the backend provider for feature
within libgit2. For example, one can query the mechanism that provides
HTTPS by asking for the backend for the `GIT_FEATURE_HTTPS`.

This is particularly useful for features that are not completely
isomorphic; the HTTPS providers may have slightly different
functionality that can be controlled (eg, certificates or cipher
support). And the SSH feature is _very_ different between libssh2 and
OpenSSH.

It may also be useful to understand the support for things like the SHA1
or SHA256 backends to ensure that sha1dc is used, or that FIPS mode is
enabled.
2024-12-22 15:37:56 +00:00
Edward Thomson
455ce40994 Make GIT_WIN32 an internal declaration
The `GIT_WIN32` macro should only be used internally; keep it as such.
2024-12-09 23:36:34 +00:00
Edward Thomson
338ceb93b6 Improve documentation 2024-11-26 21:44:09 +00:00
Edward Thomson
fa5b832544 openssl: point out the interaction between certs
The OpenSSL certificate setting functions _may_ interact; try to
document that a bit better.
2024-10-01 20:53:59 +01:00
Edward Thomson
54100fc081 Update include/git2/common.h 2024-09-29 22:58:39 +01:00
Sergey Kazmin
6c9ef79aeb more verbose doc 2024-09-09 11:11:39 +03:00
Sergey Kazmin
ad04bf2566 ssl: ability to add raw X509 certs to the cert store 2024-09-06 14:59:37 +03:00
Edward Thomson
4839f4fbfc http: allow users more control over user-agent
Users can now override the "product" portion of the user-agent (via
GIT_OPT_SET_USER_AGENT_PRODUCT). This continues to default to "git/2.0",
but users may define their own string, or may opt out of sending a
user-agent entirely (by passing an empty string). Similarly, users may
now also opt-out of sending any additional "comment" information by
setting the GIT_OPT_SET_USER_AGENT value to an empty string.
2024-03-28 10:10:50 +00:00
Edward Thomson
c3dc87b0c8 docs: update documentation for timeout
The connect timeout *does* apply to SSH connections (at least libssh2),
so update the documentation appropriately.
2024-02-05 10:16:17 +00:00
Mark
7be7c0c0e0 use git_socket_stream__timeout 2024-01-26 13:37:23 -05:00
Mark
392e380463 set SSH timeout 2024-01-18 23:13:14 -05: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
894543827d core: allow users to configure home directory
Some callers -- like our test suite and the test suites of our language
bindings -- want to isolate the home directory to avoid accidentally
including the executing user's actual home directory data.

Previously, we combined the notion of a home directory and global
configuration -- now that this is separated, we provide users the
ability to configure both.
2023-02-09 12:10:40 +00:00
Edward Thomson
0acaf3a8eb oid: define GIT_OID_SHA1_ZERO
Callers should not assume the layout of the oid structure; provide them
a macro that defines the null / zero sha1 object id.
2022-06-14 22:29:57 -04:00
Edward Thomson
4161ebdd50 repo: make ownership checks optional
Introduce the `GIT_OPT_SET_OWNER_VALIDATION` option, so that users can
disable repository ownership validation.
2022-04-11 22:17:52 -04:00
Edward Thomson
056fe4be05 meta: provide an accessor for prerelease info 2022-02-14 07:13:05 -05:00
punkymaniac
58ae4535b8 Document return value for git_libgit2_features 2022-01-09 10:29:00 +01:00
Peter Pettersson
38c3449822 Make enum in includes C90 compliant by removing trailing comma. 2021-11-15 16:45:40 +01:00
Edward Thomson
a24e656a4e common: support custom repository extensions
Allow users to specify additional repository extensions that they want
to support.  For example, callers can specify that they support
`preciousObjects` and then may open repositories that support
`extensions.preciousObjects`.

Similarly, callers may opt out of supporting extensions that the library
itself supports.
2021-09-04 13:00:18 -04:00
Peter Pettersson
2c2cb3f3ec amiga: use ';' as path list separator on AmigaOS
Like on Windows ':' is used for volume names in absolute paths.
2021-08-08 14:35:07 +02:00
Tony De La Nuez
cd460522c5 odb: Implement option for overriding of default odb backend priority
Introduce GIT_OPT_SET_ODB_LOOSE_PRIORITY and GIT_OPT_SET_ODB_PACKED_PRIORITY
to allow overriding the default priority values for the default ODB
backends. Libgit2 has historically assumed that most objects for long-
running operations will be packed, therefore GIT_LOOSE_PRIORITY is
set to 1 by default, and GIT_PACKED_PRIORITY to 2.
When a client allows libgit2 to set the default backends, they can
specify an override for the two priority values in order to change
the order in which each ODB backend is accessed.
2021-07-30 10:29:51 -04:00
punkymaniac
75defb75a8 Add documentation about GIT_OPT_GET_USER_AGENT 2021-06-02 14:44:45 +02:00
lhchavez
eab2b0448e Review feedback
* Change the default of the file limit to 0 (unlimited).
* Changed the heuristic to close files to be the file that contains the
  least-recently-used window such that the window is the
  most-recently-used in the file, and the file does not have in-use
  windows.
* Parameterized the filelimit test to check for a limit of 1 and 100
  open windows.
2020-06-26 16:45:25 -07:00
lhchavez
9679df5736 mwindow: set limit on number of open files
There are some cases in which repositories accrue a large number of
packfiles. The existing mwindow limit applies only to the total size of
mmap'd files, not on their number. This leads to a situation in which
having lots of small packfiles could exhaust the allowed number of open
files, particularly on macOS, where the default ulimit is very low
(256).

This change adds a new configuration parameter
(GIT_OPT_SET_MWINDOW_FILE_LIMIT) that sets the maximum number of open
packfiles, with a default of 128. This is low enough so that even macOS
users should not hit it during normal use.

Based on PR #5386, originally written by @josharian.

Fixes: #2758
2020-06-21 07:15:26 -07:00
Edward Thomson
4cae9e712c git_libgit2_version: return an int
Stop returning a void for functions, future-proofing them to allow them
to fail.
2020-01-24 15:12:56 -06:00
Edward Thomson
7372573b5f httpclient: support expect/continue
Allow users to opt-in to expect/continue handling when sending a POST
and we're authenticated with a "connection-based" authentication
mechanism like NTLM or Negotiate.

If the response is a 100, return to the caller (to allow them to post
their body).  If the response is *not* a 100, buffer the response for
the caller.

HTTP expect/continue is generally safe, but some legacy servers
have not implemented it correctly.  Require it to be opt-in.
2020-01-24 10:16:36 -06:00
Edward Thomson
247e6d909a Remove public 'inttypes.h' header
Remove an `inttypes.h` header that is too large in scope, and far too
public.

For Visual Studio 2012 and earlier (ie, `_MSC_VER < 1800`), we do need
to include `stdint.h` in our public headers, for types like `uint32_t`.

Internally, we also need to define `PRId64` as a printf formatting
string when it is not available.
2019-02-21 09:58:15 +00:00
Dhruva Krishnamurthy
004a339874 Allow bypassing check '.keep' files using libgit2 option 'GIT_OPT_IGNORE_PACK_KEEP_FILE_CHECK' 2019-02-02 07:56:03 -08:00
Edward Thomson
44827b6764 deprecation: add used attribute
Recent GCC enables `-Wunused-const-variables`, which makes output quite
noisy.  Disable unused warnings for our deprecated variables.
2019-01-20 10:36:41 +00:00
Edward Thomson
22d2062d95 Introduce GIT_CALLBACK macro to enforce cdecl
Since we now always build the library with cdecl calling conventions,
our callbacks should be decorated as such so that users will not be able
to provide callbacks defined with other calling conventions.

The `GIT_CALLBACK` macro will inject the `__cdecl` attribute as
appropriate.
2019-01-17 21:17:32 +00:00
Edward Thomson
a74dd39b23 Use cdecl calling conventions on Win32
The recommendation from engineers within Microsoft is that libraries
should have a calling convention specified in the public API, and that
calling convention should be cdecl unless there are strong reasons to
use a different calling convention.

We previously offered end-users the choice between cdecl and stdcall
calling conventions.  We did this for presumed wider compatibility: most
Windows applications will use cdecl, but C# and PInvoke default to
stdcall for WINAPI compatibility.  (On Windows, the standard library
functions are are stdcall so PInvoke also defaults to stdcall.)

However, C# and PInvoke can easily call cdecl APIs by specifying an
annotation.

Thus, we will explicitly declare ourselves cdecl and remove the option
to build as stdcall.
2019-01-17 21:17:32 +00:00
Edward Thomson
19faf7c5fc object_type: update public API to use git_object_t
git_object_t is the future; update the public API to use it.  This will
also ensure that we can build our tests which make use of the old API
without modification (and without compiler warnings).
2018-12-01 10:44:16 +00:00
Edward Thomson
305e801acb util: allow callers to reset custom allocators
Provide a utility to reset custom allocators back to their default.
This is particularly useful for testing.
2018-10-21 13:14:47 +01:00
Nelson Elhage
b3ca817e28 INDEXER_MAX_OBJECTS -> PACK_MAX_OBJECTS 2018-07-16 03:14:33 +00:00
Nelson Elhage
efe3f37d5f Add a git_libgit2_opts option to set the max indexer object count 2018-07-12 05:04:28 +00:00
Edward Thomson
bfa1f02292 settings: optional unsaved index safety
Add the `GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY` option, which will cause
commands that reload the on-disk index to fail if the current
`git_index` has changed that have not been saved.  This will prevent
users from - for example - adding a file to the index then calling a
function like `git_checkout` and having that file be silently removed
from the index since it was re-read from disk.

Now calls that would re-read the index will fail if the index is
"dirty", meaning changes have been made to it but have not been written.
Users can either `git_index_read` to discard those changes explicitly,
or `git_index_write` to write them.
2018-06-29 14:54:29 +01:00
Edward Thomson
3be7301151 Merge pull request #4436 from pks-t/pks/packfile-stream-free
pack: rename `git_packfile_stream_free`
2018-06-11 18:26:22 +01:00
Patrick Steinhardt
396e49600c common.h: create GIT_DEPRECATED macro 2018-06-10 19:30:40 +02:00
Patrick Steinhardt
74b7ddbf33 settings: allow swapping out memory allocator
Tie in the newly created infrastructure for swapping out memory
allocators into our settings code. A user can now simply use the new
option "GIT_OPT_SET_ALLOCATOR" with `git_libgit2_opts`, passing in an
already initialized allocator structure as vararg.
2018-06-07 12:57:39 +02:00
Patrick Steinhardt
6c23704df5 settings: rename GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION
Initially, the setting has been solely used to enable the use of
`fsync()` when creating objects. Since then, the use has been extended
to also cover references and index files. As the option is not yet part
of any release, we can still correct this by renaming the option to
something more sensible, indicating not only correlation to objects.

This commit renames the option to `GIT_OPT_ENABLE_FSYNC_GITDIR`. We also
move the variable from the object to repository source code.
2017-06-08 21:40:18 +02:00
Patrick Steinhardt
35079f507b odb: add option to turn off hash verification
Verifying hashsums of objects we are reading from the ODB may be costly
as we have to perform an additional hashsum calculation on the object.
Especially when reading large objects, the penalty can be as high as
35%, as can be seen when executing the equivalent of `git cat-file` with
and without verification enabled. To mitigate for this, we add a global
option for libgit2 which enables the developer to turn off the
verification, e.g. when he can be reasonably sure that the objects on
disk won't be corrupted.
2017-04-28 14:05:45 +02:00
Sven Strickroth
d5e6ca1e4a Allow to configure default file share mode for opening files
This can prevent FILE_SHARED_VIOLATIONS when used in tools such as TortoiseGit TGitCache and FILE_SHARE_DELETE, because files can be opened w/o being locked any more.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2017-04-03 23:13:00 +01:00
Edward Thomson
2a5ad7d0f2 fsync: call it "synchronous" object writing
Rename `GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION` ->
`GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`.
2017-02-28 13:29:01 +00:00
Edward Thomson
6d3ad7e09e Add ENABLE_SYNCHRONIZED_OBJECT_CREATION option
Allow users to enable `SYNCHRONIZED_OBJECT_CREATION` with a setting.
2017-02-28 13:27:49 +00:00
Gaurav Saral
61acc9fade Changes to provide option to turn off/on ofs_delta
This change provides an option in git_libgit2_opt_t which can be used in git_libgit2_opts to turn off/on ofs_delta capability in libGit2
2017-02-10 15:22:00 +05:30
Edward Thomson
8d3b39a6ad Merge branch 'pr/3912' 2017-01-21 23:50:38 +00:00
Edward Thomson
28d0ba0ba5 symbolic ref target validation: fixups
Fixups requested in #3912.
2017-01-21 23:45:23 +00:00