summaryrefslogtreecommitdiff
path: root/tests/refs
Commit message (Collapse)AuthorAgeFilesLines
* refactor: `tests` is now `tests/libgit2`Edward Thomson2022-02-2244-6743/+0
| | | | | | 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.
* revparse: support bare '@'Edward Thomson2022-01-301-0/+7
| | | | A bare '@' revision syntax represents HEAD. Support it as such.
* Merge pull request #6138 from ccstolley/ccs_packedrefs_fastEdward Thomson2022-01-301-0/+24
|\ | | | | refs: Speed up packed lookups.
| * refs: Speed up packed lookups.Colin Stolley2021-12-141-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fix typosDimitris Apostolou2022-01-051-1/+1
| |
* | Merge branch 'main' into better-compatiblity-for-at-time-notationYoichi Nakayama2021-11-2313-34/+38
|\ \ | |/ | | | | | | Conflicts: src/revparse.c
| * tests: include function declarationsEdward Thomson2021-11-113-4/+8
| |
| * test: correct test namesEdward Thomson2021-11-112-2/+2
| |
| * tests: declare functions statically where appropriateEdward Thomson2021-11-111-1/+1
| |
| * path: separate git-specific path functions from utilEdward Thomson2021-11-098-27/+27
| | | | | | | | | | | | Introduce `git_fs_path`, which operates on generic filesystem paths. `git_path` will be kept for only git-specific path functionality (for example, checking for `.git` in a path).
* | Cause error when date parsing is failedYoichi Nakayama2021-10-221-0/+13
| |
* | Return the oldest reflog entry on revparse when older time is givenYoichi Nakayama2021-10-221-5/+12
| | | | | | | | | | For better compatibility with git command which returns the oldest log entry with a warning message.
* | Add a branch with a empty reflog into testrepo.gitYoichi Nakayama2021-10-223-5/+7
|/
* str: introduce `git_str` for internal, `git_buf` is externalethomson/gitstrEdward Thomson2021-10-1715-143/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
* Fix one memory leak in masterlhchavez2021-07-301-0/+2
| | | | There was one test that wasn't correctly disposing of the repository.
* Merge branch 'pr/5861'Edward Thomson2021-07-301-0/+23
|\
| * tests: reformat upstream mergeEdward Thomson2021-07-301-5/+5
| |
| * tests: upstream merge test has been added.Dmitry Lobanov2021-06-181-0/+23
| |
* | tests: clean up refs::races zero oid testEdward Thomson2021-05-181-1/+3
| |
* | Merge branch 'zero_oid_in_old'Edward Thomson2021-05-161-0/+16
|\ \ | |/ |/| | | Manually merging #5842
| * refs: test git_reference_create_matching failure for zero oidEdward Thomson2021-05-161-0/+3
| |
| * git_reference_create_matching: Treat all-zero OID as "must be absent"David Turner2021-04-201-0/+13
| | | | | | | | | | | | | | | | | | | | | | This is pretty useful in avoiding races: I want to create a ref only if it doesn't already exist. I can't check first because of TOCTOU -- by the time I finish the check, someone else might have already created the ref. And I can't take a lock because then I can't do the create, since the create expects to take the lock. The semantics are inspired by git update-ref, which allows an all-zero old value to mean that the ref must not exist.
* | test: clean up memory leaksEdward Thomson2021-05-061-0/+1
| |
* | refs: ensure loose refs adhere to path validationEdward Thomson2021-04-281-0/+40
|/ | | | | | | | | On Windows, we need to enforce MAX_PATH for loose references and their reflogs. Ensure that any path - including the lock file - would fit within the 260 character maximum. We do not honor core.longpaths for loose reference files or reflogs. core.longpaths only applies to paths in the working directory.
* revspec: rename git_revparse_mode_t to git_revspec_tethomson/revparseEdward Thomson2021-01-311-13/+13
| | | | | | The information about the type of a revision spec is not information about the parser. Name it accordingly, so that `git_revparse_mode_t` is now `git_revspec_t`. Deprecate the old name.
* Add git_tag_name_is_validSven Strickroth2020-10-251-0/+17
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Add git_branch_name_is_validSven Strickroth2020-10-251-0/+17
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* refs: use git_reference_name_is_validEdward Thomson2020-10-251-22/+29
|
* tests: reflog: remove unused signaturePatrick Steinhardt2020-07-121-9/+0
| | | | | There's two tests that create a commit signature, but never make any use of it. Let's remove these to avoid any confusion.
* tests: refs: modernize coding style of testcasePatrick Steinhardt2020-06-081-8/+3
| | | | | The coding style of the testcase refs::create::propagate_eexists is not really up-to-date. Convert it to use a more modern coding style.
* clar: include the function nameethomson/clar_tapEdward Thomson2020-06-051-3/+4
|
* strarray: we should `dispose` instead of `free`Edward Thomson2020-06-013-5/+5
| | | | | | We _dispose_ the contents of objects; we _free_ objects (and their contents). Update `git_strarray_free` to be `git_strarray_dispose`. `git_strarray_free` remains as a deprecated proxy function.
* refs: refuse to delete HEADJosh Bleecher Snyder2020-01-153-9/+20
| | | | | | | 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
* refs: rename git_reference__set_name to git_reference__reallocEtienne Samson2019-12-131-0/+44
| | | | | | | | | | | As git_reference__name will reallocate storage to account for longer names (it's actually allocator-dependent), it will cause all existing pointers to the old object to become dangling, as they now point to freed memory. Fix the issue by renaming to a more descriptive name, and pass a pointer to the actual reference that can safely be invalidated if the realloc succeeds.
* Merge pull request #5275 from pks-t/pks/reflogs-with-newlinesEdward Thomson2019-11-022-20/+39
|\ | | | | reflogs: fix behaviour around reflogs with newlines
| * refdb_fs: properly parse corrupted reflogsPatrick Steinhardt2019-10-181-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | In previous versions, libgit2 could be coerced into writing reflog messages with embedded newlines into the reflog by using `git_stash_save` with a message containing newlines. While the root cause is fixed now, it was noticed that upstream git is in fact able to read such corrupted reflog messages just fine. Make the reflog parser more lenient in order to just skip over malformatted reflog lines to bring us in line with git. This requires us to change an existing test that verified that we do indeed _fail_ to parse such logs.
| * reflog: allow adding entries with newlines in their messagePatrick Steinhardt2019-10-182-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the reflog disallows any entries that have a message with newlines, as that would effectively break the reflog format, which may contain a single line per entry, only. Upstream git behaves a bit differently, though, especially when considering stashes: instead of rejecting any reflog entry with newlines, git will simply replace newlines with spaces. E.g. executing 'git stash push -m "foo\nbar"' will create a reflog entry with "foo bar" as entry message. This commit adjusts our own logic to stop rejecting commit messages with newlines. Previously, this logic was part of `git_reflog_append`, only. There is a second place though where we add reflog entries, which is the serialization code in the filesystem refdb. As it didn't contain any sanity checks whatsoever, the refdb would have been perfectly happy to write malformatted reflog entries to the disk. This is being fixed with the same logic as for the reflog itself.
* | refs: unlock unmodified refs on transaction commitSebastian Henke2019-10-171-0/+26
|/ | | | | | | | | | Refs which are locked in a transaction without an altered target, still should to be unlocked on `git_transaction_commit`. `git_transaction_free` also unlocks refs but the moment of calling of `git_transaction_free` cannot be controlled in all situations. Some binding libs call `git_transaction_free` on garbage collection or not at all if the application exits before and don't provide public access to `git_transaction_free`. It is better to release locks as soon as possible.
* refs: fix locks getting forcibly removedSebastian Henke2019-10-101-0/+21
| | | | | | | | | | | | | | | | | The flag GIT_FILEBUF_FORCE currently does two things: 1. It will cause the filebuf to create non-existing leading directories for the file that is about to be written. 2. It will forcibly remove any pre-existing locks. While most call sites actually do want (1), they do not want to remove pre-existing locks, as that renders the locking mechanisms effectively useless. Introduce a new flag `GIT_FILEBUF_CREATE_LEADING_DIRS` to separate both behaviours cleanly from each other and convert callers to use it instead of `GIT_FILEBUF_FORCE` to have them honor locked files correctly. As this conversion removes all current users of `GIT_FILEBUF_FORCE`, this commit removes the flag altogether.
* smart: use push_glob instead of manual filteringEtienne Samson2019-08-212-4/+6
| | | | | | | | | | 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.
* fileops: rename to "futils.h" to match function signaturesPatrick Steinhardt2019-07-206-6/+6
| | | | | | | | | Our file utils functions all have a "futils" prefix, e.g. `git_futils_touch`. One would thus naturally guess that their definitions and implementation would live in files "futils.h" and "futils.c", respectively, but in fact they live in "fileops.h". Rename the files to match expectations.
* refs: loosen restriction on wildcard "*" refspecsPatrick Steinhardt2019-04-261-6/+6
| | | | | | | | | | | | In commit cd377f45c9 (refs: loosen restriction on wildcard "*" refspecs, 2015-07-22) in git.git, the restrictions on wildcard "*" refspecs has been loosened. While wildcards were previously only allowed if the component is a single "*", this was changed to also accept other patterns as part of the component. We never adapted to that change and still reject any wildcard patterns that aren't a single "*" only. Update our tests to reflect the upstream change and adjust our own code accordingly.
* branch: add test for git_branch_lookup to accept GIT_BRANCH_ALLAugustin Fabre2019-02-221-2/+25
|
* branch: fix `branch_is_checked_out` with bare reposPatrick Steinhardt2019-02-141-0/+7
| | | | | | | | | | In a bare repository, HEAD usually points to the branch that is considered the "default" branch. As the current implementation for `git_branch_is_checked_out` only does a comparison of HEAD with the branch that is to be checked, it will say that the branch pointed to by HEAD in such a bare repo is checked out. Fix this by skipping the main repo's HEAD when it is bare.
* branches: do not assert that the given ref is a branchPatrick Steinhardt2019-02-141-0/+7
| | | | | | | | | | | | | | | | | Libraries should use assert(3P) only very scarcely. First, we usually shouldn't cause the caller of our library to abort in case where the assert fails. Second, if code is compiled with -DNDEBUG, then the assert will not be included at all. In our `git_branch_is_checked_out` function, we have an assert that verifies that the given reference parameter is non-NULL and in fact a branch. While the first check is fine, the second is not. E.g. when compiled with -DNDEBUG, we'd proceed and treat the given reference as a branch in all cases. Fix the issue by instead treating a non-branch reference as not being checked out. This is the obvious solution, as references other than branches cannot be directly checked out.
* branches: add tests for `git_branch_is_checked_out`Patrick Steinhardt2019-02-141-0/+39
| | | | | We currently do not have any tests at all for the `git_branch_is_checked_out` function. Add some basic ones.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-225-13/+13
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* references: use new names in internal usageethomson/git_refEdward Thomson2019-01-178-150/+150
| | | | Update internal usage to use the `git_reference` names for constants.
* Merge pull request #4833 from csware/drop-empty-dirsPatrick Steinhardt2018-12-191-0/+46
|\ | | | | Remove empty (sub-)directories when deleting refs
| * Remove empty directories when deleting refsSven Strickroth2018-10-131-0/+46
| | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>