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

[BUG] git add is silent when adding submodule with modified content

From
Atharva Raykar <raykar.ath@gmail.com>
Date
Jul 27, 2021, 14:48 UTC
Message-ID
<CFAB9A5C-6F76-4C91-AD4B-F315C4060FD9@gmail.com>

(Apologies to those CC'd if you got this multiple times, it looks like my MUA is messing things up and the list is rejecting it)

Please answer the following questions to help us understand your issue.
What did you do before the bug happened? (Steps to reproduce your issue)

git init superproj && cd superproj echo 'hello' > superfile git add superfile && git commit -m "superproj commit" git submodule add ../superproj submod git commit -m "add submodule" echo "submod content changed, possibly unintended" > submod/new-in-sub git add submod

What did you expect to happen? (Expected behavior)

Git informs me the add did not happen because of modified content in the submodule.

What happened instead? (Actual behavior)
Git silently does nothing, and returns success.
What's different between what you expected and what actually happened?

I want Git to either fail or warn me so that I know that the operation did not match what I expected.

A script I wrote silently carried on and committed everything except the submodule and pushed it to a remote repository. Even on the command line it was confusing at first, until I explicitly ran 'git status' and realised why it was not getting added. Unless someone opens the git man pages, they might not realise why the add failed.

Anything else you want to add:

I tried looking into it, but I'm not sure where the fix would fit. I suppose the problem could be at 'diff-lib.c:run_diff_files()' [1] which makes calls to check for changes in submodules, but does not relay that information in any useful way, especially when called in 'add.c:add_files_to_cache()' [2].

[1] https://github.com/git/git/blob/eb27b338a3e71c7c4079fbac8aeae3f8fbb5c687/diff-lib.c#L239-L264 [2] https://github.com/git/git/blob/eb27b338a3e71c7c4079fbac8aeae3f8fbb5c687/builtin/add.c#L120-L141

[System Info] git version: git version 2.32.0 cpu: arm64 built from commit: 62a8d224e6203d9d3d2d1d63a01cf5647ec312c9 sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: 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 compiler info: clang: 12.0.0 (clang-1200.0.32.29) libc info: no libc information available $SHELL (typically, interactive shell): /bin/zsh

--- Atharva Raykar ಅಥರ್ವ ರಾಯ್ಕರ್ अथर्व रायकर

Message 1 of 1 in “[BUG] git add is silent when adding submodule with modified content”
  1. Atharva RaykarJul 27, 2021

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.