tests/refs


Log

Author Commit Date CI Message
lhchavez d15b6132 2021-07-30T07:18:57 Fix one memory leak in master There was one test that wasn't correctly disposing of the repository.
Edward Thomson cc68c19a 2021-07-30T08:56:51 Merge branch 'pr/5861'
Edward Thomson f2915ec4 2021-07-30T08:56:34 tests: reformat upstream merge
Dmitry Lobanov 55f2abb8 2021-06-18T15:47:15 tests: upstream merge test has been added.
Edward Thomson 1b1e541d 2021-05-18T11:52:51 tests: clean up refs::races zero oid test
Edward Thomson 58944388 2021-05-16T11:11:56 Merge branch 'zero_oid_in_old' Manually merging #5842
Edward Thomson cf323cb9 2021-05-16T11:09:44 refs: test git_reference_create_matching failure for zero oid
Edward Thomson b31795ef 2021-05-06T01:46:19 test: clean up memory leaks
Edward Thomson e5851c62 2021-04-24T09:44:45 refs: ensure loose refs adhere to path validation 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.
David Turner 95b7a639 2021-04-14T21:52:36 git_reference_create_matching: Treat all-zero OID as "must be absent" 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.
Edward Thomson 4732e030 2021-01-31T00:36:54 revspec: rename git_revparse_mode_t to git_revspec_t 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.
Sven Strickroth 0caa4655 2020-09-09T10:48:00 Add git_tag_name_is_valid Signed-off-by: Sven Strickroth <email@cs-ware.de>
Sven Strickroth fe11160c 2020-09-08T21:05:18 Add git_branch_name_is_valid Signed-off-by: Sven Strickroth <email@cs-ware.de>
Edward Thomson b52bb4d4 2020-10-11T13:20:52 refs: use git_reference_name_is_valid
Patrick Steinhardt 9703d26f 2020-06-29T12:22:27 tests: reflog: remove unused signature There's two tests that create a commit signature, but never make any use of it. Let's remove these to avoid any confusion.
Patrick Steinhardt 9e4e25b1 2020-06-08T12:57:48 tests: refs: modernize coding style of testcase 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.
Edward Thomson cad7a1ba 2020-06-05T08:42:38 clar: include the function name
Edward Thomson 51eff5a5 2020-05-29T13:13:19 strarray: we should `dispose` instead of `free` 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.
Josh Bleecher Snyder 852c83ee 2020-01-15T13:31:21 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
Etienne Samson 97b8491b 2019-12-08T15:25:52 refs: rename git_reference__set_name to git_reference__realloc 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.
Edward Thomson bf2911d7 2019-11-02T07:30:32 Merge pull request #5275 from pks-t/pks/reflogs-with-newlines reflogs: fix behaviour around reflogs with newlines
Patrick Steinhardt 7968e90f 2019-10-18T12:33:07 refdb_fs: properly parse corrupted reflogs 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.
Patrick Steinhardt d8233feb 2019-10-18T09:24:14 reflog: allow adding entries with newlines in their message 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.
Sebastian Henke 47531f47 2019-10-11T12:44:09 refs: unlock unmodified refs on transaction commit 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.
Sebastian Henke 3335a034 2019-10-10T15:28:46 refs: fix locks getting forcibly removed 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.
Etienne Samson 39d18fe6 2019-07-31T08:37:10 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.
Patrick Steinhardt e54343a4 2019-06-29T09:17:32 fileops: rename to "futils.h" to match function signatures 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.
Patrick Steinhardt 51214b85 2019-04-26T10:15:49 refs: loosen restriction on wildcard "*" refspecs 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.
Augustin Fabre 0a25141e 2019-02-21T21:42:25 branch: add test for git_branch_lookup to accept GIT_BRANCH_ALL
Patrick Steinhardt bf013fc0 2019-02-14T13:30:33 branch: fix `branch_is_checked_out` with bare repos 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.
Patrick Steinhardt 788cd2d5 2019-02-14T13:49:35 branches: do not assert that the given ref is a branch 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.
Patrick Steinhardt a0f87e16 2019-02-14T13:26:30 branches: add tests for `git_branch_is_checked_out` We currently do not have any tests at all for the `git_branch_is_checked_out` function. Add some basic ones.
Edward Thomson f673e232 2018-12-27T13:47:34 git_error: use new names in internal APIs and usage Move to the `git_error` name in the internal API for error-related functions.
Edward Thomson ed8cfbf0 2019-01-17T00:32:31 references: use new names in internal usage Update internal usage to use the `git_reference` names for constants.
Patrick Steinhardt bc219657 2018-12-19T11:01:55 Merge pull request #4833 from csware/drop-empty-dirs Remove empty (sub-)directories when deleting refs
Edward Thomson 168fe39b 2018-11-28T14:26:57 object_type: use new enumeration names Use the new object_type enumeration names within the codebase.
Etienne Samson e226ad8f 2018-11-17T17:55:10 refs: add support for core.logAllRefUpdates=always Since we were not expecting this config entry to contain a string, we would fail as soon as its (cached) value would be accessed. Hence, provide some constants for the 4 states we use, and account for "always" when we decide to reflog changes.
Sven Strickroth 9f48dc3b 2018-10-05T12:47:32 Remove empty directories when deleting refs Signed-off-by: Sven Strickroth <email@cs-ware.de>
Patrick Steinhardt 9994cd3f 2018-06-25T11:56:52 treewide: remove use of C++ style comments C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
Patrick Steinhardt ecf4f33a 2018-02-08T11:14:48 Convert usage of `git_buf_free` to new `git_buf_dispose`
Julian Ganz d7eca4c3 2018-06-01T08:57:17 refdb_fs: add test for globbing of nonexistant refs
Patrick Steinhardt 0750d0cc 2018-05-04T15:25:22 tests: refs::normalize: simplify code to avoid GCC warning Since version 8.1, GCC will do some automatic bounds checking when printing static content into a buffer with known size. The bounds checking doesn't yet work quite right in all scenarios and may thus lead to false positives. Fix one of these false positives in refs::normalize by simplifying the code.
Etienne Samson 5e19a7f9 2018-04-10T21:16:43 refs: preserve the owning refdb when duping reference This fixes a segfault in git_reference_owner on references returned from git_reference__read_head and git_reference_dup ones.
Edward Thomson 18d9c847 2018-02-20T00:32:38 testrepo: add new branch Add a new branch to the `testrepo` repository, where the `README` file has changed to executable. This branch enables typechange tests between the new `executable` branch and `master`.
Patrick Steinhardt 782402c2 2018-01-12T13:09:23 tests: refs::iterator: fix memory leak due to ref names not being free'd The test refs::iterator::foreach_name iterates through every reference and copies its name into a local vector. While the test makes sure to free the vector afterwards, the copied reference names are not being free'd. Fix that.
Edward Thomson 7a830f28 2017-12-30T00:46:17 refs:iterator: add tests to recurse symlinks Ensure that we can recurse into directories via symbolic links.
Etienne Samson da635eda 2017-11-22T23:47:29 tests: move free functions at the end
Etienne Samson ebe5d8ec 2017-07-21T20:12:01 tests: move static method to the top
Etienne Samson f01a8587 2017-07-21T17:45:44 tests: make reflog_check_entry more clar-y
Etienne Samson b9b1f9f8 2017-07-14T03:21:02 tests: clarify which steps corresponds to each checks
Etienne Samson 53672128 2017-07-21T17:35:30 tests: gather the reflog entry content tests
Patrick Steinhardt b112b1e9 2017-10-06T11:24:11 refs: do not use peeled OID if peeling to a tag If a reference stored in a packed-refs file does not directly point to a commit, tree or blob, the packed-refs file will also will include a fully-peeled OID pointing to the first underlying object of that type. If we try to peel a reference to an object, we will use that peeled OID to speed up resolving the object. As a reference for an annotated tag does not directly point to a commit, tree or blob but instead to the tag object, the packed-refs file will have an accomodating fully-peeled OID pointing to the object referenced by that tag. When we use the fully-peeled OID pointing to the referenced object when peeling, we obviously cannot peel that to the tag anymore. Fix this issue by not using the fully-peeled OID whenever we want to peel to a tag. Note that this does not include the case where we want to resolve to _any_ object type. Existing code may make use from the fact that we resolve those to commit objects instead of tag objects, even though that behaviour is inconsistent between packed and loose references. Furthermore, some tests of ours make the assumption that we in fact resolve those references to a commit.
Patrick Steinhardt b6ed67c2 2017-05-10T12:54:14 tests: refs::crashes: create sandbox for creating symref The test `refs::crashes::double_free` operates on our in-source "testrepo.git" repository without creating a copy first. As the test will try to create a new symbolic reference, this will fail when we want to do a pure out-of-tree build with a read-only source tree. Fix the issue by creating a sandbox first.
Patrick Steinhardt 6c23704d 2017-06-08T21:40:18 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.
William Bain 8b107dc5 2017-05-03T11:20:57 revparse: support open-ended ranges Support '..' and '...' ranges where one side is not specified. The unspecified side defaults to HEAD. Closes #4223
Edward Thomson 6fd6c678 2017-03-22T20:29:22 Merge pull request #4030 from libgit2/ethomson/fsync fsync all the things
Edward Thomson d24ae06d 2017-03-06T13:13:47 refs::namespace: add namespace tests These simple tests only ensure that we enforce the existence of a namespace; these mirror the rugged tests, they are not exhaustive.
Edward Thomson 1c04a96b 2017-02-28T12:29:29 Honor `core.fsyncObjectFiles`
Patrick Steinhardt 5aa1f12a 2017-03-01T07:45:14 tests: refs::create: fix memory leak
Patrick Steinhardt cf8e9a3a 2017-03-01T07:35:44 Merge pull request #4143 from richardipsum/issue-4094 Fix: make reflog include "(merge)" for merge commits
Richard Ipsum 397cf1a1 2017-02-28T22:22:02 Add test for inclusion of (merge) in reflog This test ensures that the string '(merge)' is included in the reflog when a merge commit is made.
Edward Thomson 3ac05d11 2017-02-17T16:48:03 win32: don't fsync parent directories on Windows Windows doesn't support it.
Edward Thomson 2a5ad7d0 2017-02-17T16:42:40 fsync: call it "synchronous" object writing Rename `GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION` -> `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`.
Edward Thomson 1229e1c4 2017-02-17T16:36:53 fsync parent directories when fsyncing When fsync'ing files, fsync the parent directory in the case where we rename a file into place, or create a new file, to ensure that the directory entry is flushed correctly.
Edward Thomson eb56ed81 2016-12-15T14:49:43 refdb_fs: optionally fsync packed refs
Edward Thomson af3dcb0e 2016-12-15T10:56:52 refdb_fs: optionally fsync loose references
Richard Ipsum b84e58f4 2017-02-25T14:17:10 Whitespace and style fixes Use C style comments as per style guide, and fix mismatching indentation.
Richard Ipsum d2b3a21f 2017-01-22T00:21:30 tests: Add create__symbolic_with_arbitrary_content This test ensures that it's possible to create a symbolic ref that has arbitrary data as its target. It also ensures it's possible to obtain the target of that symbolic reference from the git_reference object.
Patrick Steinhardt 8acc3b16 2015-11-10T15:53:09 tests: add merge-conflict branch for testrepo Add a new branch that causes a merge conflict to `testrepo` so that we are able to test merging in worktrees.
Patrick Steinhardt bd9f4fd2 2015-11-11T10:54:08 tests: add worktree test data
Edward Thomson 8f0d5cde 2016-12-29T12:55:49 tests: update error message checking
John Fultz f9793884 2016-10-28T14:32:01 branch: fix forced branch creation on HEAD of a bare repo The code correctly detects that forced creation of a branch on a nonbare repo should not be able to overwrite a branch which is the HEAD reference. But there's no reason to prevent this on a bare repo, and in fact, git allows this. I.e., git branch -f master new_sha works on a bare repo with HEAD set to master. This change fixes that problem, and updates tests so that, for this case, both the bare and nonbare cases are checked for correct behavior.
Arthur Schreiber 908f24fd 2016-04-22T10:34:17 Allow creating copies of `git_reference` objects.
Edward Thomson 0e00eecf 2016-04-11T13:29:54 Merge pull request #3736 from libgit2/cmn/dwim-general-message refs: provide a more general error message for dwim
Edward Thomson d22a8b95 2016-04-11T11:50:11 refs::create: strict object creation on by default When we turned strict object creation validation on by default, we forgot to inform the refs::create tests of this. They, in fact, believed that strict object creation was off by default. As a result, their cleanup function went and turned strict object creation off for the remaining tests.
Carlos Martín Nieto 77965c68 2016-04-11T17:43:07 refs: provide a more general error message for dwim If we cannot dwim the input, set the error message to be explicit about that. Otherwise we leave the error for the last failed lookup, which can be rather unexpected as it mentions a remote when the user thought they were trying to look up a branch.
Carlos Martín Nieto 9b3fc895 2016-03-03T11:17:36 tests: plug a leak
Edward Thomson 98c34149 2016-02-28T15:11:15 refs: honor strict object creation
Edward Thomson 0a700ee3 2015-11-03T17:34:54 reflog: error when a directory is at reflog path When a non-empty directory exists and prevents the creation of a reflog, provide a more informative error message.
Edward Thomson b46c7ee5 2015-11-03T17:18:00 refs: complain when a directory exists at ref When a (non-empty) directory exists at the reference target location, complain with a more actionable error message.
Edward Thomson 2d556f31 2015-11-03T14:48:31 reflog: test reflog is deleted when ref is deleted
Stjepan Rajko 335c9e2f 2015-10-26T15:33:00 Prevent segfault when parsing a reflog with oid parse error Using calloc instead of malloc because the parse error will lead to an immediate free of committer (and its properties, which can segfault on free if undefined - test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_returns_error segfaulted before the fix). #3458
Edward Thomson ac2fba0e 2015-09-16T15:07:27 git_futils_mkdir_*: make a relative-to-base mkdir Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter assumes that we own everything beneath the base, as if it were being called with a base of the repository or working directory, and is tailored towards checkout and ensuring that there is no bogosity beneath the base that must be cleaned up. This is (at best) slow and (at worst) unsafe in the larger context of a filesystem where we do not own things and cannot do things like unlink symlinks that are in our way.
Carlos Martín Nieto 01d0c02d 2015-07-12T19:08:06 refdb: delete a ref's reflog upon deletion Removing a reflog upon ref deletion is something which only some backends might wish to do. Backends which are database-backed may wish to archive a reflog, log-based ones may not need to do anything.
Vicent Marti a2f8d1ae 2015-06-26T16:48:58 revparse: Add test to make sure this doesn't regress
Carlos Martín Nieto 5014fe95 2015-05-22T12:24:09 branch: error out if we cannot find the remote When we look for which remote corresponds to a remote-tracking branch, we look in the refspecs to see which ones matches. If none do, we should abort. We currently ignore the error message from this operation, so let's not do that anymore. As part of the test we're writing, let's test for the expected behaviour if we cannot find a refspec which tells us what the remote-tracking branch for a remote would look like.
Carlos Martín Nieto 77254990 2015-04-23T06:51:34 remote: remove live changing of refspecs The base refspecs changing can be a cause of confusion as to what is the current base refspec set and complicate saving the remote's configuration. Change `git_remote_add_{fetch,push}()` to update the configuration instead of an instance. This finally makes `git_remote_save()` a no-op, it will be removed in a later commit.
Carlos Martín Nieto a5815a2a 2015-03-07T00:30:40 Add tests for the annotated versions of ref-modifying functions This also brings the soft-reset tests back to life. The function name was missing an underscore, meaning they had not been running.
Carlos Martín Nieto d578b45f 2015-03-08T16:46:33 refdb: use the same id for old and new when renaming a reference When we rename a reference, we want the old and new ids to be the same one (as we did not change it). The normal code path looks up the old id from the current value of the brtanch, but by the time we look it up, it does not exist anymore and thus we write a zero id. Pass the old id explicitly instead.
nulltoken 7eb76734 2015-03-04T22:01:20 branch: fix generated reflog message upon renaming
nulltoken 015d4b7b 2015-03-04T21:48:54 branch: fix generated reflog message upon creation
Carlos Martín Nieto 9a97f49e 2014-12-21T15:31:03 config: borrow refcounted references This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
Carlos Martín Nieto 4e498646 2015-01-15T16:50:31 repository: remove log message override for switching the active branch We want to use the "checkout: moving from ..." message in order to let git know when a change of branch has happened. Make the convenience functions for this goal write this message.
Carlos Martín Nieto 6bfb990d 2015-01-07T14:47:02 branch: don't accept a reflog message override This namespace is about behaving like git's branch command, so let's do exactly that instead of taking a reflog message. This override is still available via the reference namespace.
Carlos Martín Nieto 659cf202 2015-01-07T12:23:05 Remove the signature from ref-modifying functions The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.
Carlos Martín Nieto d24a5312 2015-02-12T02:34:58 Merge pull request #2866 from ethomson/checkout_perf2 Checkout performance
Jeff Hostetler 1589a93a 2015-02-02T16:50:10 Fix branch creation when branch name matches namespace of previously deleted branch
Edward Thomson 60561d54 2015-02-03T03:36:07 tests: update for new test data
Edward Thomson ee5da720 2014-12-02T22:20:42 reference_create: validate loose names Validate loose reference names on Win32.
Carlos Martín Nieto 753e17b0 2014-11-19T18:42:29 peel: reject bad queries with EINVALIDSPEC There are some combination of objects and target types which we know cannot be fulfilled. Return EINVALIDSPEC for those to signify that there is a mismatch in the user-provided data and what the object model is capable of satisfying. If we start at a tag and in the course of peeling find out that we cannot reach a particular type, we return EPEEL.