summaryrefslogtreecommitdiff
path: root/tests/worktree
Commit message (Collapse)AuthorAgeFilesLines
* tests: don't generate false positives on empty path segmentsPeter Pettersson2021-08-082-11/+12
|
* Apply suggestions from code reviewEdward Thomson2020-11-212-1/+1
|
* worktree: change test to invalidate worktree via filesystemReginald McLean2020-11-072-4/+2
|
* worktree: Demonstrate missing worktree checkReginald McLean2020-11-061-0/+14
| | | | worktree_dir isn't validated when it should be
* tests: verify renaming branch really updates worktree HEADPatrick Steinhardt2020-07-121-1/+4
| | | | | | | | | | | In case where a branch is getting renamed, all HEADs of the main repository and of its worktrees that point to the old branch need to get updated to point to the new branch. We already do so and have a test for this, but the test only verifies that we're able to lookup the updated HEAD, not what it contains. Let's make the test more specific by verifying the updated HEAD also has the correct updated symbolic target.
* repository: retrieve worktree HEAD via refdbPatrick Steinhardt2020-07-121-1/+4
| | | | | | | | | | The function `git_repository_head_for_worktree` currently uses `git_reference__read_head` to directly read a given worktree's HEAD from the filesystem. This is broken in case the repository uses a different refdb implementation than the filesystem-based one, so let's instead open the worktree as a real repository and use `git_reference_lookup`. This also fixes the case where the worktree's HEAD is not a symref, but a detached HEAD, which would have resulted in an error previously.
* repository: remove function to iterate over HEADsPatrick Steinhardt2020-07-121-43/+0
| | | | | | | | The function `git_repository_foreach_head` is broken, as it directly interacts with the on-disk representation of the reference database, thus assuming that no other refdb is used for the given repository. As this is an internal function only and all users have been replaced, let's remove this function.
* repository: introduce new function to iterate over all worktreesPatrick Steinhardt2020-07-121-0/+30
| | | | | | | Given a Git repository, it's non-trivial to iterate over all worktrees that are associated with it, including the "main" repository. This commit adds a new internal function `git_repository_foreach_worktree` that does this for us.
* strarray: we should `dispose` instead of `free`Edward Thomson2020-06-013-8/+8
| | | | | | 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.
* worktree: use size_t in testsEdward Thomson2019-06-241-1/+1
|
* branches: introduce flag to skip enumeration of certain HEADsPatrick Steinhardt2019-02-141-2/+2
| | | | | | | Right now, the function `git_repository_foreach_head` will always iterate over all HEADs of the main repository and its worktrees. In some cases, it might be required to skip either of those, though. Add a flag in preparation for the following commit that enables this behaviour.
* worktree: unlock should return 1 when the worktree isn't lockedEtienne Samson2018-08-171-2/+2
| | | | | The documentation states that git_worktree_unlock returns 0 on success, and 1 on success if the worktree wasn't locked. Turns out we were returning 0 in any of those cases.
* treewide: remove use of C++ style commentsPatrick Steinhardt2018-07-131-2/+4
| | | | | | | | | 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.
* tests: worktree/bare: test some pathsEtienne Samson2018-06-291-0/+18
|
* tests: add a helper to build sandbox subpaths quicklyEtienne Samson2018-06-291-20/+3
|
* tests: worktree/bare: fix git_worktree_validateEtienne Samson2018-06-291-0/+2
|
* tests: worktree/bare: check git_worktree_listEtienne Samson2018-06-291-0/+5
|
* tests: worktree/bare: gather all testsEtienne Samson2018-06-292-32/+47
|
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-105-29/+29
|
* worktree: a worktree can be made from a bare repositoryEtienne Samson2018-05-071-0/+20
|
* Merge pull request #4640 from mkeeler/worktree-convenience2Patrick Steinhardt2018-04-301-0/+23
|\ | | | | worktree: add functions to get name and path
| * worktree: add functions to get name and pathMatt Keeler2018-04-251-0/+23
| |
* | Merge pull request #4633 from csware/worktree-delererefPatrick Steinhardt2018-04-261-0/+22
|\ \ | | | | | | Fix deletion of unrelated branch on worktree
| * | Fix deletion of unrelated branch on worktreeSven Strickroth2018-04-201-0/+22
| | | | | | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | | Merge pull request #4636 from tiennou/fix/leaksPatrick Steinhardt2018-04-201-0/+1
|\ \ \ | | | | | | | | Fix leaks in master
| * | | tests: free the worktree in add_with_explicit_branchEtienne Samson2018-04-201-0/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Valgrind log: ==2711== 305 (48 direct, 257 indirect) bytes in 1 blocks are definitely lost in loss record 576 of 624 ==2711== at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==2711== by 0x5E079E: git__calloc (util.h:99) ==2711== by 0x5E0D21: open_worktree_dir (worktree.c:134) ==2711== by 0x5E0F23: git_worktree_lookup (worktree.c:176) ==2711== by 0x5E1972: git_worktree_add (worktree.c:388) ==2711== by 0x551F23: test_worktree_worktree__add_with_explicit_branch (worktree.c:292) ==2711== by 0x45853E: clar_run_test (clar.c:222) ==2711== by 0x4587E1: clar_run_suite (clar.c:286) ==2711== by 0x458B04: clar_parse_args (clar.c:362) ==2711== by 0x458CAB: clar_test_run (clar.c:428) ==2711== by 0x45665C: main (main.c:24)
* | | Merge pull request #4577 from csware/reflog-worktree-headPatrick Steinhardt2018-04-201-0/+26
|\ \ \ | |/ / |/| | worktree: Read worktree specific reflog for HEAD
| * | worktree: Read worktree specific reflog for HEADSven Strickroth2018-03-271-0/+26
| |/ | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | Merge pull request #4524 from pks-t/pks/worktree-refsEdward Thomson2018-04-171-0/+30
|\ \ | | | | | | worktree: add ability to create worktree with pre-existing branch
| * | worktree: add ability to create worktree with pre-existing branchPatrick Steinhardt2018-02-091-0/+30
| |/ | | | | | | | | | | | | | | | | | | | | Currently, we always create a new branch after the new worktree's name when creating a worktree. In some workflows, though, the caller may want to check out an already existing reference instead of creating a new one, which is impossible to do right now. Add a new option `ref` to the options structure for adding worktrees. In case it is set, a branch and not already checked out by another worktree, we will re-use this reference instead of creating a new one.
* | tests: ensure worktrees' head have owners tooEtienne Samson2018-04-101-0/+1
|/
* worktree: switch over worktree pruning to an opts structurePatrick Steinhardt2017-05-052-8/+38
| | | | | | | | | | The current signature of `git_worktree_prune` accepts a flags field to alter its behavior. This is not as flexible as we'd like it to be when we want to enable passing additional options in the future. As the function has not been part of any release yet, we are still free to alter its current signature. This commit does so by using our usual pattern of an options structure, which is easily extendable without breaking the API.
* worktree: support creating locked worktreesPatrick Steinhardt2017-05-051-0/+25
| | | | | | | | | | | | | When creating a new worktree, we do have a potential race with us creating the worktree and another process trying to delete the same worktree as it is being created. As such, the upstream git project has introduced a flag `git worktree add --locked`, which will cause the newly created worktree to be locked immediately after its creation. This mitigates the race condition. We want to be able to mirror the same behavior. As such, a new flag `locked` is added to the options structure of `git_worktree_add` which allows the user to enable this behavior.
* worktree: introduce git_worktree_add optionsPatrick Steinhardt2017-05-022-6/+6
| | | | | | | | | The `git_worktree_add` function currently accepts only a path and name for the new work tree. As we may want to expand these parameters in future versions without adding additional parameters to the function for every option, this commit introduces our typical pattern of an options struct. Right now, this structure is still empty, which will change with the next commit.
* refs: update worktree HEADs when renaming branchesPatrick Steinhardt2017-04-052-0/+57
| | | | | | | Whenever we rename a branch, we update the repository's symbolic HEAD reference if it currently points to the branch that is to be renamed. But with the introduction of worktrees, we also have to iterate over all HEADs of linked worktrees to adjust them. Do so.
* tests: worktree::refs: convert spaces to tabsPatrick Steinhardt2017-04-051-14/+14
|
* submodule: resolve URLs relative to main worktreePatrick Steinhardt2017-03-171-0/+33
| | | | | | | | | | | | | | | It is possible to specify submodule URLs relative to the repository location. E.g. having a submodule with URL "../submodule" will look for the submodule at "repo/../submodule". With the introduction of worktrees, though, we cannot simply resolve the URL relative to the repository location itself. If the repository for which a URL is to be resolved is a working tree, we have to resolve the URL relative to the parent's repository path. Otherwise, the URL would change depending on where the working tree is located. Fix this by special-casing when we have a working tree while getting the URL base.
* refdb: create references in commondirPatrick Steinhardt2017-03-171-0/+26
| | | | | | | | | | | References for a repository are usually created inside of its gitdir. When using worktrees, though, these references are not to be created inside the worktree gitdir, but instead inside the gitdir of its parent repository, which is the commondir. Like this, branches will still be available after the worktree itself has been deleted. The filesystem refdb currently still creates new references inside of the gitdir. Fix this and have it create references in commondir.
* worktree: write resolved paths into link filesPatrick Steinhardt2017-03-171-0/+2
| | | | | | | | The three link files "worktree/.git", ".git/worktrees/<name>/commondir" and ".git/worktrees/<name>/gitdir" should always contain absolute and resolved paths. Adjust the logic creating new worktrees to first use `git_path_prettify_dir` before writing out these files, so that paths are resolved first.
* worktree: parent path should point to the working dirPatrick Steinhardt2017-03-171-1/+2
| | | | | | | | | The working tree's parent path should not point to the parent's gitdir, but to the parent's working directory. Pointing to the gitdir would not make any sense, as the parent's working directory is actually equal to both repository's common directory. Fix the issue.
* worktree: implement `git_worktree_open_from_repository`Patrick Steinhardt2017-03-171-0/+26
| | | | | | | | | While we already provide functionality to look up a worktree from a repository, we cannot do so the other way round. That is given a repository, we want to look up its worktree if it actually exists. Getting the worktree of a repository is useful when we want to get certain meta information like the parent's location, getting the locked status, etc.
* tests: worktree: use joinpath instead of printf to join pathsPatrick Steinhardt2017-03-151-1/+1
|
* tests: worktree: unify init/cleanup in open testsPatrick Steinhardt2017-03-151-26/+14
|
* tests: worktree: unify init/cleanup in submodule testsPatrick Steinhardt2017-03-151-39/+29
|
* tests: worktree: move submodule tests into own suitePatrick Steinhardt2017-03-152-65/+69
|
* worktree: test opening worktree via gitlink, gitdir and worktreePatrick Steinhardt2017-02-131-4/+77
|
* worktree: test creating and opening submodule worktreesPatrick Steinhardt2017-02-131-0/+28
|
* worktree: test opening discovered submodule worktreesPatrick Steinhardt2017-02-131-0/+27
|
* worktree: compute workdir for worktrees opened via their gitdirPatrick Steinhardt2017-02-132-5/+29
| | | | | | | | | | | | | | | | | | | | | When opening a worktree via the gitdir of its parent repository we fail to correctly set up the worktree's working directory. The problem here is two-fold: we first fail to see that the gitdir actually is a gitdir of a working tree and then subsequently fail to determine the working tree location from the gitdir. The first problem of not noticing a gitdir belongs to a worktree can be solved by checking for the existence of a `gitdir` file in the gitdir. This file points back to the gitlink file located in the working tree's working directory. As this file only exists for worktrees, it should be sufficient indication of the gitdir belonging to a worktree. The second problem, that is determining the location of the worktree's working directory, can then be solved by reading the `gitdir` file in the working directory's gitdir. When we now resolve relative paths and strip the final `.git` component, we have the actual worktree's working directory location.
* repository: rename `path_repository` and `path_gitlink`Patrick Steinhardt2017-02-132-7/+7
| | | | | | | | | | | | | The `path_repository` variable is actually confusing to think about, as it is not always clear what the repository actually is. It may either be the path to the folder containing worktree and .git directory, the path to .git itself, a worktree or something entirely different. Actually, the intent of the variable is to hold the path to the gitdir, which is either the .git directory or the bare repository. Rename the variable to `gitdir` to avoid confusion. While at it, also rename `path_gitlink` to `gitlink` to improve consistency.