3340 Commits

Author SHA1 Message Date
Edward Thomson
3c8a860df4 Merge pull request #6348 from lya001/fix-invalid-branch-name
Fix creation of branches and tags with invalid names
2022-07-13 10:19:14 -04:00
Edward Thomson
b70dbaa2f2 Merge pull request #6347 from libgit2/ethomson/no_pack_v3
pack: don't pretend we support pack files v3
2022-07-12 22:12:36 -04:00
yuangli
760a5acc73 Merge branch 'main' into fix-invalid-branch-name 2022-07-12 15:07:54 +01:00
yuangli
1912f145e1 tests: free resources in invalid tag name test 2022-07-11 15:53:35 +01:00
yuangli
7456e81934 tests: error when create tag with invalid name 2022-07-11 15:42:16 +01:00
yuangli
724b5a0e97 tests: rename to follow clar naming convention 2022-07-11 15:24:34 +01:00
yuangli
2e9228e85a tests: rename test for consistency 2022-07-11 15:23:41 +01:00
yuangli
71fafae17a tests: error when create branch with invalid name 2022-07-11 12:03:37 +01:00
yuangli
e4f98ac4b8 tests: follow clar naming convention 2022-07-11 12:00:23 +01:00
Edward Thomson
4597b869f7 pack: don't pretend we support pack files v3
Pack files v3 are introduced in the SHA256 hash transition document
https://github.com/git/git/blob/master/Documentation/technical/hash-function-transition.txt

Obviously we do not support these yet. Stop pretending that we do.
2022-07-08 21:30:21 -04:00
Edward Thomson
56aaaf532d repo: allow admin owned configs by admin users
Allow users in the administrator group to use git configs that are owned
by administrators.
2022-07-07 10:38:01 -04:00
Edward Thomson
df354ec25d fs: remove mock naming from change ownership constants
The file ownership concepts can reflect the actual file ownership, they
are not necessarily limited to mocking the interface. Rename them so
that they can be more broadly applicable.
2022-07-07 10:37:44 -04:00
Edward Thomson
78af6b5eb6 repo: add tests for bare repo permissions
Ensure that we test opening a bare repository with odd permissions.
2022-07-07 10:37:02 -04:00
Edward Thomson
f51f66468a Revert "repo: allow administrator to own the configuration"
This reverts commit cdff2f0237.

This change erroneously allowed system users to own a worktree; this
should only be allowed when the current user is in the Administrator
group on Windows as well.
2022-07-07 10:36:52 -04:00
Edward Thomson
cdff2f0237 repo: allow administrator to own the configuration
Update our ownership checks that were introduced in libgit2 v1.4.3
(to combat CVE 2022-24765). These were not compatible with git's; git
itself allows administrators to own the path. Our checks now match
this behavior.
2022-06-13 21:37:04 -04:00
lhchavez
0a7c00be7f Merge remote-tracking branch 'origin/main' into main 2022-06-11 14:31:16 -07:00
lhchavez
a75416761c Apply suggestions from code review
Co-authored-by: Edward Thomson <ethomson@github.com>
2022-06-11 14:29:15 -07:00
Carl Dong
7f53d7b600 revparse: Remove error-prone, redundant test
Originally introduced in: 776a6a8e5f

This test case has recently been fixed in bdab22384c, but that fix will only last for a year. Next year the same problem will crop up and the test will need to be re-edited.

This is not ideal as
- This test case becomes an unnecessary burden for developers
- Downstream distros or even just users who want to build older versions of libgit2 are guaranteed to have this test fail

Furthermore, this test case is entirely unnecessary, as the functionality that was originally (see 776a6a8e5f) intended to be tested is well-covered by subsequent tests which specify a date instead of a "x ago" specification.
2022-05-09 12:09:08 -04:00
Carlos Martín Nieto
bdab22384c revparse: adjust reflog test as we move away from the dates
The dates we use in `refs::revparse::date` has just passed the ten years, so
now everything is beyond ten years, leading to an unexpected commit being
returned.

Adjust it to 11 years so it all looks fine again.
2022-05-03 09:28:43 +02:00
Edward Thomson
3b52e5f558 Merge pull request #6265 from libgit2/ethomson/sha256_two
sha256: refactoring in preparation for sha256
2022-04-18 17:12:27 -04:00
lhchavez
1d88605ca9 transport: introduce git_transport_smart_remote_connect_options
6fc6eeb66c removed
`git_transport_smart_proxy_option`, and there was nothing added to
replace it. That made it hard for custom transports / smart
subtransports to know what remote connect options to use (e.g. proxy
options).

This change introduces `git_transport_smart_remote_connect_options` to
replace it.
2022-04-16 08:23:22 -07: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
fa366921d9 repo: honor safe.directory during ownership checks
Obey the `safe.directory` configuration variable if it is set in the
global or system configuration. (Do not try to load this from the
repository configuration - to avoid malicious repositories that then
mark themselves as safe.)
2022-04-11 22:15:47 -04:00
Edward Thomson
90d2b61957 repo: test configuration ownership validation
Test that we prevent opening directories that are not owned by
ourselves.
2022-04-11 22:15:47 -04:00
Edward Thomson
bf2620bcef fs_path: refactor ownership checks into current user and system
Provide individual file ownership checks for both the current user and
the system user, as well as a combined current user and system user
check.
2022-04-11 16:49:05 -04:00
Edward Thomson
7367a9d5f7 tests: don't cast raw data to a git_oid`
Create an object id from raw data instead of casting.
2022-04-10 15:56:57 -04:00
Edward Thomson
590ff98166 oid: don't assume the size of an oid
Don't assume that a `git_oid` is a particular size; allocate
`sizeof(git_oid)` instead.
2022-04-10 15:56:57 -04:00
Edward Thomson
ab0421612f tree: move git_oid into tree entry
A tree entry previously pointed directly into the object id within the
tree object itself; this is useful to avoid any unnecessary memory copy
(and an unnecessary use of 40 bytes per tree entry) but difficult if we
change the underlying `git_oid` object to not simply be a raw object id
but have additional structure.

This commit moves the `git_oid` directly into the tree entry; this
simplifies the tree entry creation from user data.  We now copy the
`git_oid` into place when parsing.
2022-04-10 15:56:57 -04:00
Edward Thomson
606afeda5a Merge pull request #6244 from jorio/fix-diff_delta_format_path-crash
Fix crash when regenerating a patch with unquoted spaces in filename
2022-04-10 09:44:41 -04:00
Edward Thomson
e7fce1b5e5 tests: support flaky stat
The 32-bit ARM QEMU builds are flaky when running `lstat`. Disable those
testing `lstat`'s `st_size` temporarily.
2022-04-06 15:15:26 -04:00
Edward Thomson
4e85b4fccc Merge pull request #6259 from libgit2/ethomson/diff_arm32
diff: don't stat empty file on arm32 (flaky test)
2022-04-05 22:40:43 -04:00
Edward Thomson
d8015d28a7 Merge pull request #6251 from libgit2/ethomson/oid_fetch
fetch: support OID refspec without dst
2022-04-04 13:30:27 -04:00
Edward Thomson
42093d6a8e diff: don't stat empty file on arm32 (flaky test)
Our CI test infrastructure virtualizes arm32 in docker, which is a
sometimes imperfect situation. In `diff::workdir::can_diff_empty_file`,
avoid the stat to ensure that the file is zero bytes; there is an odd
issue running in qemu when emulating arm32 that we should skip.
2022-04-04 11:40:42 -04:00
Edward Thomson
ce78c83b73 sha: ensure we test both cng and cryptoapi on windows
When GIT_SHA1_WIN32 or GIT_SHA256_WIN32 is used, ensure that we test
both CryptoNG ("cng") and CryptoAPI.
2022-03-23 08:39:19 -04:00
Edward Thomson
b900981cf7 sha: add sha256 algorithm
Add support for a SHA256 hash algorithm, and add the "builtin" SHA256
hash engine (from RFC 6234).
2022-03-23 08:39:19 -04:00
Edward Thomson
3a08bc4381 Merge pull request #6235 from libgit2/ethomson/cli_benchmarks
Benchmarking suite
2022-03-23 08:38:23 -04:00
Edward Thomson
a9a7967ac0 fetch: support OID refspec without dst
Support the ability to create a refspec that is a single object ID
without a destination.
2022-03-23 08:35:24 -04:00
Edward Thomson
a1020a7f15 clone: update bitbucket tests 2022-03-22 23:13:39 -04:00
Iliyas Jorio
11866327d0 test: add test that regenerates patches with spaces in filename
This currently crashes, proposed fix in subsequent commit.
2022-03-13 17:39:12 +01:00
Edward Thomson
93037bab1c tests: add benchmark tests
Add a benchmark test suite that wraps hyperfine and is suitable for
producing data about test runs of a CLI or A/B testing CLIs.
2022-02-27 23:44:19 -05:00
Edward Thomson
d9b041e6d7 assert: add ASSERT_WITH_CLEANUP
Now that we safely assert and return, we may need to be in a place where
we need to unlock mutexes or cleanup resources.  Provide
`ASSERT_WITH_CLEANUP` that permits for this behavior by taking a block.
2022-02-27 09:20:58 -05:00
Edward Thomson
d02f4f7ad7 cmake: refactor add_clar_test into separate module 2022-02-22 22:07:45 -05:00
Edward Thomson
e6d93612e8 refactor: move utility tests into util 2022-02-22 22:07:45 -05:00
Edward Thomson
2b09b5d7a0 refactor: move headertest into separate test folder 2022-02-22 22:07:45 -05:00
Edward Thomson
25bc84fb8f refactor: move clar into separate directory 2022-02-22 22:07:45 -05:00
Edward Thomson
3344fddc97 refactor: tests is now tests/libgit2
Like we want to separate libgit2 and utility source code, we want to
separate libgit2 and utility tests.  Start by moving all the tests into
libgit2.
2022-02-22 22:07:45 -05:00
Edward Thomson
5fcfada500 cmake: document CMakeLists.txt hierarchy 2022-02-22 22:07:44 -05:00
Edward Thomson
eca9e1cfec Merge pull request #6228 from libgit2/ethomson/win32_systemdirs
win32: `find_system_dirs` does not return `GIT_ENOTFOUND`
2022-02-22 07:17:12 -05:00
Edward Thomson
f45121edd1 win32: find_system_dirs does not return GIT_ENOTFOUND
Allow for no Git for Windows installation.  When there is no GfW found
in the path or registry, `git_win32__find_system_dirs` would return a
`GIT_ENOTFOUND`.  Callers were not expecting this.  Since this is no
error, we simply return `0` so that callers can move on with their
lives.
2022-02-21 16:13:52 +00:00
Carlos Martín Nieto
e35b5e44aa test: add test for the behaviour of update_tips on error 2022-02-21 10:34:13 +01:00