{"thread":{"id":"64489","subject":"`git submodule update --single-branch` tracks HEAD instead of branch from .gitmodules","startedAt":"2025-11-17T09:20:54Z","lastAt":"2025-11-21T08:49:27Z","messageCount":3,"participants":["Uwe Kleine-König","D. Ben Knoble"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"530797","messageId":"xmkf25oq2vka2kipfqfybngkqffbljqygmtrtiujgsrao7g2wq@k56wxix4oism","threadId":"64489","inReplyTo":null,"subject":"`git submodule update --single-branch` tracks HEAD instead of branch from .gitmodules","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@baylibre.com","sentAt":"2025-11-17T09:20:51Z","receivedAt":"2025-11-17T09:20:54Z","isPatch":false,"sender":{"key":"u.kleine-koenig@baylibre.com","avatar":null},"body":"Hello,\n\nfor a project I'm using several submodules, showing my issue with just\none of them\n\n\t$ git ls-tree @:layers | grep poky\n\t160000 commit b33a8abe77081a2bdda0d89c61736473b2f9bb8b\tpoky\n\n\t$ cat .gitmodules \n\t...\n\t[submodule \"yocto_poky\"]\n\t\tpath = layers/poky\n\t\turl = https://git.yoctoproject.org/git/poky\n\t\tbranch = scarthgap\n\n\t$ git submodule update --init --checkout --recursive --single-branch\n\t...\n\tCloning into '/home/uwe/work/sri/poet-server/layers/poky'...\n\tremote: Enumerating objects: 8775, done.\n\tremote: Counting objects: 100% (3119/3119), done.\n\tremote: Compressing objects: 100% (158/158), done.\n\tremote: Total 8775 (delta 2974), reused 2961 (delta 2961), pack-reused 5656 (from 1)\n\tReceiving objects: 100% (8775/8775), 3.24 MiB | 15.45 MiB/s, done.\n\tResolving deltas: 100% (6158/6158), completed with 391 local objects.\n\tFrom https://git.yoctoproject.org/git/poky\n\t * branch                      b33a8abe77081a2bdda0d89c61736473b2f9bb8b -> FETCH_HEAD\n\nso far so good. But:\n\n\t$ cd layers/poky/\n\tlayers/poky$ git remote show origin\n\t* remote origin\n\t  Fetch URL: https://git.yoctoproject.org/git/poky\n\t  Push  URL: https://git.yoctoproject.org/git/poky\n\t  HEAD branch: master\n\t  Remote branch:\n\t    master tracked\n\t  Local branch configured for 'git pull':\n\t    master merges with remote master\n\t  Local ref configured for 'git push':\n\t    master pushes to master (up to date)\n\nSo in this submodule master is tracked, while I think it would be much\nmore sensible to track the scarthgap branch. The further consequence is\nthat\n\n\t$ git submodule update --remote layers/poky/\n\tfatal: Unable to find refs/remotes/origin/scarthgap revision in submodule path 'layers/poky'\n\nThis happens for both git version 2.47.3 (which I typically use,\nprovided by Debian), but also on current git master\n(2.52.0.rc2.22.gc93f1a0fa3eb).\n\nBest regards\nUwe\n"},{"id":"531063","messageId":"CALnO6CBdc=5KpUwweMzxpT+9CBXZVP4AG4bFS9sGucJJVmzjtQ@mail.gmail.com","threadId":"64489","inReplyTo":"xmkf25oq2vka2kipfqfybngkqffbljqygmtrtiujgsrao7g2wq@k56wxix4oism","subject":"Re: `git submodule update --single-branch` tracks HEAD instead of branch from .gitmodules","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-11-20T16:05:00Z","receivedAt":"2025-11-20T16:05:13Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Mon, Nov 17, 2025 at 4:28 AM Uwe Kleine-König\n<u.kleine-koenig@baylibre.com> wrote:\n>\n> Hello,\n>\n> for a project I'm using several submodules, showing my issue with just\n> one of them\n>\n>         $ git ls-tree @:layers | grep poky\n>         160000 commit b33a8abe77081a2bdda0d89c61736473b2f9bb8b  poky\n>\n>         $ cat .gitmodules\n>         ...\n>         [submodule \"yocto_poky\"]\n>                 path = layers/poky\n>                 url = https://git.yoctoproject.org/git/poky\n>                 branch = scarthgap\n>\n>         $ git submodule update --init --checkout --recursive --single-branch\n>         ...\n>         Cloning into '/home/uwe/work/sri/poet-server/layers/poky'...\n>         remote: Enumerating objects: 8775, done.\n>         remote: Counting objects: 100% (3119/3119), done.\n>         remote: Compressing objects: 100% (158/158), done.\n>         remote: Total 8775 (delta 2974), reused 2961 (delta 2961), pack-reused 5656 (from 1)\n>         Receiving objects: 100% (8775/8775), 3.24 MiB | 15.45 MiB/s, done.\n>         Resolving deltas: 100% (6158/6158), completed with 391 local objects.\n>         From https://git.yoctoproject.org/git/poky\n>          * branch                      b33a8abe77081a2bdda0d89c61736473b2f9bb8b -> FETCH_HEAD\n>\n> so far so good. But:\n\nIs it? You've only cloned the HEAD from the origin:\n\n       --single-branch, --no-single-branch\n           This option is only valid for the update command. Clone only one\n           branch during update: HEAD or one specified by --branch.\n\nPerhaps you want to use --branch here, and _perhaps_ update\n--single-branch should default to submodule.<name>.branch ?\n\n-- \nD. Ben Knoble\n"},{"id":"531131","messageId":"llfngawozm26eo3x42ndon55qenrzeto2tgl7djr2weho43gt5@sjcdk2ppafqc","threadId":"64489","inReplyTo":"CALnO6CBdc=5KpUwweMzxpT+9CBXZVP4AG4bFS9sGucJJVmzjtQ@mail.gmail.com","subject":"Re: `git submodule update --single-branch` tracks HEAD instead of branch from .gitmodules","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@baylibre.com","sentAt":"2025-11-21T08:49:24Z","receivedAt":"2025-11-21T08:49:27Z","isPatch":false,"sender":{"key":"u.kleine-koenig@baylibre.com","avatar":null},"body":"Hello,\n\nOn Thu, Nov 20, 2025 at 11:05:00AM -0500, D. Ben Knoble wrote:\n> On Mon, Nov 17, 2025 at 4:28 AM Uwe Kleine-König\n> <u.kleine-koenig@baylibre.com> wrote:\n> > for a project I'm using several submodules, showing my issue with just\n> > one of them\n> >\n> >         $ git ls-tree @:layers | grep poky\n> >         160000 commit b33a8abe77081a2bdda0d89c61736473b2f9bb8b  poky\n> >\n> >         $ cat .gitmodules\n> >         ...\n> >         [submodule \"yocto_poky\"]\n> >                 path = layers/poky\n> >                 url = https://git.yoctoproject.org/git/poky\n> >                 branch = scarthgap\n> >\n> >         $ git submodule update --init --checkout --recursive --single-branch\n> >         ...\n> >         Cloning into '/home/uwe/work/sri/poet-server/layers/poky'...\n> >         remote: Enumerating objects: 8775, done.\n> >         remote: Counting objects: 100% (3119/3119), done.\n> >         remote: Compressing objects: 100% (158/158), done.\n> >         remote: Total 8775 (delta 2974), reused 2961 (delta 2961), pack-reused 5656 (from 1)\n> >         Receiving objects: 100% (8775/8775), 3.24 MiB | 15.45 MiB/s, done.\n> >         Resolving deltas: 100% (6158/6158), completed with 391 local objects.\n> >         From https://git.yoctoproject.org/git/poky\n> >          * branch                      b33a8abe77081a2bdda0d89c61736473b2f9bb8b -> FETCH_HEAD\n> >\n> > so far so good. But:\n> \n> Is it? You've only cloned the HEAD from the origin:\n\nI don't. b33a8abe77081a2bdda0d89c61736473b2f9bb8b isn't included in the\nremote's HEAD, only in the scarthgap branch.\n\n>        --single-branch, --no-single-branch\n>            This option is only valid for the update command. Clone only one\n>            branch during update: HEAD or one specified by --branch.\n> \n> Perhaps you want to use --branch here, [...]\n\nWell, the submodule is initialized from .gitmodules which has a\nspecification of the branch. And the init steps works fine despite\nthe submodule commit not being included in HEAD of the remote poky repo.\nI interpret that as --branch being provided (somewhat) implicitly.\n\nAnd yes I'm aware I wail about something that is documented. But the\ndocumentation is silly in the same way as the code.\n\n> [...] and _perhaps_ update --single-branch should default to\n> submodule.<name>.branch ?\n\nYes please. `git submodule update --init` already does it right, just\nthe fetch line in .git/modules/yocto_poky/config is wrong.\n\nBest regards\nUwe\n"}]}