{"thread":{"id":"52898","subject":"Q: submodules and detached HEAD","startedAt":"2020-02-27T09:51:17Z","lastAt":"2020-02-28T08:24:48Z","messageCount":3,"participants":["Ulrich Windl","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"392603","messageId":"5E578F2A020000A1000373EF@gwsmtp.uni-regensburg.de","threadId":"52898","inReplyTo":null,"subject":"Q: submodules and detached HEAD","fromName":"Ulrich Windl","fromEmail":"ulrich.windl@rz.uni-regensburg.de","sentAt":"2020-02-27T09:43:06Z","receivedAt":"2020-02-27T09:51:17Z","isPatch":false,"sender":{"key":"ulrich.windl@rz.uni-regensburg.de","avatar":null},"body":"Hi!\n\nI'm rather new to submodules, and I have a question on something I don't understand (git-2.12.3 from SLES12):\nI had checked out tag v0.0.1 of my submodule.\nWhen checking the status, I see:\n\niptables> git status\nHEAD detached at v0.0.1\nnothing to commit, working tree clean\niptables> git checkout v0.0.1\nHEAD is now at b23fbdc... .version: 0.0.1\niptables> git checkout v0.0.2\nPrevious HEAD position was b23fbdc... .version: 0.0.1\nHEAD is now at 5af0df5... v0.0.2: Fix issue with \"xtables lock\"\n/iptables> git status\nHEAD detached at v0.0.2\nnothing to commit, working tree clean\niptables> git branch\n* (HEAD detached at v0.0.2)\n  master\n\ngit reflog says:\n5af0df5 HEAD@{0}: checkout: moving from b23fbdc0e18e570a4d9ec4cb8826afc82e2e0b64 to v0.0.2\nb23fbdc HEAD@{1}: checkout: moving from ec7dd70b59e039b49bb478a3134b713a2b0a279c to v0.0.1\nec7dd70 HEAD@{2}: checkout: moving from master to v0.0\n\nConfig submodule.iptables.branch is not set.\n\nWho can explain?\n\nRegards,\nUlrich\n\n\n"},{"id":"392628","messageId":"xmqqsgiweyxs.fsf@gitster-ct.c.googlers.com","threadId":"52898","inReplyTo":"5E578F2A020000A1000373EF@gwsmtp.uni-regensburg.de","subject":"Re: Q: submodules and detached HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-27T17:13:03Z","receivedAt":"2020-02-27T17:13:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Ulrich Windl\" <Ulrich.Windl@rz.uni-regensburg.de> writes:\n\n> I'm rather new to submodules, and I have a question on something I don't understand (git-2.12.3 from SLES12):\n> I had checked out tag v0.0.1 of my submodule.\n> When checking the status, I see:\n>\n> iptables> git status\n> HEAD detached at v0.0.1\n> nothing to commit, working tree clean\n> iptables> git checkout v0.0.1\n> HEAD is now at b23fbdc... .version: 0.0.1\n\nI do not see anything special about \"submodule\" in the above.\nAssuming that v0.0.1 is a tag (i.e. refs/tags/v0.0.1 points at a\ncommit whose object name is b23fbdc...), what we see in the above\nis quite expected.\n\n> iptables> git checkout v0.0.2\n> Previous HEAD position was b23fbdc... .version: 0.0.1\n> HEAD is now at 5af0df5... v0.0.2: Fix issue with \"xtables lock\"\n> /iptables> git status\n> HEAD detached at v0.0.2\n> nothing to commit, working tree clean\n> iptables> git branch\n> * (HEAD detached at v0.0.2)\n>   master\n\nSo is the above, under the assumption that v0.0.2 is a tag and not a\nbranch.  When you give a commit to \"git checkout <what-to-checkout>\"\ninstead of giving it a branch name, the HEAD points directly at the\ngiven commit and the state is called \"detached HEAD\".\n\nI do not quite get what the question is.  What was the end-user\nexpectation and how is the actual behaviour different from it?\n\n\n> git reflog says:\n> 5af0df5 HEAD@{0}: checkout: moving from b23fbdc0e18e570a4d9ec4cb8826afc82e2e0b64 to v0.0.2\n> b23fbdc HEAD@{1}: checkout: moving from ec7dd70b59e039b49bb478a3134b713a2b0a279c to v0.0.1\n> ec7dd70 HEAD@{2}: checkout: moving from master to v0.0\n>\n> Config submodule.iptables.branch is not set.\n>\n> Who can explain?\n\nNot me, especially without  knowing what to explain.  Everything I\nsaw so far is expected.\n\n"},{"id":"392653","messageId":"5E58CE48020000A10003744D@gwsmtp.uni-regensburg.de","threadId":"52898","inReplyTo":"23314_1582823592_5E57F8A7_23314_1178_1_xmqqsgiweyxs.fsf@gitster-ct.c.googlers.com","subject":"Antw: [EXT] Re: Q: submodules and detached HEAD","fromName":"Ulrich Windl","fromEmail":"ulrich.windl@rz.uni-regensburg.de","sentAt":"2020-02-28T08:24:40Z","receivedAt":"2020-02-28T08:24:48Z","isPatch":false,"sender":{"key":"ulrich.windl@rz.uni-regensburg.de","avatar":null},"body":">>> Junio C Hamano <gitster@pobox.com> schrieb am 27.02.2020 um 18:13 in\nNachricht\n<23314_1582823592_5E57F8A7_23314_1178_1_xmqqsgiweyxs.fsf@gitster-ct.c.googlers.c\n\nm>:\n> \"Ulrich Windl\" <Ulrich.Windl@rz.uni‑regensburg.de> writes:\n> \n>> I'm rather new to submodules, and I have a question on something I don't \n> understand (git‑2.12.3 from SLES12):\n>> I had checked out tag v0.0.1 of my submodule.\n>> When checking the status, I see:\n>>\n>> iptables> git status\n>> HEAD detached at v0.0.1\n>> nothing to commit, working tree clean\n>> iptables> git checkout v0.0.1\n>> HEAD is now at b23fbdc... .version: 0.0.1\n> \n> I do not see anything special about \"submodule\" in the above.\n> Assuming that v0.0.1 is a tag (i.e. refs/tags/v0.0.1 points at a\n> commit whose object name is b23fbdc...), what we see in the above\n> is quite expected.\n> \n>> iptables> git checkout v0.0.2\n>> Previous HEAD position was b23fbdc... .version: 0.0.1\n>> HEAD is now at 5af0df5... v0.0.2: Fix issue with \"xtables lock\"\n>> /iptables> git status\n>> HEAD detached at v0.0.2\n>> nothing to commit, working tree clean\n>> iptables> git branch\n>> * (HEAD detached at v0.0.2)\n>>   master\n> \n> So is the above, under the assumption that v0.0.2 is a tag and not a\n> branch.  When you give a commit to \"git checkout <what‑to‑checkout>\"\n> instead of giving it a branch name, the HEAD points directly at the\n> given commit and the state is called \"detached HEAD\".\n> \n> I do not quite get what the question is.  What was the end‑user\n> expectation and how is the actual behaviour different from it?\n\nWell the idea of checking out a tag instead of a branch is that the submodule\nversion is well-defined (assuming the tag won't be moved). Using a branch\nhowever, I suspect that pushing to the branch vie routes outside the repository\nusing the submodule might cause some unwanted changes to the submodule.\n\nIndependent from that it seems that submodules always create a new branch\n(this the detached head). I always felt when I see a \"detached head\" I've done\nsomething fundamentally wrong.  Maybe the docs should point out more clearly if\nit's part of the concept.\n\n           checkout\n               the commit recorded in the superproject will be checked out in\n               the submodule on a detached HEAD.\n\nMaybe add some explanation what this actually means.  Maybe clarify the\nconcept in DESCRIPTION.\n\nI was following some instruction to add and update a submodule, and I thought\nsomething went wrong (or the instructions were no longer up-to-date).\n\n\n> \n> \n>> git reflog says:\n>> 5af0df5 HEAD@{0}: checkout: moving from \n> b23fbdc0e18e570a4d9ec4cb8826afc82e2e0b64 to v0.0.2\n>> b23fbdc HEAD@{1}: checkout: moving from \n> ec7dd70b59e039b49bb478a3134b713a2b0a279c to v0.0.1\n>> ec7dd70 HEAD@{2}: checkout: moving from master to v0.0\n>>\n>> Config submodule.iptables.branch is not set.\n>>\n>> Who can explain?\n> \n> Not me, especially without  knowing what to explain.  Everything I\n> saw so far is expected.\n\nSo it seems to be a variation of expectation ;-)\n\nRegards,\nUlrich\n\n\n"}]}