git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Submodule/contents conflict

From
Orgad Shaneh <orgads@gmail.com>
Date
Apr 24, 2017, 08:06 UTC
Message-ID
<CAGHpTBJCjNa8gQRkMah30ehESdsVVKNy+6CuLSf9hfDedR+tPA@mail.gmail.com>
Hi,

I've noticed a strange behavior with submodule/content conflict. My current Git version is 2.12.2, but the problem exists since I remember.

Branch A has a submodule. In branch B which diverged from A, I replaced the submodule with its contents.

Now, every time I merge A into B, and A had changed the submodule reference, all the files inside the ex-submodule directory in B are being "re-added".

Moreover, aborting the merge prints an error, but seems to work nevertheless, and if I run git reset --hard all the files in that directory are actually written to the disk, even though they haven't changed at all.

When the submodule is small, it might be ok. But in my project we have a huge submodule with ~16K files, and on each merge all the files are listed, and even mixed reset takes several minutes.

The following script demonstrates this: #!/bin/sh

rm -rf super sub mkdir sub cd sub git init touch foo git add foo git commit -m 'Initial commit' mkdir ../super; cd ../super git init git submodule add ../sub touch foo; git add foo sub git commit -m 'Initial commit' git checkout -b update-sub git update-index --cacheinfo 160000,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,sub git commit -m 'Update submodule' git checkout -b remove-sub HEAD^ git rm sub mkdir sub touch sub/foo sub/bar git add sub git commit -m 'Replaced submodule with contents' git checkout -b remove-2 HEAD^ git merge --no-ff remove-sub git merge update-sub # Adding sub/foo # Adding sub/bar # CONFLICT (modify/delete): sub deleted in HEAD and modified in update-sub. Version update-sub of sub left in tree at sub~update-sub. # Automatic merge failed; fix conflicts and then commit the result. git merge --abort # error: 'sub' appears as both a file and as a directory # error: sub: cannot drop to stage #0

- Orgad
Next: Stefan Beller
Message 1 of 18 in “Submodule/contents conflict”
  1. Orgad ShanehApr 24, 2017
  2. Stefan BellerApr 24, 2017
  3. Philip OakleyApr 24, 2017
  4. Stefan BellerApr 24, 2017
  5. Jeff KingApr 25, 2017
  6. Jeff KingApr 25, 2017
  7. Philip OakleyApr 27, 2017
  8. Jeff KingApr 28, 2017
  9. Junio C HamanoMay 1, 2017
  10. Philip OakleyApr 25, 2017
  11. Junio C HamanoApr 26, 2017
  12. Stefan BellerApr 26, 2017
  13. Junio C HamanoApr 27, 2017
  14. Junio C HamanoApr 27, 2017
  15. Philip OakleyApr 27, 2017
  16. Junio C HamanoApr 28, 2017
  17. Junio C HamanoApr 25, 2017
  18. Stefan BellerApr 25, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.