Re: [PATCH 3/8] refs: new ref types to make per-worktree refs visible to all worktrees
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Sep 23, 2018, 08:06 UTC
- Message-ID
- <CAPig+cTtjwCMRMx2xS1WPyM30ipxx5QJK_Aueu50i-jLQdpdBA@mail.gmail.com>
- In-Reply-To
- <20180922180500.4689-4-pclouds@gmail.com>
On Sat, Sep 22, 2018 at 2:05 PM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 6 quoted lines
> [...] > 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/HEAD" (we can't use > "worktrees/main/HEAD" because "main" under "worktrees" is not > reserved).
Bikeshedding: I wonder if this would be more intuitive if called simply "/HEAD" rather than "main/HEAD".
Show 19 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/refs.c b/refs.c
> @@ -641,12 +641,32 @@ static int is_pseudoref_syntax(const char *refname)
> +static int is_main_pseudoref_syntax(const char *refname)
> +{
> + return skip_prefix(refname, "main/", &refname) &&
> + is_pseudoref_syntax(refname);
> +}
> +
> +static int is_other_pseudoref_syntax(const char *refname)
> +{
> + if (!skip_prefix(refname, "worktrees/", &refname))
> + return 0;
> + refname = strchr(refname, '/');
> + if (!refname)
> + return 0;
> + return is_pseudoref_syntax(refname + 1);
> +}If the input is "worktrees/refs/" (nothing following the trailing '/'), then an empty string will be passed to is_pseudoref_syntax(), which will return true. Does that result in correct behavior? (Same question about "main/" being passed to is_main_pseudoref_syntax().)