{"thread":{"id":"58895","subject":"Possible BUG: git stash -m picks branch name from submodule","startedAt":"2022-12-05T15:25:14Z","lastAt":"2022-12-05T15:25:14Z","messageCount":1,"participants":["Flavio Stanchina"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"468522","messageId":"cddbcbea-61c5-50c6-624f-5c7708b27f79@gmail.com","threadId":"58895","inReplyTo":null,"subject":"Possible BUG: git stash -m picks branch name from submodule","fromName":"Flavio Stanchina","fromEmail":"flavio.stanchina@gmail.com","sentAt":"2022-12-05T15:22:05Z","receivedAt":"2022-12-05T15:25:14Z","isPatch":false,"sender":{"key":"flavio.stanchina@gmail.com","avatar":null},"body":"I have a repository with one submodule:\n   $ cat .gitmodules\n   [submodule \"foo\"]\n     path = foo\n     url = https://gitlab.xx.yy/zz/foo.git\n     branch = xxx\n\nAfter I clone the main repo and run \"git submodule init\" + \"git \nsubmodule update\", the submodule is in a detached state:\n   $ (cd foo && git status)\n   HEAD detached at cb52389b\n   nothing to commit, working tree clean\n\nI was expecting it to be on the branch spelled out in the configuration, \nbut I guess this is working as designed: that's the correct commit, so \nnothing to worry about yet.\n\nAt this point, if I create a stash in the main repo with -m, the stash \ncomment correctly says it was on master:\n   $ git stash -m \"test prestazioni filtri RFID\"\n   Saved working directory and index state On master:\n   test prestazioni filtri RFID\n\n   $ git stash list\n   stash@{0}: On master: test prestazioni filtri RFID\n\nNow I explicitly check out the submodule by branch name, in preparation \nfor work in the submodule itself:\n   $ (cd foo && git checkout xxx)\n   Switched to branch 'xxx'\n   Your branch is up to date with 'origin/xxx'.\n\n   $ (cd foo && git log -1)\n   commit cb52389b (HEAD -> xxx, origin/xxx)\n   Author: Flavio Stanchina [...]\n\nI create a stash in the main directory with exactly the same command as \nbefore:\n   $ git stash -m \"test prestazioni filtri RFID\"\n   Saved working directory and index state On xxx:\n   test prestazioni filtri RFID\n\n   $ git stash list\n   stash@{0}: On xxx: test prestazioni filtri RFID\n\nAs you can see, the stash took the branch name from the submodule (there \nis no branch with that name in the main repo, and it's still on master \nanyway).\n\nThis doesn't happen if I just run \"git stash\" without -m:\n   $ git stash\n   Saved working directory and index state WIP on master:\n   7bf81a83 [...]\n\n   $ git stash list\n   stash@{0}: WIP on master: 7bf81a83 [...]\n\nIs this expected? I don't think so.\n\nAm I not supposed to touch the submodule directory in any way? Even if \nthat's the case, why would it make sense to pick the branch name from \nthe submodule when stashing in the main directory?\n\nRunning on Debian 11 in a WSL instance:\n   $ git --version\n   git version 2.30.2\n\n   $ dpkg -s git\n   ...\n   Version: 1:2.30.2-1\n   ...\n\n\n-- \nCiao, Flavio\n\n"}]}