{"thread":{"id":"56170","subject":"[BUG] git add is silent when adding submodule with modified content","startedAt":"2021-07-27T14:49:09Z","lastAt":"2021-07-27T14:49:09Z","messageCount":1,"participants":["Atharva Raykar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"431312","messageId":"CFAB9A5C-6F76-4C91-AD4B-F315C4060FD9@gmail.com","threadId":"56170","inReplyTo":null,"subject":"[BUG] git add is silent when adding submodule with modified content","fromName":"Atharva Raykar","fromEmail":"raykar.ath@gmail.com","sentAt":"2021-07-27T14:48:17Z","receivedAt":"2021-07-27T14:49:09Z","isPatch":false,"sender":{"key":"raykar.ath@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24277692?v=4"},"body":"(Apologies to those CC'd if you got this multiple times, it looks like\nmy MUA is messing things up and the list is rejecting it)\n\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\ngit init superproj && cd superproj\necho 'hello' > superfile\ngit add superfile && git commit -m \"superproj commit\"\ngit submodule add ../superproj submod\ngit commit -m \"add submodule\"\necho \"submod content changed, possibly unintended\" > submod/new-in-sub\ngit add submod\n\nWhat did you expect to happen? (Expected behavior)\n\nGit informs me the add did not happen because of modified content in the\nsubmodule.\n\nWhat happened instead? (Actual behavior)\n\nGit silently does nothing, and returns success.\n\nWhat's different between what you expected and what actually happened?\n\nI want Git to either fail or warn me so that I know that the operation\ndid not match what I expected.\n\nA script I wrote silently carried on and committed everything except the\nsubmodule and pushed it to a remote repository. Even on the command line\nit was confusing at first, until I explicitly ran 'git status' and\nrealised why it was not getting added. Unless someone opens the git man\npages, they might not realise why the add failed.\n\nAnything else you want to add:\n\nI tried looking into it, but I'm not sure where the fix would fit. I\nsuppose the problem could be at 'diff-lib.c:run_diff_files()' [1] which\nmakes calls to check for changes in submodules, but does not relay that\ninformation in any useful way, especially when called in\n'add.c:add_files_to_cache()' [2].\n\n[1] https://github.com/git/git/blob/eb27b338a3e71c7c4079fbac8aeae3f8fbb5c687/diff-lib.c#L239-L264\n[2] https://github.com/git/git/blob/eb27b338a3e71c7c4079fbac8aeae3f8fbb5c687/builtin/add.c#L120-L141\n\n[System Info]\ngit version:\ngit version 2.32.0\ncpu: arm64\nbuilt from commit: 62a8d224e6203d9d3d2d1d63a01cf5647ec312c9\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64\ncompiler info: clang: 12.0.0 (clang-1200.0.32.29)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n---\nAtharva Raykar\nಅಥರ್ವ ರಾಯ್ಕರ್\nअथर्व रायकर\n\n"}]}