summaryrefslogtreecommitdiff
path: root/tests/worktree
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* repository: restrict checking out checked out branchesPatrick Steinhardt2017-02-131-0/+35
| | | | | | 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.
* branch: restrict branch deletion for worktreesPatrick Steinhardt2017-02-131-0/+27
| | | | | Restrict the ability to delete branches that are checked out in any linked repository.
* worktree: test basic merge functionalityPatrick Steinhardt2017-02-131-0/+121
|
* worktree: implement functions reading HEADPatrick Steinhardt2017-02-132-0/+64
| | | | | | 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.
* worktree: implement `git_worktree_prune`Patrick Steinhardt2017-02-131-0/+58
| | | | | | | 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.
* worktree: implement locking mechanismsPatrick Steinhardt2017-02-131-0/+59
| | | | | | 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.
* worktree: implement `git_worktree_add`Patrick Steinhardt2017-02-131-0/+83
| | | | | Implement the `git_worktree_add` function which can be used to create new working trees for a given repository.
* worktree: implement `git_worktree_validate`Patrick Steinhardt2017-02-131-0/+50
| | | | | | 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.
* worktree: implement `git_repository_open_from_worktree`Patrick Steinhardt2017-02-131-0/+72
| | | | | Add function `git_repository_open_from_worktree`, which allows to open a `git_worktree` as repository.
* worktree: introduce `struct git_worktree`Patrick Steinhardt2017-02-131-1/+27
| | | | | | | 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.
* worktree: implement `git_worktree_list`Patrick Steinhardt2017-02-131-0/+107
| | | | | | Add new module for working trees with the `git_worktree_list` function. The function lists names for all working trees of a certain repository.
* config: open configuration in commondirPatrick Steinhardt2017-02-131-0/+45
| | | | | | | 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.
* refdb: look for reflog in commondirPatrick Steinhardt2017-02-131-0/+65
|
* refdb: introduce commondir awarenessPatrick Steinhardt2017-02-131-0/+68
| | | | | | | | | | | 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.
* repository: introduce is_worktree variablePatrick Steinhardt2017-02-131-0/+11
|
* repository: introduce commondir variablePatrick Steinhardt2017-02-131-0/+60
| | | | | | | | | 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.
* tests: implement worktree helpersPatrick Steinhardt2017-02-132-0/+41