On Thu, Dec 13, 2018 at 3:43 PM Duy Nguyen <pclouds@xxxxxxxxx> wrote: > > On Thu, Dec 13, 2018 at 9:34 PM Mike Rappazzo <rappazzo@xxxxxxxxx> wrote: > > > > On Thu, Dec 13, 2018 at 3:23 PM Duy Nguyen <pclouds@xxxxxxxxx> wrote: > > > > > > On Thu, Dec 13, 2018 at 8:56 PM Michael Rappazzo via GitGitGadget > > > <gitgitgadget@xxxxxxxxx> wrote: > > > > > > > > From: Michael Rappazzo <rappazzo@xxxxxxxxx> > > > > > > > > On a worktree which is not the primary, using the symbolic-ref 'head' was > > > > incorrectly pointing to the main worktree's HEAD. The same was true for > > > > any other case of the word 'Head'. > > > > > > > > Signed-off-by: Michael Rappazzo <rappazzo@xxxxxxxxx> > > > > --- > > > > refs.c | 8 ++++---- > > > > t/t1415-worktree-refs.sh | 9 +++++++++ > > > > 2 files changed, 13 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/refs.c b/refs.c > > > > index f9936355cd..963e786458 100644 > > > > --- a/refs.c > > > > +++ b/refs.c > > > > @@ -579,7 +579,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref) > > > > *ref = xstrdup(r); > > > > if (!warn_ambiguous_refs) > > > > break; > > > > - } else if ((flag & REF_ISSYMREF) && strcmp(fullref.buf, "HEAD")) { > > > > + } else if ((flag & REF_ISSYMREF) && strcasecmp(fullref.buf, "HEAD")) { > > > > > > This is not going to work. How about ~40 other "strcmp.*HEAD" > > > instances? All refs are case-sensitive and this probably will not > > > change even when we introduce new ref backends. > > > > The current situation is definitely a problem. If I am in a worktree, > > using "head" should be the same as "HEAD". > > No "head" is not the same as "HEAD". It does not matter if you're in a > worktree or not. I was not aware of a difference. Is that spelled out in the docs somewhere? It seems like a bad idea to have a magical symbolic ref that _sometimes_ gives you a different answer depending on casing. What should "head" do in a worktree? Is it supposed to mean the HEAD of the primary worktree? > > > I am not sure if you mean that the fix is too narrow or too wide. > > Maybe it is only necessary in 'is_per_worktree_ref'. On the other > > side of the coin, I could change every strcmp to strcasecmp where the > > comparison is against "HEAD". > > If you make "head" work like "HEAD", then it should work for _all_ > commands, not just worktree, and "MASTER" should match > "refs/heads/master" and so on. I don't think it's as simple as > changing strcmp to strcasecmp. You would need to make ref management > case-insensitive (and make sure if still is case-sensitive if > configured so). I don't think anybody has managed that. I am all for making "head" work in all cases, not just worktree. I don't think that this situation applies to non-magical refs (branches/tags). > -- > Duy