Subject: Re: [PATCH 1/3] checkout: provide hint when failing due to another worktree

From: Ben Knoble <[email-masked]>
Date: Sun, 14 Sep 2025 15:03:32 -0400

> Le 13 sept. 2025 à 16:56, Kristoffer Haugsbakk <[email-masked]> a écrit :
> 
> Unrelated: I found it confusing that my `co = checkout` alias did not
> work with this fresh-off-the-press Advice:[1]
> 
> ```
> $ ./git co master
> fatal: 'master' is already used by worktree at '<path>'
> $ ./git checkout master
> fatal: 'master' is already used by worktree at '<patch>'
> hint: Use --detach to avoid this restriction,
> hint: or --ignore-other-worktrees to ignore it.
> hint: Disable this message with "git config set advice.branchUsedInOtherWorktree false"
> ```
> 
> But it did for this older Advice (which is in my installed git(1)):
> 
> ```
> $ ./git co -b .. @
> fatal: '..' is not a valid branch name
> hint: See `man git check-ref-format`
> hint: Disable this message with "git config set advice.refSyntax false"
> ```
> 
> It’s because aliases are run as a subprocess from the `git` in `PATH`:
> 
> ```
> strvec_push(&cmd.args, "git");
> ```
> 
> [1]: Chain of events:
> 
> 1. Try to trigger the Advice in this series
> 2. ... but it doesn’t
> 3. Is the code wrong?
> 4. Wait, I’m using my alias (which I always use; I don’t think about it)
> 5. I test with `git checkout`: it works
> 6. ... so aliases don’t work with Advice?
> 7. Test an existing Advice that I know about
> 8. ... but it does work with aliases
> 9.–15. ...
> 
> It was part of the process.  I didn’t *decide* to get hung up on it. ;)

Using bin-wrappers/git should set things up correctly, I think?