Commit Graph

227 Commits

Author SHA1 Message Date
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
33938b3df7 openssl: update custom cert tests
Update the custom cert tests to test various custom certificates.
2024-10-01 20:53:59 +01:00
Sergey Kazmin
ceab2087c0 test impl 2024-09-30 15:12:28 +03:00
Edward Thomson
3baa6372fd config: read the individual worktree config
Instead of reading the worktree configuration from the commondir, read
it from the gitdir. This ensures that each worktree gets its own
configuration.
2024-03-11 15:21:12 +00:00
Edward Thomson
e62cdc9bcb Merge pull request #6717 from herrerog/fix-rename-detection
merge: fix incorrect rename detection for empty files.
2024-02-20 16:41:40 +00:00
Edward Thomson
6b54210595 merge: refactor merge tests for empty files treated as renames
Don't munge the "trivial" tests, those are specifically about the
"trivial" resolutions for git's tree merge. (For example, adding a file
in a new branch and making no changes in the HEAD branch is something
that can be handled _trivially_.)

For tests of rename functionality, put them in the trees::rename tests.
2024-02-20 13:47:31 +00:00
Parnic
a0dbf60447 Change capitalization per PR feedback 2024-02-17 08:15:42 -06:00
Parnic
e159f5aba7 Remove unnecessary files 2024-02-16 09:40:29 -06:00
Parnic
9ed014775e Add index.skipHash test 2024-02-16 09:37:29 -06:00
Edward Thomson
85279f06aa ci: update push options tests
Keep the push options tests more constrained to our CI environment;
writing files within the test sandbox instead of outside of it. Provide
the path to the output file in the test data. In addition, add the
repository to the test resources instead of recreating the hooks every
time.
2024-02-06 20:40:38 +00:00
Gregory Herrero
16688efa41 tests: merge: tree: detect incorrect renames.
This test follow "merge: fix incorrect rename detection for empty
files." commit.

Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
2024-01-16 08:47:06 +01:00
Edward Thomson
95adbdebc1 Merge pull request #6581 from roehling/bashism
Use #!/bin/bash for script with bash-specific commands
2023-11-20 15:00:06 +00:00
Edward Thomson
b1b2f063c3 Update tests/resources/push.sh 2023-11-20 12:39:44 +00:00
Edward Thomson
bc97d01c03 Introduce git_process class that invokes processes 2023-08-30 20:45:13 +01:00
Timo Röhling
1e2ea79e78 Use #!/bin/bash for script with bash-specific commands
The test/Resources/push.sh calls pushd/popd, which is not a POSIX
shell feature but a Bash extension.
2023-06-19 20:44:09 +02:00
Edward Thomson
190a4c55df Merge remote-tracking branch 'origin/main' into shallow-clone-network 2023-04-22 23:17:32 +01:00
Edward Thomson
523f893f6f index: add sha256 support 2023-04-10 11:02:12 +01:00
lmcglash
570ef74a07 Merge commit 'd066d0d95c43e97df6624292f3f527f9372ca8fe' 2023-03-10 08:51:43 +00:00
Edward Thomson
479c8c8c14 packfile: handle sha256 packfiles
Teach the packfile machinery to cope with SHA256.
2023-02-12 21:26:12 +00:00
Edward Thomson
23df884ea7 tests: add a sha256 repository
This is a conversion of the testrepo.git to SHA256 support.
2023-02-12 21:26:11 +00:00
Edward Thomson
9d9a90ad3d clone: test bare clone namespaced repo with no HEAD
Test that we can successfully clone a repository that is namespace
scoped to a bare repository locally. We need not specify a checkout
branch in this case (obviously, since we do not check anything out in a
bare clone).
2022-09-19 05:07:16 -04:00
yuangli
52ba17f3d6 Merge branch 'pr/pks-t/5254' into shallow-clone-local 2022-07-26 16:26:32 +01:00
Edward Thomson
2a4d100ae8 refs: make git_reference_cmp consider the name
`git_reference_cmp` only considers the target of a reference, and
ignores the name. Meaning that a reference `foo` and reference `bar`
pointing to the same commit will compare equal.

Correct this, comparing the name _and_ target of a reference.
2022-07-07 21:30:28 -04:00
Yuang Li
e07aa9c3c4 Merge branch 'main' into pr/pks-t/5254 2022-06-24 13:21:48 +01: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
aae54d5b3c Merge pull request #6138 from ccstolley/ccs_packedrefs_fast
refs: Speed up packed lookups.
2022-01-30 13:43:43 -05:00
Miguel Arroz
a3436cde9f #6154 git_status_list_new case insensitive fix 2022-01-01 15:23:00 -08:00
Edward Thomson
05c3d972be Merge pull request #6124 from csware/config-parsing
Config parsing
2021-12-23 15:03:08 -05:00
Edward Thomson
dca31d2427 Merge pull request #6101 from mkhl/fix/instead-of
remotes: fix insteadOf/pushInsteadOf handling
2021-12-23 14:12:23 -05:00
Colin Stolley
ad7a51d834 refs: Speed up packed lookups.
Currently ref lookups require loading the entire packed-refs file into
a hashmap in memory. For repos with large numbers of refs this can be
painfully slow.

This patch replaces the existing lookup code and instead mmap()'s the
packed-refs file and performs a binary search to locate the ref entry.
Git uses a similiar approach.

The old hash table codepath is still used for unsorted packed-refs files.

This patch also fixes a minor bug where the "peeled" trait is never
parsed correctly from the packed-refs header.
2021-12-14 10:07:03 -06:00
Sven Strickroth
433edb54b7 Config parsing confused by continuations that start with quotes
(fixes issue #6089)

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2021-12-06 13:28:07 +01:00
Martin Kühl
7891660a12 update remote/insteadof tests
we want to test:
- an anonymous repo (a url)
- a named repo with a url
- a named repo with a url and pushurl
and for each of these matching configuration:
- only insteadOf
- only pushInsteadOf
- both insteadOf and pushInsteadOf

this change adds test cases for all of these combinations.
2021-11-11 21:45:47 +01:00
Yoichi Nakayama
49ebc8a755 Add a branch with a empty reflog into testrepo.git 2021-10-22 00:08:52 +09:00
Colin Stolley
516f7519f0 Add test for revert+rename bug. 2021-09-15 17:09:17 -05:00
Basile Henry
5eab4dafbe Add test config parsing
This tests parsing a multiline string containing multiple quoted comment
chars. See #6019
2021-09-09 21:51:52 +02:00
Edward Thomson
0e04726866 opts: test GIT_OPT_SET_SSL_CERT_LOCATIONS
Include a self-signed certificate for test.libgit2.org:1443 that we can
use to verify that GIT_OPT_SET_SSL_CERT_LOCATIONS works.
2021-08-29 21:52:30 -04:00
Edward Thomson
1439b9ff05 filter: introduce GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT
Provide a mechanism to filter using attribute data from a specific
commit (making use of `GIT_ATTR_CHECK_INCLUDE_COMMIT`).
2021-07-22 16:40:42 -04:00
Kartikaya Gupta
2d24690c67 Add testcase 2021-05-12 20:42:25 -04:00
lhchavez
1f32ed25ee commit-graph: Support lookups of entries in a commit-graph
This change introduces `git_commit_graph_entry_find()` and
`git_commit_graph_entry_parent()`. These two functions allow a much
faster lookup of commits by ID, since the ODB does not need to be
consulted, the commit object does not need to be inflated, and the
contents of the commit object do not need to be parsed.

Part of: #5757
2021-01-10 11:18:38 -08:00
lhchavez
3fd57a75e9 commit-graph: Introduce a parser for commit-graph files
This change is the first in a series to add support for git's
commit-graph. This should speed up commit graph traversals by avoiding
object parsing and allowing some operations to terminate earlier.

Part of: #5757
2021-01-10 11:18:38 -08:00
lhchavez
005e77157d multipack: Introduce a parser for multi-pack-index files
This change is the first in a series to add support for git's
multi-pack-index. This should speed up large repositories significantly.

Part of: #5399
2020-10-05 05:08:38 -07:00
Sven Strickroth
6ac1862586 Fix config file parsing with multi line values containing quoted parts
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2020-09-18 11:21:00 +02:00
Etienne Samson
d54c00814b tests: graft commits 2020-06-27 14:33:58 +02:00
Carl Schwan
9830ab3d25 blame: add option to ignore whitespace changes 2020-04-14 15:50:53 +02:00
lhchavez
62d5946761 Fix segfault when calling git_blame_buffer()
This change makes sure that the hunk is not null before trying to
dereference it. This avoids segfaults, especially when blaming against a
modified buffer (i.e. the index).

Fixes: #5443
2020-03-23 06:47:18 -07:00
Josh Bleecher Snyder
852c83ee44 refs: refuse to delete HEAD
This requires adding a new symbolic ref to the testrepo fixture.
Some of the existing tests attempt to delete HEAD, expecting a different failure. Introduce and use a non-HEAD symbolic ref instead.
Adjust a few other tests as needed.

Fixes #5357
2020-01-15 13:55:58 -08:00
Johannes Schindelin
3f7851eadc Disallow NTFS Alternate Data Stream attacks, even on Linux/macOS
A little-known feature of NTFS is that it offers to store metadata in
so-called "Alternate Data Streams" (inspired by Apple's "resource
forks") that are copied together with the file they are associated with.
These Alternate Data Streams can be accessed via `<file name>:<stream
name>:<stream type>`.

Directories, too, have Alternate Data Streams, and they even have a
default stream type `$INDEX_ALLOCATION`. Which means that `abc/` and
`abc::$INDEX_ALLOCATION/` are actually equivalent.

This is of course another attack vector on the Git directory that we
definitely want to prevent.

On Windows, we already do this incidentally, by disallowing colons in
file/directory names.

While it looks as if files'/directories' Alternate Data Streams are not
accessible in the Windows Subsystem for Linux, and neither via
CIFS/SMB-mounted network shares in Linux, it _is_ possible to access
them on SMB-mounted network shares on macOS.

Therefore, let's go the extra mile and prevent this particular attack
_everywhere_. To keep things simple, let's just disallow *any* Alternate
Data Stream of `.git`.

This is libgit2's variant of CVE-2019-1352.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-12-10 18:01:06 +10:00
Patrick Steinhardt
b7dcea0492 config_entries: micro-optimize storage of multivars
Multivars are configuration entries that have many values for the same
name; we can thus micro-optimize this case by just retaining the name of
the first configuration entry and freeing all the others, letting them
point to the string of the first entry.

The attached test case is an extreme example that demonstrates this. It
contains a section name that is approximately 500kB in size with 20.000
entries "a=b". Without the optimization, this would require at least
20000*500kB bytes, which is around 10GB. With this patch, it only
requires 500kB+20000*1B=20500kB.

The obvious culprit here is the section header, which we repeatedly
include in each of the configuration entry's names. This makes it very
easier for an adversary to provide a small configuration file that
disproportionally blows up in memory during processing and is thus a
feasible way for a denial-of-service attack. Unfortunately, we cannot
fix the root cause by e.g. having a separate "section" field that may
easily be deduplicated due to the `git_config_entry` structure being
part of our public API. So this micro-optimization is the best we can do
for now.
2019-11-05 13:24:12 +01:00
Patrick Steinhardt
5d8a4659ea Merge pull request #5195 from tiennou/fix/commitish-smart-push
smart: use push_glob instead of manual filtering
2019-09-13 10:31:49 +02:00
Etienne Samson
39d18fe676 smart: use push_glob instead of manual filtering
The code worked under the assumption that anything under `refs/tags` are
tag objects, and all the rest would be peelable to a commit. As it is
completely valid to have tags to blobs under a non `refs/tags` ref, this
would cause failures when trying to peel a tag to a commit.

Fix the broken filtering by switching to `git_revwalk_push_glob`, which
already handles this case.
2019-08-21 12:22:03 +02:00