Commit Graph

9619 Commits

Author SHA1 Message Date
Talya Connor
9f93169473 diff: account for common prefix in max namelen. 2025-03-29 18:50:19 +11:00
ytnuf
a465da73a5 Revert include path regression 2025-02-13 11:10:45 +00:00
Edward Thomson
3822833a7a Merge pull request #7007 from libgit2/ethomson/buildinfo
Introduce git_libgit2_buildinfo
2025-02-03 17:20:55 +00:00
Edward Thomson
3eadce3d0b Merge pull request #7019 from vapier/main
alternates: allow relative paths in all repositories
2025-01-21 13:04:10 -08:00
Edward Thomson
346930e280 Merge pull request #7018 from libgit2/ethomson/icase_filters
attr: honor ignorecase in attribute matching
2025-01-20 15:09:50 -08:00
Carlo Bramini
63cffe3d21 cli: fix undefined alloca() on CYGWIN
I tried to build my libgit2-1.9.0 package for CYGWIN but I got an error. This message appears when compiling:

[199/671] Building C object src/cli/CMakeFiles/git2_cli.dir/opt.c.o
libgit2-1.9.0/src/cli/opt.c: In function ‘cli_opt_parse’:
libgit2-1.9.0/src/cli/opt.c:564:23: warning: implicit declaration of function ‘alloca’; did you mean ‘malloc’? [-Wimplicit-function-declaration]
  564 |         given_specs = alloca(sizeof(const cli_opt_spec *) * (args_len + 1));
      |                       ^~~~~~
      |                       malloc

and later the linker emits this error message:

[668/671] Linking C executable git2.exe
FAILED: git2.exe
/usr/x86_64-pc-cygwin/bin/ld: src/cli/CMakeFiles/git2_cli.dir/opt.c.o: in function `cli_opt_parse':
/usr/src/debug/libgit2-1.9.0-1/src/cli/opt.c:564:(.text+0xce3): undefined reference to `alloca'
collect2: error: ld returned 1 exit status

The error is fixed by adding alloca.h to included headers.
Hopefully, opt.c already allows to add alloca.h for some platforms, so I just added an additional test for the preprocessor for checking if the target is CYGWIN.
2025-01-20 12:34:50 +01:00
Mike Frysinger
17cbd2eae0 alternates: allow relative paths in all repositories
Git does not limit relative paths in alternates to the first
repository, so libgit2 shouldn't either.
2025-01-15 21:25:30 -05:00
Edward Thomson
906623b8f9 attr: honor ignorecase in attribute matching
`.gitattributes` is case-insensitive when `core.ignorecase=true`.
2025-01-15 22:44:51 +00:00
Edward Thomson
6330ca3c0f version: add size information
Add `sizeof-long` and `sizeof-size_t` information to `version` command.
2025-01-15 09:28:28 +00: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
Alexander Kanavin
904c8f266d src/libgit2/CMakeLists.txt: install cmake files into configured libdir
libdir can be something else than /usr/lib, e.g. /usr/lib64 or similar.
2025-01-07 19:01:49 +01:00
Edward Thomson
caa65e0e9f Merge pull request #7000 from libgit2/ethomson/object_type 2025-01-03 14:01:24 +00:00
Edward Thomson
23da3a8f3c object: remove OFS_DELTA and REF_DELTA values
Deltas are not objects, they're entries in a packfile. Remove them from
the object enum.
2025-01-03 13:28:19 +00:00
Edward Thomson
2d5942571c object: introduce type_is_valid
There's no such thing as a "loose object type" or a "packed object
type". There are only object types. Introduce `type_is_valid` and
deprecate `typeisloose`.
2025-01-03 13:28:19 +00:00
Edward Thomson
dafe14ce65 Merge pull request #6346 from libgit2/ethomson/reference_cmp
refs: make `git_reference_cmp` consider the name
2025-01-02 23:14:40 +00:00
Edward Thomson
a0d432660a Merge pull request #6994 from libgit2/ethomson/cmake 2025-01-02 17:56:41 +00:00
Edward Thomson
270d8019cd Merge pull request #6975 from libgit2/ethomson/sha256_simplification 2025-01-02 14:22:44 +00:00
Edward Thomson
c605f4281b Merge pull request #6995 from libgit2/ethomson/cmd_version
cli: add version command
2025-01-02 13:14:41 +00:00
Edward Thomson
c26d8a8b54 sha256: further API simplifications for OID parsing
Introduce `git_oid_from_string`, `git_oid_from_prefix`, and
`git_oid_from_raw`, all of which take a `git_oid_t` that indicates what
type of OID should be parsed (SHA1 or SHA256).

This allows users to continue to use `git_oid_fromstr` without any code
changes, while remaining in a SHA1 world.

Note that these are not perfect analogs to the `fromstr` APIs.

* `git_oid_from_string` now takes a NUL terminated string, instead of
  allowing for non-NUL terminated strings. Adding a NUL check feels like
  an important safety consideration for C strings.
* `git_oid_from_prefix` should be used for an OID substring and length.

Previous usages of `git_oid_fromstr` with non-NUL terminated strings
should move to `git_oid_from_prefix` with the hexsize for the given OID
type.
2025-01-02 13:13:59 +00:00
Edward Thomson
56e2a85643 sha256: simplify API changes for sha256 support
There are several places where users may want to specify the type of
object IDs (sha1 or sha256) that should be used, for example, when
dealing with repositories, indexes, etc.

However, given that sha256 support remains disappointingly uncommon in
the wild, we should avoid hard API breaks when possible. Instead, update
these APIs to have an "extended" format (eg, `git_odb_open_ext`) that
provides an options structure with oid type information.

This allows callers who do care about sha256 to use it, and callers who
do not to avoid gratuitous API breakage.
2025-01-02 13:13:59 +00:00
Edward Thomson
fb7fef0d72 hash: allow unsigned int != size_t in sha256
Our bundled SHA256 implementation passes a `size_t` as an `unsigned
int`. Stop doing that.
2025-01-02 12:39:54 +00:00
Edward Thomson
24d50ad87b cli: add version command
Move the `--version` information into its own command, so that we can
support `--build-options`.
2025-01-02 12:39:33 +00:00
Edward Thomson
4546929e00 cmake: case insensitive options
It's hard to remember whether it's `-DUSE_HTTPS=mbedTLS` or
`-DUSE_HTTPS=mbedtls`. Even worse for things like `builtin` which we may
have been inconsistent about. Allow for case insensitive options.
2025-01-02 12:36:46 +00:00
Edward Thomson
5a654f11bb cmake: update git2_features.h
Reorganize the libgit2 feature selection file.
2025-01-02 12:36:45 +00:00
Edward Thomson
c4c284e46f cmake: standardize HTTPS backend definitions
There were a few oddities around HTTPS provider selection: namely,
`GIT_OPENSSL_DYNAMIC` implied `GIT_OPENSSL`, which made a bit of sense,
until we added FIPS support. In addition, dynamic OpenSSL for _hashes_
and dynamic OpenSSL for HTTPS was conflated in a few places.

Untangle these, and make `GIT_HTTPS_*` the define, for consistency with
other feature provider selection.
2025-01-02 12:36:11 +00:00
Edward Thomson
c42ccfaa34 cmake: don't report futimes enablement
futimes is not an option; don't report enablement as such.
2025-01-02 12:36:11 +00:00
Edward Thomson
9efdbe3834 cmake: standardize leak check option
The `GIT_WIN32_LEAKCHECK` option is a debugging option, so it should be
`GIT_DEBUG_LEAKCHECK_WIN32`
2025-01-02 12:36:11 +00:00
Edward Thomson
94d8883dcf cmake: update verbiage on feature enablement 2025-01-02 12:36:11 +00:00
Edward Thomson
2b581ef517 cmake: update threads
For consistency with other backend/provider selection, allow
`USE_THREADS` to select the threads provider.
2025-01-02 12:36:11 +00:00
Edward Thomson
890d70856c cmake: update nanosecond selection
For consistency, specify the nanosecond option in the same way as other
options, and identify it as such. Split the detection of platform
support (`FindStatNsec`) and its selection (`SelectNsec`).
2025-01-02 12:36:11 +00:00
Edward Thomson
8bbd2f406e cmake: use DEBUG_LEAK_CHECKER as option
The `USE_` prefix for inputs denotes a backend; the `DEBUG_` prefix
denotes a debugging option. Make `DEBUG_LEAK_CHECKER` the name of the
leak checking option.
2025-01-02 12:36:11 +00:00
Edward Thomson
c9974d28b2 cmake: update Negotiate backend selection 2025-01-02 12:36:11 +00:00
Edward Thomson
fb59acb246 cmake: update NTLM feature enablement 2025-01-02 12:36:09 +00:00
Edward Thomson
9ea1f6d4ed cmake: standardize iconv options 2025-01-02 11:45:47 +00:00
Edward Thomson
fdb73f5d1d cmake: simplify compression selection 2025-01-02 11:45:47 +00:00
Edward Thomson
c4a65c34c2 cmake: standardize builtin sha1dc selection
All `USE_*` options are now `builtin`. Use that for the builtin sha1dc
implementation, keeping `CollisionDetection` for backward compatibility.
2025-01-02 11:45:47 +00:00
Edward Thomson
ca2a241e4c repo: workdir_path implies no dotgit in init
When specifying a separate working directory path, the given repository
path should never have a `.git` directory created beneath it. That
simply doesn't make sense.

As a result, the `GIT_REPOSITORY_INIT_NO_DOTGIT_DIR` now _also_ no
longer makes sense. It would only ever be a sensible option when one
wanted a separate `.git` directory and working directory, otherwise the
git files and working directory files would be comingled. Remove the
option entirely.
2024-12-30 20:36:13 +00:00
Edward Thomson
e9d97bedc2 Merge pull request #6966 from libgit2/ethomson/tls
ssl: enforce TLS v1.2 (or better)
2024-12-28 23:44:12 +00:00
Edward Thomson
800a95371c Merge pull request #6984 from libgit2/ethomson/cli
CLI: introduce `init` command
2024-12-28 00:32:57 +00:00
Edward Thomson
838875eb8f Merge branch 'cmake_target' 2024-12-28 00:30:28 +00:00
Edward Thomson
ded9494954 cmake: only add package target for libgit2 itself 2024-12-28 00:26:11 +00:00
Edward Thomson
9f61001ad5 cli: improve option help 2024-12-28 00:02:25 +00:00
Edward Thomson
5350142b9b Merge pull request #6981 from libgit2/ethomson/gitlink_newline 2024-12-27 17:17:35 +00:00
Edward Thomson
bf5f0b5600 cli: add an init command 2024-12-27 16:50:26 +00:00
Edward Thomson
a844a6cf23 repo: put a newline on the .git link file
The `.git` file, when containing a `gitdir: ` link, should be suffixed
with a trailing newline.
2024-12-27 16:38:26 +00:00
Edward Thomson
0c27a85b41 repo: don't require option when template_path is specified
When a `template_path` is explicitly specified, don't _also_ require an
option to indicate that we should use templates. We, obviously, should.
2024-12-27 16:20:11 +00:00
Edward Thomson
ccc202802c Merge pull request #6962 from ryan-ph/ryanpham/negative-refspec/remote
remote: Handle fetching negative refspecs
2024-12-24 23:55:06 +00:00
Ryan Pham
6039d28d43 remote: Return first matching refspec
The previous behavior was to return the first match, so this reverts the
clobbering behavior that was introduced in
f7f30ec136.
2024-12-24 10:42:02 +09:00
Ryan Pham
83994dafec remote: Remove unnecessary call
`git_refspec_is_negative()` is already called by
`git_refspec_src_matches_negative()`, so should not be necessary here.
2024-12-24 10:41:56 +09:00
bmarques1995
5d6e679e21 Rebase 2024-12-23 20:27:40 -03:00