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

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

 



(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
ಅಥರ್ವ ರಾಯ್ಕರ್
अथर्व रायकर





[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