threads / patch / 60337

patchdoc/git-worktree: mention "refs/rewritten" as per-worktree refs

Subject: [PATCH] doc/git-worktree: mention "refs/rewritten" as per-worktree refs

## tl;dr

2 messages between Oct 10, 2023 and Oct 10, 2023. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Patrick Steinhardt· Oct 10, 2023, 11:01 UTC · lore

Some references are special in the context of worktrees as they are considered to be per-worktree instead of shared across all of the worktrees. Most importantly, this includes "refs/worktree/" that have explicitly been designed such that users can create per-woorktree refs. But there are also special references that have an associated meaning like "refs/bisect/", which is used to track state of git-bisect(1).

These special per-worktree references are documented in git-worktree(1), but one instance is missing. In a9be29c9817 (sequencer: make refs generated by the `label` command worktree-local, 2018-04-25), we have converted "refs/rewritten/" to be a per-worktree reference as well. These references are used by our sequencer infrastructure to generate labels for rebased commits. So in order to allow for multiple concurrent rebases to happen in different worktrees, these references need to be tracked per worktree.

We forgot to update our documentation to mention these new per-worktree references, which is fixed by this patch.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/git-worktree.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Show changes to Documentation/git-worktree.txt +4 −3
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index a4fbf5e838..93d76f5d66 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -286,7 +286,8 @@ rules and how to access refs of one worktree from another.
 In general, all pseudo refs are per-worktree and all refs starting with
 `refs/` are shared. Pseudo refs are ones like `HEAD` which are directly
 under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions,
-however: refs inside `refs/bisect` and `refs/worktree` are not shared.
+however: refs inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are
+not shared.
 
 Refs that are per-worktree can still be accessed from another worktree via
 two special paths, `main-worktree` and `worktrees`. The former gives
@@ -363,8 +364,8 @@ linked worktree `git rev-parse --git-path HEAD` returns
 `/path/other/test-next/.git/HEAD` or `/path/main/.git/HEAD`) while `git
 rev-parse --git-path refs/heads/master` uses
 `$GIT_COMMON_DIR` and returns `/path/main/.git/refs/heads/master`,
-since refs are shared across all worktrees, except `refs/bisect` and
-`refs/worktree`.
+since refs are shared across all worktrees, except `refs/bisect`,
+`refs/worktree` and `refs/rewritten`.
 
 See linkgit:gitrepository-layout[5] for more information. The rule of
 thumb is do not make any assumption about whether a path belongs to
-- 
2.42.0
Eric Sunshine· Oct 10, 2023, 17:49 UTC · re: Patrick Steinhardt · lore

Re: [PATCH] doc/git-worktree: mention "refs/rewritten" as per-worktree refs

On Tue, Oct 10, 2023 at 7:01 AM Patrick Steinhardt <ps@pks.im> wrote:
> Some references are special in the context of worktrees as they are
> considered to be per-worktree instead of shared across all of the
> worktrees. Most importantly, this includes "refs/worktree/" that have
> explicitly been designed such that users can create per-woorktree refs.
s/woorktree/worktree/
Show 25 quoted lines
> But there are also special references that have an associated meaning
> like "refs/bisect/", which is used to track state of git-bisect(1).
>
> These special per-worktree references are documented in git-worktree(1),
> but one instance is missing. In a9be29c9817 (sequencer: make refs
> generated by the `label` command worktree-local, 2018-04-25), we have
> converted "refs/rewritten/" to be a per-worktree reference as well.
> These references are used by our sequencer infrastructure to generate
> labels for rebased commits. So in order to allow for multiple concurrent
> rebases to happen in different worktrees, these references need to be
> tracked per worktree.
>
> We forgot to update our documentation to mention these new per-worktree
> references, which is fixed by this patch.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> @@ -286,7 +286,8 @@ rules and how to access refs of one worktree from another.
>  In general, all pseudo refs are per-worktree and all refs starting with
>  `refs/` are shared. Pseudo refs are ones like `HEAD` which are directly
>  under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions,
> -however: refs inside `refs/bisect` and `refs/worktree` are not shared.
> +however: refs inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are
> +not shared.

To simplify future maintenance, eventually we might want to turn this into a bulleted list, but that doesn't necessarily have to be done by this patch, which is fine as-is.

Show 6 quoted lines
> @@ -363,8 +364,8 @@ linked worktree `git rev-parse --git-path HEAD` returns
>  `$GIT_COMMON_DIR` and returns `/path/main/.git/refs/heads/master`,
> -since refs are shared across all worktrees, except `refs/bisect` and
> -`refs/worktree`.
> +since refs are shared across all worktrees, except `refs/bisect`,
> +`refs/worktree` and `refs/rewritten`.
Ditto.

← back to recent threads