git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [BUG] git add is silent when adding submodule with modified content
@ 2021-07-27 14:48 Atharva Raykar
  0 siblings, 0 replies; only message in thread
From: Atharva Raykar @ 2021-07-27 14:48 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Johannes Schindelin, Jeff King

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-27 14:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 14:48 [BUG] git add is silent when adding submodule with modified content Atharva Raykar

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).