diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-10-21 10:08:54 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-10-22 13:32:29 +0900 |
commit | 3a3b9d8cde4ed647b1c56a8097f6db8e269bbc71 (patch) | |
tree | cbac4a25a4f33120cec68f92ee93a59708a00d6e /Documentation | |
parent | 8aff1a9ca5a266020fe5b1bd8c54228581e34530 (diff) | |
download | git-3a3b9d8cde4ed647b1c56a8097f6db8e269bbc71.tar.gz |
refs: new ref types to make per-worktree refs visible to all worktrees
One of the problems with multiple worktree is accessing per-worktree
refs of one worktree from another worktree. This was sort of solved by
multiple ref store, where the code can open the ref store of another
worktree and has access to the ref space of that worktree.
The problem with this is reporting. "HEAD" in another ref space is
also called "HEAD" like in the current ref space. In order to
differentiate them, all the code must somehow carry the ref store
around and print something like "HEAD from this ref store".
But that is not feasible (or possible with a _lot_ of work). With the
current design, we pass a reference around as a string (so called
"refname"). Extending this design to pass a string _and_ a ref store
is a nightmare, especially when handling extended SHA-1 syntax.
So we do it another way. Instead of entering a separate ref space, we
make refs from other worktrees available in the current ref space. So
"HEAD" is always HEAD of the current worktree, but then we can have
"worktrees/blah/HEAD" to denote HEAD from a worktree named
"blah". This syntax coincidentally matches the underlying directory
structure which makes implementation a bit easier.
The main worktree has to be treated specially because well... it's
special from the beginning. So HEAD from the main worktree is
acccessible via the name "main-worktree/HEAD" instead of
"worktrees/main/HEAD" because "main" could be just another secondary
worktree.
This patch also makes it possible to specify refs from one worktree in
another one, e.g.
git log worktrees/foo/HEAD
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/git-worktree.txt | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index a50fbf8094..9117e4fb50 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -208,7 +208,8 @@ REFS ---- In multiple working trees, some refs may be shared between all working trees, some refs are local. One example is HEAD is different for all -working trees. This section is about the sharing rules. +working trees. This section is about the sharing rules and how to access +refs of one working tree from another. In general, all pseudo refs are per working tree and all refs starting with "refs/" are shared. Pseudo refs are ones like HEAD which are @@ -216,6 +217,18 @@ directly under GIT_DIR instead of inside GIT_DIR/refs. There are one exception to this: refs inside refs/bisect and refs/worktree is not shared. +Refs that are per working tree can still be accessed from another +working tree via two special paths, main-worktree and worktrees. The +former gives access to per-worktree refs of the main working tree, +while the latter to all linked working trees. + +For example, main-worktree/HEAD or main-worktree/refs/bisect/good +resolve to the same value as the main working tree's HEAD and +refs/bisect/good respectively. Similarly, worktrees/foo/HEAD or +worktrees/bar/refs/bisect/bad are the same as +GIT_COMMON_DIR/worktrees/foo/HEAD and +GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad. + To access refs, it's best not to look inside GIT_DIR directly. Instead use commands such as linkgit:git-revparse[1] or linkgit:git-update-ref[1] which will handle refs correctly. |