On Sat, Sep 22, 2018 at 2:05 PM Nguyễn Thái Ngọc Duy <pclo...@gmail.com> wrote:
> [...]
> 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".

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@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().)

Reply via email to