Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fixture for linked-worktree #1

Merged
merged 1 commit into from
Jun 13, 2020

Conversation

distorhead
Copy link

Ported already existing PR: src-d/go-git-fixtures#21 (with rebase).

Fixtures are needed for the PR: go-git/go-git#88

@distorhead distorhead force-pushed the linked-worktree branch 3 times, most recently from f2b245f to ad47e53 Compare June 9, 2020 10:06
@distorhead distorhead marked this pull request as draft June 9, 2020 15:05
@distorhead distorhead marked this pull request as ready for review June 9, 2020 19:03
@distorhead distorhead marked this pull request as draft June 9, 2020 22:05
@distorhead distorhead marked this pull request as ready for review June 10, 2020 08:51
@mcuadros mcuadros merged commit f56387b into go-git:master Jun 13, 2020
@distorhead distorhead deleted the linked-worktree branch June 15, 2020 11:49
distorhead added a commit to distorhead/go-git that referenced this pull request Jun 15, 2020
Git creates `.git/commondir` when there are custom worktrees (see "git worktree add" related commands).

`.git/commondir` in such case contains a link to another dot-git repository tree, which could contain some folders like:
 - objects;
 - config;
 - refs;
 - etc.

In this PR a new dotgit.RepositoryFilesystem struct is defined, which is billy.Filesystem interface compatible object-wrapper, that can handle commondir and dispatch all operations to the correct file path.

`git.PlainOpen` remain unchanged, but `git.PlainOpenWithOptions` has a new option: `PlainOpenOptions.EnableDotGitCommonDir=true|false` (which is false by default). When `EnableDotGitCommonDir=true` repository-open procedure will read `.git/commondir` (if it exists) and then create dotgit.RepositoryFilesystem object initialized with 2 filesystems. This object then passed into storage and then into dotgit.DotGit as `billy.Filesystem` interface. This object will catch all filesystem operations and dispatch to the correct repository-filesystem (dot-git or common-dot-git) according to the rules described in the doc: https://git-scm.com/docs/gitrepository-layout#Documentation/gitrepository-layout.txt. EnableDotGitCommonDir option will only work with the filesystem-backed storage.

Also worktree_test.go has been adopted from an older, already existing existing PR: src-d/go-git#1098. This PR needs new fixtures added in the following PR: go-git/go-git-fixtures#1.
traidare pushed a commit to traidare/go-git that referenced this pull request Oct 26, 2024
Git creates `.git/commondir` when there are custom worktrees (see "git worktree add" related commands).

`.git/commondir` in such case contains a link to another dot-git repository tree, which could contain some folders like:
 - objects;
 - config;
 - refs;
 - etc.

In this PR a new dotgit.RepositoryFilesystem struct is defined, which is billy.Filesystem interface compatible object-wrapper, that can handle commondir and dispatch all operations to the correct file path.

`git.PlainOpen` remain unchanged, but `git.PlainOpenWithOptions` has a new option: `PlainOpenOptions.EnableDotGitCommonDir=true|false` (which is false by default). When `EnableDotGitCommonDir=true` repository-open procedure will read `.git/commondir` (if it exists) and then create dotgit.RepositoryFilesystem object initialized with 2 filesystems. This object then passed into storage and then into dotgit.DotGit as `billy.Filesystem` interface. This object will catch all filesystem operations and dispatch to the correct repository-filesystem (dot-git or common-dot-git) according to the rules described in the doc: https://git-scm.com/docs/gitrepository-layout#Documentation/gitrepository-layout.txt. EnableDotGitCommonDir option will only work with the filesystem-backed storage.

Also worktree_test.go has been adopted from an older, already existing existing PR: src-d/go-git#1098. This PR needs new fixtures added in the following PR: go-git/go-git-fixtures#1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants