[BUG] Adding a submodule containing submodules in a branch and checkout --recurse-submodules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I think I have found a bug in the implementation of `git checkout —recurse-submodules $branch` in the case of nested submodules. When I add a submodule that has submodules in a feature branch of the main project, checkout the master branch and then checkout my feature branch again, the submodule is not in the expected state.

As an illustration, the following sequence of commands will not leave the submodule brooklyn in the right state:

mkdir test
cd test
git init
git touch file
git add file
git commit -m "initial commit" # add a commit on master
git checkout -b add-sub # create feature branch
git submodule add http://github.com/apache/brooklyn # this repo has submodules itself
git submodule update --init --recursive # initialize all nested submodules
git commit -m "add brooklyn"
git checkout --recurse-submodules master # this removes the brooklyn directory, as expected
GIT_TRACE=1 git checkout --recurse-submodules add-sub # this fails to checkout the nested submodules correctly
22:38:13.885971 git.c:439               trace: built-in: git checkout --recurse-submodules add-sub
22:38:13.895776 run-command.c:663       trace: run_command: cd brooklyn; unset GIT_PREFIX; GIT_DIR=.git git --super-prefix=brooklyn/ read-tree -u --reset 4b825dc642cb6eb9a060e54bf8d69288fbee4904
22:38:13.909366 git.c:439               trace: built-in: git read-tree -u --reset 4b825dc642cb6eb9a060e54bf8d69288fbee4904
22:38:13.918464 run-command.c:663       trace: run_command: cd brooklyn; unset GIT_PREFIX; GIT_DIR=.git git --super-prefix=brooklyn/ read-tree --recurse-submodules -u --reset 30f3d2754a98670d57d142193ba51af3038555af
22:38:13.935402 git.c:439               trace: built-in: git read-tree --recurse-submodules -u --reset 30f3d2754a98670d57d142193ba51af3038555af
22:38:13.940017 run-command.c:663       trace: run_command: cd brooklyn-client; unset GIT_INTERNAL_SUPER_PREFIX GIT_PREFIX; GIT_DIR=.git git --super-prefix=brooklyn/brooklyn-client/ read-tree --recurse-submodules -n --reset 05031a79d4724b867db76b7c4afe55190666c7af
fatal: exec '--super-prefix=brooklyn/brooklyn-client/': cd to 'brooklyn-client' failed: No such file or directory
error: Submodule 'brooklyn-client' could not be updated.
error: Submodule 'brooklyn/brooklyn-client' cannot checkout new HEAD.
error: Submodule 'brooklyn' could not be updated.
22:38:13.947005 run-command.c:663       trace: run_command: cd brooklyn; unset GIT_PREFIX; GIT_DIR=.git git status --porcelain=2
22:38:13.962706 git.c:439               trace: built-in: git status --porcelain=2
M	brooklyn
Switched to branch 'add-sub’

After that, git status says "modified content" for brooklyn; cd-ing into brooklyn and doing git status show everything as deleted, and also some errors related to the git dir of the nested submodules : 
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	deleted:    .gitattributes
	deleted:    .gitignore
	deleted:    .gitmodules
	deleted:    .mvn/jvm.config
	deleted:    Dockerfile
	deleted:    Jenkinsfile
	deleted:    LICENSE
	deleted:    NOTICE
	deleted:    README.md
	deleted:    brooklyn-client
	deleted:    brooklyn-dist
	deleted:    brooklyn-docs
	deleted:    brooklyn-library
	deleted:    brooklyn-server
	deleted:    brooklyn-ui
	deleted:    doap_Brooklyn.rdf
	deleted:    pom.xml

fatal: not a git repository: 'brooklyn-client/.git'
fatal: not a git repository: 'brooklyn-dist/.git'
fatal: not a git repository: 'brooklyn-docs/.git'
fatal: not a git repository: 'brooklyn-library/.git'
fatal: not a git repository: 'brooklyn-server/.git'
fatal: not a git repository: 'brooklyn-ui/.git'
Submodule changes to be committed:

* brooklyn-client 05031a7...0000000:

* brooklyn-dist 3a30944...0000000:

* brooklyn-docs 2b06e96...0000000:

* brooklyn-library a94f7d8...0000000:

* brooklyn-server e601350...0000000:

* brooklyn-ui 503d74e...0000000:

To get back to the state I was on branch add-sub before checking out master, I need to do "git submodule update --recursive --force". I don’t think this is expected behaviour, it is rather confusing.

Cheers,
Philippe Blain.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux