{"thread":{"id":"55793","subject":"Bug when cloning a repository with a default branch called HEAD","startedAt":"2021-05-28T19:53:57Z","lastAt":"2021-05-31T20:57:45Z","messageCount":6,"participants":["Björn Kautler","Bagas Sanjaya","asymptosis","Randall S. Becker"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"425821","messageId":"CAKChYSqgGRfBh68oj=Gt7q4uyS7D879aQZQiZ1RsyqaDToV+0g@mail.gmail.com","threadId":"55793","inReplyTo":null,"subject":"Bug when cloning a repository with a default branch called HEAD","fromName":"Björn Kautler","fromEmail":"bjoern@kautler.net","sentAt":"2021-05-28T19:05:40Z","receivedAt":"2021-05-28T19:53:57Z","isPatch":false,"sender":{"key":"bjoern@kautler.net","avatar":"https://gravatar.com/avatar/bdced748b9c4d05ea367da8538332227794d2982fb3c3572e3562faf19ec507c?d=mp&s=160"},"body":"Hi,\n\nI'm not right now sure why this repo is in this state or how it got\nthere, but that doesn't matter.\nBut if you clone it, everything is fine.\nAnd if you then try to fetch it, Git goes havoc:\n\n$ git clone https://gitlab.com/Vampire/whelk.git/ && cd whelk &&\nGIT_TRACE=1 git fetch; echo $?\nCloning into 'whelk'...\nremote: Enumerating objects: 525, done.\nremote: Counting objects: 100% (525/525), done.\nremote: Compressing objects: 100% (227/227), done.\nremote: Total 525 (delta 280), reused 525 (delta 280), pack-reused 0\nReceiving objects: 100% (525/525), 165.63 KiB | 3.52 MiB/s, done.\nResolving deltas: 100% (280/280), done.\n21:04:15.761530 exec-cmd.c:237          trace: resolved executable\ndir: C:/Program Files/Git/mingw64/bin\n21:04:15.765532 git.c:447               trace: built-in: git fetch\nwarning: refname 'HEAD' is ambiguous.\n21:04:15.769530 run-command.c:667       trace: run_command:\nGIT_DIR=.git git remote-https origin\nhttps://gitlab.com/Vampire/whelk.git/\n21:04:15.795532 exec-cmd.c:237          trace: resolved executable\ndir: C:/Program Files/Git/mingw64/libexec/git-core\n21:04:15.799535 git.c:734               trace: exec: git-remote-https\norigin https://gitlab.com/Vampire/whelk.git/\n21:04:15.799535 run-command.c:667       trace: run_command:\ngit-remote-https origin https://gitlab.com/Vampire/whelk.git/\n21:04:15.832533 exec-cmd.c:237          trace: resolved executable\ndir: C:/Program Files/Git/mingw64/libexec/git-core\n21:04:16.438060 run-command.c:667       trace: run_command: git\nrev-list --objects --stdin --not --all --quiet --alternate-refs\n21:04:16.461060 run-command.c:667       trace: run_command: git\nrev-list --objects --stdin --not --all --quiet --alternate-refs\n21:04:16.475738 exec-cmd.c:237          trace: resolved executable\ndir: C:/Program Files/Git/mingw64/libexec/git-core\n21:04:16.478705 git.c:447               trace: built-in: git rev-list\n--objects --stdin --not --all --quiet --alternate-refs\nerror: multiple updates for 'refs/remotes/origin/HEAD' (including one\nvia symref 'refs/remotes/origin/HEAD') are not allowed\nFrom https://gitlab.com/Vampire/whelk\n ! [new branch]      HEAD       -> origin/HEAD  (unable to update local ref)\nerror: some local refs could not be updated; try running\n 'git remote prune origin' to remove any old, conflicting branches\n21:04:16.496254 run-command.c:667       trace: run_command: git\nmaintenance run --auto --no-quiet\n21:04:16.510254 exec-cmd.c:237          trace: resolved executable\ndir: C:/Program Files/Git/mingw64/libexec/git-core\n21:04:16.512256 git.c:447               trace: built-in: git\nmaintenance run --auto --no-quiet\n1\n\nCheers\nBjörn\n"},{"id":"425956","messageId":"07edafe5-d0a2-4a2c-12a2-28c163f6fdda@gmail.com","threadId":"55793","inReplyTo":"CAKChYSqgGRfBh68oj=Gt7q4uyS7D879aQZQiZ1RsyqaDToV+0g@mail.gmail.com","subject":"Re: Bug when cloning a repository with a default branch called HEAD","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-05-31T04:01:22Z","receivedAt":"2021-05-31T04:01:30Z","isPatch":false,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Hi,\n\nOn 29/05/21 02.05, Björn Kautler wrote:\n> Hi,\n> \n> I'm not right now sure why this repo is in this state or how it got\n> there, but that doesn't matter.\n> But if you clone it, everything is fine.\n> And if you then try to fetch it, Git goes havoc:\n> \n\nI'm trying to create minimal reproducible test repo by switching initial \nbranch to HEAD:\n\n$ mkdir shark && cd shark\n$ git init\n$ git checkout -b HEAD\n\nBut when I checkout, it returned error as expected:\n\n> fatal: 'HEAD' is not a valid branch name.\n\nThus I can't reproduce this issue.\n\n> $ git clone https://gitlab.com/Vampire/whelk.git/ && cd whelk &&\n> GIT_TRACE=1 git fetch; echo $?\n> Cloning into 'whelk'...\n> remote: Enumerating objects: 525, done.\n> remote: Counting objects: 100% (525/525), done.\n> remote: Compressing objects: 100% (227/227), done.\n> remote: Total 525 (delta 280), reused 525 (delta 280), pack-reused 0\n> Receiving objects: 100% (525/525), 165.63 KiB | 3.52 MiB/s, done.\n> Resolving deltas: 100% (280/280), done.\n> 21:04:15.761530 exec-cmd.c:237          trace: resolved executable\n> dir: C:/Program Files/Git/mingw64/bin\n> 21:04:15.765532 git.c:447               trace: built-in: git fetch\n> warning: refname 'HEAD' is ambiguous.\n> 21:04:15.769530 run-command.c:667       trace: run_command:\n> GIT_DIR=.git git remote-https origin\n> https://gitlab.com/Vampire/whelk.git/\n> 21:04:15.795532 exec-cmd.c:237          trace: resolved executable\n> dir: C:/Program Files/Git/mingw64/libexec/git-core\n> 21:04:15.799535 git.c:734               trace: exec: git-remote-https\n> origin https://gitlab.com/Vampire/whelk.git/\n> 21:04:15.799535 run-command.c:667       trace: run_command:\n> git-remote-https origin https://gitlab.com/Vampire/whelk.git/\n> 21:04:15.832533 exec-cmd.c:237          trace: resolved executable\n> dir: C:/Program Files/Git/mingw64/libexec/git-core\n> 21:04:16.438060 run-command.c:667       trace: run_command: git\n> rev-list --objects --stdin --not --all --quiet --alternate-refs\n> 21:04:16.461060 run-command.c:667       trace: run_command: git\n> rev-list --objects --stdin --not --all --quiet --alternate-refs\n> 21:04:16.475738 exec-cmd.c:237          trace: resolved executable\n> dir: C:/Program Files/Git/mingw64/libexec/git-core\n> 21:04:16.478705 git.c:447               trace: built-in: git rev-list\n> --objects --stdin --not --all --quiet --alternate-refs\n> error: multiple updates for 'refs/remotes/origin/HEAD' (including one\n> via symref 'refs/remotes/origin/HEAD') are not allowed\n>  From https://gitlab.com/Vampire/whelk\n>   ! [new branch]      HEAD       -> origin/HEAD  (unable to update local ref)\n> error: some local refs could not be updated; try running\n>   'git remote prune origin' to remove any old, conflicting branches\n> 21:04:16.496254 run-command.c:667       trace: run_command: git\n> maintenance run --auto --no-quiet\n> 21:04:16.510254 exec-cmd.c:237          trace: resolved executable\n> dir: C:/Program Files/Git/mingw64/libexec/git-core\n> 21:04:16.512256 git.c:447               trace: built-in: git\n> maintenance run --auto --no-quiet\n> 1\n> \n> Cheers\n> Björn\n> \n\nThe remote [1] might misconfigured default branch, so instead of \nmaster/main it pointed to HEAD, and it caused the issue.\n\nThanks.\n\n[1]: https://gitlab.com/Vampire/whelk\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"425959","messageId":"YLRoAIBExd+dAe0C@sleipnir.acausal.realm","threadId":"55793","inReplyTo":"07edafe5-d0a2-4a2c-12a2-28c163f6fdda@gmail.com","subject":"Re: Bug when cloning a repository with a default branch called HEAD","fromName":"asymptosis","fromEmail":"asymptosis@posteo.net","sentAt":"2021-05-31T04:37:20Z","receivedAt":"2021-05-31T04:37:38Z","isPatch":false,"sender":{"key":"asymptosis@posteo.net","avatar":null},"body":">I'm trying to create minimal reproducible test repo by switching \n>initial branch to HEAD:\n>\n>$ mkdir shark && cd shark\n>$ git init\n>$ git checkout -b HEAD\n>\n> /snip\n>\n>The remote [1] might misconfigured default branch, so instead of \n>master/main it pointed to HEAD, and it caused the issue.\n\nHi Bagas,\n\nI think he meant the remote had its default branch set to HEAD before he tried cloning. I.e. reproducing the error would look something more like this:\n\n#! /bin/bash\nremote_repo=/tmp/remote\nlocal_repo=/tmp/local\nmkdir $remote_repo\ncd $remote_repo\ngit init -b HEAD\ntouch README\ngit add -A && git commit -m \"Initial commit\"\ncd ..\ngit clone $remote_repo $local_repo\n\n\nFor me, the generated /tmp/local repo does issue warnings about ambiguous HEAD ref. However, it still works, and I don't get the wild errors like reported by Björn.\n\nI suspect it's something to do with the implementation on the local OS. I'm on Linux and it seems like Björn is using Windows.\n"},{"id":"426077","messageId":"CAKChYSpGJ8WHsYRgYL9M8rr7Dp_SLrUuRsTONqNO3CTnX2DQ_Q@mail.gmail.com","threadId":"55793","inReplyTo":"CAKChYSrQ3u3yH0+8Fwj-84cnAFGvuSEPHx+5Mcy8Ys4sXcN14A@mail.gmail.com","subject":"Fwd: Bug when cloning a repository with a default branch called HEAD","fromName":"Björn Kautler","fromEmail":"bjoern@kautler.net","sentAt":"2021-05-31T20:38:01Z","receivedAt":"2021-05-31T20:40:41Z","isPatch":false,"sender":{"key":"bjoern@kautler.net","avatar":"https://gravatar.com/avatar/bdced748b9c4d05ea367da8538332227794d2982fb3c3572e3562faf19ec507c?d=mp&s=160"},"body":"---------- Forwarded message ---------\nVon: Björn Kautler <Bjoern@kautler.net>\nDate: Mo., 31. Mai 2021 um 22:24 Uhr\nSubject: Re: Bug when cloning a repository with a default branch called HEAD\nTo: asymptosis <asymptosis@posteo.net>\n\n\nIt happens the same no matter whether on Windows or Linux.\nI now also have a reproduction recipe on how to get into that state.\n- Create the `whelk` repository with standard settings, nothing for\ndefault branch or anything is necessary\n- Execute this: git clone https://github.com/seveas/whelk.git\nwhelk-src && git -C whelk-src remote add gitlab git@gitlab.com:<your\nnamespace>/whelk.git && git -C whelk-src push gitlab\nrefs/remotes/origin/*:refs/heads/* && git clone\ngit@gitlab.com:git-spindle-test-vampire-1/whelk.git && git -C whelk\nfetch\n\nCheers\nBjörn\n"},{"id":"426079","messageId":"00a401d7565d$f20fd4b0$d62f7e10$@nexbridge.com","threadId":"55793","inReplyTo":"CAKChYSpGJ8WHsYRgYL9M8rr7Dp_SLrUuRsTONqNO3CTnX2DQ_Q@mail.gmail.com","subject":"RE: Bug when cloning a repository with a default branch called HEAD","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2021-05-31T20:45:46Z","receivedAt":"2021-05-31T20:46:03Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":">-----Original Message-----\n>From: <Bjoern@kautler.net>\nOn May 31, 2021 4:38 PM, Björn Kautler wrote:\n>Subject: Re: Bug when cloning a repository with a default branch called HEAD\n>It happens the same no matter whether on Windows or Linux.\n>I now also have a reproduction recipe on how to get into that state.\n>- Create the `whelk` repository with standard settings, nothing for default branch or anything is necessary\n>- Execute this: git clone https://github.com/seveas/whelk.git\n>whelk-src && git -C whelk-src remote add gitlab git@gitlab.com:<your\n>namespace>/whelk.git && git -C whelk-src push gitlab\n>refs/remotes/origin/*:refs/heads/* && git clone git@gitlab.com:git-spindle-test-vampire-1/whelk.git && git -C whelk fetch\n\nAccording to GitHub, the default branch for this repo is \"main\" not \"HEAD\". AFAIK, HEAD is a reserved ref in git and I don't think this would or should work.\n\nJust saying.\nRandall\n\n"},{"id":"426080","messageId":"CAKChYSq__2dgCWVqKt1LeBs9vg8xSj2FnikDqNdgsevfz565zg@mail.gmail.com","threadId":"55793","inReplyTo":"CAKChYSpjOZa2F_mE_7--htzaQ1V4zWgYi8Wm4GHOiYnWoAiswA@mail.gmail.com","subject":"Re: Bug when cloning a repository with a default branch called HEAD","fromName":"Björn Kautler","fromEmail":"bjoern@kautler.net","sentAt":"2021-05-31T20:57:25Z","receivedAt":"2021-05-31T20:57:45Z","isPatch":false,"sender":{"key":"bjoern@kautler.net","avatar":"https://gravatar.com/avatar/bdced748b9c4d05ea367da8538332227794d2982fb3c3572e3562faf19ec507c?d=mp&s=160"},"body":"Don't get me wrong, I neither want that nor intended this result.\nThis happened in the test suite of git-spindle which does commands\nsimilar to what I showed as reproducer now and I just wondered what is\nhappening.\n\nImho a simple push should not be able to produce an unusable state and\nI think this was not the case in the past as the tests used to work.\nBut this could also be caused by changes in the used fixture repo.\n\n\nAm Mo., 31. Mai 2021 um 22:52 Uhr schrieb Björn Kautler <Bjoern@kautler.net>:\n>\n> Don't get me wrong, I neither want that nor intended this result.\n> This happened in the test suite of git-spindle which does commands similar to what I showed as reproducer now and I just wondered what is happening.\n>\n> Imho a simple push should not be able to produce an unusable state and I think this was not the case in the past as the tests used to work. But this could also be caused by changes in the used fixture repo.\n>\n> Randall S. Becker <rsbecker@nexbridge.com> schrieb am Mo., 31. Mai 2021, 22:46:\n>>\n>> >-----Original Message-----\n>> >From: <Bjoern@kautler.net>\n>> On May 31, 2021 4:38 PM, Björn Kautler wrote:\n>> >Subject: Re: Bug when cloning a repository with a default branch called HEAD\n>> >It happens the same no matter whether on Windows or Linux.\n>> >I now also have a reproduction recipe on how to get into that state.\n>> >- Create the `whelk` repository with standard settings, nothing for default branch or anything is necessary\n>> >- Execute this: git clone https://github.com/seveas/whelk.git\n>> >whelk-src && git -C whelk-src remote add gitlab git@gitlab.com:<your\n>> >namespace>/whelk.git && git -C whelk-src push gitlab\n>> >refs/remotes/origin/*:refs/heads/* && git clone git@gitlab.com:git-spindle-test-vampire-1/whelk.git && git -C whelk fetch\n>>\n>> According to GitHub, the default branch for this repo is \"main\" not \"HEAD\". AFAIK, HEAD is a reserved ref in git and I don't think this would or should work.\n>>\n>> Just saying.\n>> Randall\n>>\n"}]}