tests/worktree


Log

Author Commit Date CI Message
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.
Etienne Samson 8356bf7e 2018-06-29T14:39:14 tests: worktree/bare: test some paths
Etienne Samson d0921127 2018-06-29T14:39:13 tests: add a helper to build sandbox subpaths quickly
Etienne Samson 83c35f7e 2018-06-29T14:39:11 tests: worktree/bare: fix git_worktree_validate
Etienne Samson bd40f0d7 2018-06-29T14:39:10 tests: worktree/bare: check git_worktree_list
Etienne Samson 7e3c13e0 2018-06-29T14:39:08 tests: worktree/bare: gather all tests
Patrick Steinhardt ecf4f33a 2018-02-08T11:14:48 Convert usage of `git_buf_free` to new `git_buf_dispose`
Etienne Samson a82082d0 2018-04-20T08:38:50 worktree: a worktree can be made from a bare repository
Patrick Steinhardt b33b6d33 2018-04-30T09:27:47 Merge pull request #4640 from mkeeler/worktree-convenience2 worktree: add functions to get name and path
Patrick Steinhardt 5ace1494 2018-04-26T11:45:38 Merge pull request #4633 from csware/worktree-delereref Fix deletion of unrelated branch on worktree
Matt Keeler 3da1ad20 2018-04-24T17:09:34 worktree: add functions to get name and path
Patrick Steinhardt 0ad2372b 2018-04-20T21:25:01 Merge pull request #4636 from tiennou/fix/leaks Fix leaks in master
Patrick Steinhardt 8d138f89 2018-04-20T20:28:48 Merge pull request #4577 from csware/reflog-worktree-head worktree: Read worktree specific reflog for HEAD
Etienne Samson 25100d6d 2018-04-19T19:17:07 tests: free the worktree in add_with_explicit_branch 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)
Sven Strickroth fd7b5bc3 2018-04-20T12:54:41 Fix deletion of unrelated branch on worktree Signed-off-by: Sven Strickroth <email@cs-ware.de>
Edward Thomson 8529ac9b 2018-04-17T23:38:46 Merge pull request #4524 from pks-t/pks/worktree-refs worktree: add ability to create worktree with pre-existing branch
Etienne Samson 2dc54855 2018-04-10T23:49:44 tests: ensure worktrees' head have owners too
Sven Strickroth eb0a3afd 2018-03-11T15:35:56 worktree: Read worktree specific reflog for HEAD Signed-off-by: Sven Strickroth <email@cs-ware.de>
Patrick Steinhardt a22f19e6 2018-02-09T10:38:11 worktree: add ability to create worktree with pre-existing branch 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.
Patrick Steinhardt 883eeb5f 2017-05-02T12:35:59 worktree: switch over worktree pruning to an opts structure 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.
Patrick Steinhardt 8264a30f 2017-05-02T10:11:28 worktree: support creating locked worktrees 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.
Patrick Steinhardt a7aa73a5 2017-05-02T10:02:36 worktree: introduce git_worktree_add options 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.
Patrick Steinhardt 2a485dab 2017-04-04T18:55:57 refs: update worktree HEADs when renaming branches 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.
Patrick Steinhardt 60297256 2017-04-04T16:12:27 tests: worktree::refs: convert spaces to tabs
Patrick Steinhardt b0c9bc92 2017-03-15T13:38:54 submodule: resolve URLs relative to main worktree 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.
Patrick Steinhardt 097f0105 2017-03-17T08:54:53 refdb: create references in commondir 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.
Patrick Steinhardt 8f154be3 2017-03-17T08:13:59 worktree: write resolved paths into link files 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.
Patrick Steinhardt 20a368e2 2017-03-15T15:29:29 worktree: parent path should point to the working dir 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.
Patrick Steinhardt 3017ba94 2017-03-15T14:24:25 worktree: implement `git_worktree_open_from_repository` 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.
Patrick Steinhardt f3c30686 2017-03-15T15:04:24 tests: worktree: use joinpath instead of printf to join paths
Patrick Steinhardt fdb3e24a 2017-03-15T14:23:59 tests: worktree: unify init/cleanup in open tests
Patrick Steinhardt 548e5bdf 2017-03-15T12:28:05 tests: worktree: unify init/cleanup in submodule tests
Patrick Steinhardt aa593a65 2017-03-15T12:01:02 tests: worktree: move submodule tests into own suite
Patrick Steinhardt 3f3a4ce7 2016-11-09T14:18:22 worktree: test opening worktree via gitlink, gitdir and worktree
Patrick Steinhardt 6f6dd17c 2016-11-08T12:13:59 worktree: test creating and opening submodule worktrees
Patrick Steinhardt 1fd6e035 2016-11-07T10:23:34 worktree: test opening discovered submodule worktrees
Patrick Steinhardt 39abd3ad 2016-11-04T13:39:54 worktree: compute workdir for worktrees opened via their gitdir 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.
Patrick Steinhardt 84f56cb0 2016-11-04T11:59:52 repository: rename `path_repository` and `path_gitlink` 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.
Patrick Steinhardt 384518d0 2015-10-27T14:17:52 repository: restrict checking out checked out branches If a branch is already checked out in a working tree we are not allowed to check out that branch in another repository. Introduce this restriction when setting a repository's HEAD.
Patrick Steinhardt 143e539f 2015-11-06T12:33:59 branch: restrict branch deletion for worktrees Restrict the ability to delete branches that are checked out in any linked repository.
Patrick Steinhardt 4321595d 2015-11-10T16:54:48 worktree: test basic merge functionality
Patrick Steinhardt 04fb12ab 2015-10-27T12:37:51 worktree: implement functions reading HEAD Implement `git_repository_head_for_worktree` and `git_repository_head_detached_for_worktree` for directly accessing a worktree's HEAD without opening it as a `git_repository` first.
Patrick Steinhardt f0cfc341 2015-10-21T13:53:18 worktree: implement `git_worktree_prune` Implement the `git_worktree_prune` function. This function can be used to delete working trees from a repository. According to the flags passed to it, it can either delete the working tree's gitdir only or both gitdir and the working directory.
Patrick Steinhardt 2a503485 2015-10-21T16:03:04 worktree: implement locking mechanisms Working trees support locking by creating a file `locked` inside the tree's gitdir with an optional reason inside. Support this feature by adding functions to get and set the locking status.
Patrick Steinhardt dea7488e 2015-10-23T14:11:44 worktree: implement `git_worktree_add` Implement the `git_worktree_add` function which can be used to create new working trees for a given repository.
Patrick Steinhardt 372dc9ff 2015-10-21T13:49:55 worktree: implement `git_worktree_validate` Add a new function that checks wether a given `struct git_worktree` is valid. The validation includes checking if the gitdir, parent directory and common directory are present.
Patrick Steinhardt 8c8d726e 2015-10-21T12:10:30 worktree: implement `git_repository_open_from_worktree` Add function `git_repository_open_from_worktree`, which allows to open a `git_worktree` as repository.
Patrick Steinhardt d3bc09e8 2015-10-21T12:02:31 worktree: introduce `struct git_worktree` Introduce a new `struct git_worktree`, which holds information about a possible working tree connected to a repository. Introduce functions to allow opening working trees for a repository.
Patrick Steinhardt 45f2b7a4 2015-10-21T11:48:02 worktree: implement `git_worktree_list` Add new module for working trees with the `git_worktree_list` function. The function lists names for all working trees of a certain repository.
Patrick Steinhardt 4292837d 2015-09-24T14:37:10 config: open configuration in commondir A repository's configuartion file can always be found in the GIT_COMMON_DIR, which has been newly introduced. For normal repositories this does change nothing, but for working trees this change allows to access the shared configuration file.
Patrick Steinhardt e9403024 2015-09-24T15:32:26 refdb: look for reflog in commondir
Patrick Steinhardt e0a6c28e 2015-09-16T16:09:24 refdb: introduce commondir awareness The refdb_fs_backend is not aware of the git commondir, which stores common objects like the o bject database and packed/loose refereensces when worktrees are used. Make refdb_fs_backend aware of the common directory by introducing a new commonpath variable that points to the actual common path of the database and using it instead of the gitdir for the mentioned objects.
Patrick Steinhardt 79ab3ef6 2015-10-15T15:58:05 repository: introduce is_worktree variable
Patrick Steinhardt c09fd54e 2015-09-16T12:10:11 repository: introduce commondir variable The commondir variable stores the path to the common directory. The common directory is used to store objects and references shared across multiple repositories. A current use case is the newly introduced `git worktree` feature, which sets up a separate working copy, where the backing git object store and references are pointed to by the common directory.
Patrick Steinhardt 807d57e7 2015-11-11T10:54:41 tests: implement worktree helpers