{"thread":{"id":"57193","subject":"Apparent interaction between recursive submodule push and self-submodules","startedAt":"2022-01-05T18:22:42Z","lastAt":"2022-01-05T18:22:42Z","messageCount":1,"participants":["Dave Abrahams"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"445551","messageId":"8FFD3227-2811-486C-A305-90C4988A0A1A@boostpro.com","threadId":"57193","inReplyTo":null,"subject":"Apparent interaction between recursive submodule push and self-submodules","fromName":"Dave Abrahams","fromEmail":"dave@boostpro.com","sentAt":"2022-01-05T18:22:34Z","receivedAt":"2022-01-05T18:22:42Z","isPatch":false,"sender":{"key":"dave@boostpro.com","avatar":"https://gravatar.com/avatar/df0921f05114687777894565de21c052fb137ba7c303a399528b43d08833f065?d=mp&s=160"},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\nIn your .gitconfig, have\n  [submodule]\n\trecurse = true\n\nThen follow this script:\n\n```\n$ mkdir x\n$ cd x; git init\nInitialized empty Git repository in /private/tmp/x/.git/\n$ touch a\n$ git add a\n$ git commit -m 'initial'\n[main (root-commit) 0afd184] initial\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 a\n$ cd ..\n$ git clone x y\nCloning into 'y'...\ndone.\n$ cd y\n$ git branch -c b\n$ git submodule add ../x self\nCloning into '/private/tmp/y/self'...\ndone.\n$ git submodule update --init\n$ git push origin HEAD:refs/heads/b\nTotal 0 (delta 0), reused 0 (delta 0), pack-reused 0\nTo /private/tmp/x\n * [new branch]      HEAD -> b\n$ cd self\n$ echo 'first change' >> a\n$ git commit -a -m 'first change on main'\n[main 80466da] first change on main\n 1 file changed, 1 insertion(+)\n$ cd ..\n$ git add .gitmodules self\n$ git commit -m 'update to point at new submodule'\n[main 4f5a1b7] update to point at new submodule\n 2 files changed, 4 insertions(+)\n create mode 100644 .gitmodules\n create mode 160000 self\n$ git push origin HEAD:b\nPushing submodule 'self'\nEnumerating objects: 5, done.\nCounting objects: 100% (5/5), done.\nWriting objects: 100% (3/3), 252 bytes | 252.00 KiB/s, done.\nTotal 3 (delta 0), reused 0 (delta 0), pack-reused 0\nTo /private/tmp/x\n   0afd184..80466da  HEAD -> b\nEnumerating objects: 4, done.\nCounting objects: 100% (4/4), done.\nDelta compression using up to 10 threads\nCompressing objects: 100% (2/2), done.\nWriting objects: 100% (3/3), 357 bytes | 357.00 KiB/s, done.\nTotal 3 (delta 0), reused 0 (delta 0), pack-reused 0\nremote: error: cannot lock ref 'refs/heads/b': is at 80466da48f71630dc87553ca75e216cf6f1dfda9 but expected 0afd18466f353590ae52219e32a712691a59b60b\nTo /private/tmp/x\n ! [remote rejected] HEAD -> b (failed to update ref)\nerror: failed to push some refs to '/private/tmp/x'\n$\n```\n\nWhat did you expect to happen? (Expected behavior)\n\nNo error\n\nWhat happened instead? (Actual behavior)\n\nSee error above.\n\nWhat's different between what you expected and what actually happened?\n\nAnything else you want to add:\n\nIf I do this with a repository cloned via ssh and a submodule cloned via https,\nI get a different error:\n\n```\n$ git push -v origin refs/heads/gh-pages\\:refs/heads/gh-pages\nPushing to github.com:stlab/adobe-reveal-theme\nfatal: bad object f7cc6f9014af46fb9cfcaae26b82ac830593df6d\nerror: remote unpack failed: eof before pack header was fully read\nTo github.com:stlab/adobe-reveal-theme\n ! [remote rejected] gh-pages -> gh-pages (failed)\nerror: failed to push some refs to 'github.com:stlab/adobe-reveal-theme'\n```\n\nThe issue appears to be an interaction between recursive submodule push and the fact\nthat the submodule comes from the same repository as its super-module.\n\n[System Info]\ngit version:\ngit version 2.32.0 (Apple Git-132)\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Darwin 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64\ncompiler info: clang: 13.0.0 (clang-1300.0.29.30)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n\n"}]}