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

Re: Re: Git issues with submodules

From
Heiko Voigt <hvoigt@hvoigt.net>
Date
Nov 22, 2013, 21:54 UTC
Message-ID
<20131122215454.GA4952@sandbox-ub>
In-Reply-To
<528FC638.5060403@web.de>
Hi,
On Fri, Nov 22, 2013 at 10:01:44PM +0100, Jens Lehmann wrote:
Show 48 quoted lines
> Hmm, looks like git show also needs to be fixed to honor the
> ignore setting from .gitmodules. It already does that for
> diff.ignoreSubmodules from either .git/config or git -c and
> also supports the --ignore-submodules command line option.
> The following fixes this inconsistency for me:
> 
> ---------------------->8-------------------
> diff --git a/builtin/log.c b/builtin/log.c
> index b708517..ca97cfb 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -25,6 +25,7 @@
>  #include "version.h"
>  #include "mailmap.h"
>  #include "gpg-interface.h"
> +#include "submodule.h"
> 
>  /* Set a default date-time format for git log ("log.date" config variable) */
>  static const char *default_date_mode = NULL;
> @@ -521,6 +522,7 @@ int cmd_show(int argc, const char **argv, const char *prefix
>         int i, count, ret = 0;
> 
>         init_grep_defaults();
> +       gitmodules_config();
>         git_config(git_log_config, NULL);
> 
>         memset(&match_all, 0, sizeof(match_all));
> ---------------------->8-------------------
> 
> But the question is if that is the right thing to do: should
> diff.ignoreSubmodules and submodule.<name>.ignore only affect
> the diff family or also git log & friends? That would make
> users blind for submodule history (which they already are
> when using diff & friends, so that might be ok here too).
> 
> > For some reason, the
> > `git add .` is adding the ignored submodule to the index.
> 
> The ignore setting is documented to only affect diff output
> (including what checkout, commit and status show as modified).
> While I agree that this behavior is confusing for Sergey and
> not optimal for the floating branch model he uses, git is
> currently doing exactly what it should. And for people using
> the ignore setting to not having to stat submodules with huge
> and/or many files that behavior is what they want: don't bother
> me with what changed, but commit what I did change on purpose.
> We may have to rethink what should happen for users of the
> floating branch model though.

This gets more nasty. When using 'git add .' you secretly add the submodule to the index. But it is neither shown in status nor diff --cached. commit actually complains there is nothing to add. But then once you add a local file to the index you can commit and secretly take the submodule change with you.

What I think needs fixing here first is that the ignore setting should not apply to any diffs between HEAD and index. IMO, it should only apply to the diff between worktree and index.

When we have that the user does not see the submodule changed when normally working. But after doing git add . the change to the submodule should be shown in status and diff regardless of the configuration.

I will have a look at that.

After that we can discuss whether add should add submodules that are tracked but not shown. How about commit -a ? Should it also ignore the change? I am undecided here. There does not seem to be any good decision. From the users point of view we should probably not add it since its not visible in status. What do others think?

Cheers Heiko
Previous: Sergey SharybinNext: Jonathan Nieder
Message 13 of 51 in “Git issues with submodules”
  1. Sergey SharybinNov 22, 2013
  2. Ramkumar RamachandraNov 22, 2013
  3. Sergey SharybinNov 22, 2013
  4. Ramkumar RamachandraNov 22, 2013
  5. Jeff KingNov 22, 2013
  6. Sergey SharybinNov 22, 2013
  7. Ramkumar RamachandraNov 22, 2013
  8. Sergey SharybinNov 22, 2013
  9. Sergey SharybinNov 22, 2013
  10. Ramkumar RamachandraNov 22, 2013
  11. Jens LehmannNov 22, 2013
  12. Sergey SharybinNov 22, 2013
  13. Heiko VoigtNov 22, 2013
  14. Jonathan NiederNov 22, 2013
  15. Jens LehmannNov 23, 2013
  16. Heiko VoigtNov 24, 2013
  17. Jens LehmannNov 24, 2013
  18. Sergey SharybinNov 25, 2013
  19. Heiko VoigtNov 25, 2013
  20. Sergey SharybinNov 25, 2013
  21. Heiko VoigtNov 25, 2013
  22. 0/4 less ignorance of submodules for ignore=allHeiko Voigt, Dec 4, 2013
  23. 1/4 disable complete ignorance of submodules for index <-> HEAD diffHeiko Voigt, Dec 4, 2013
  24. 2/4 fix 'git add' to skip submodules configured as ignoredHeiko Voigt, Dec 4, 2013
  25. 3/4 teach add -f option for ignored submodulesHeiko Voigt, Dec 4, 2013
  26. Junio C HamanoDec 6, 2013
  27. Heiko VoigtDec 9, 2013
  28. 4/4 always show committed submodules in summary after commitHeiko Voigt, Dec 4, 2013
  29. Heiko VoigtDec 4, 2013
  30. Junio C HamanoDec 4, 2013
  31. Heiko VoigtDec 4, 2013
  32. Jens LehmannDec 5, 2013
  33. Heiko VoigtDec 9, 2013
  34. Junio C HamanoDec 9, 2013
  35. Junio C HamanoNov 25, 2013
  36. Jens LehmannNov 26, 2013
  37. Junio C HamanoNov 26, 2013
  38. Jonathan NiederNov 26, 2013
  39. Junio C HamanoNov 26, 2013
  40. disable complete ignorance of submodules for index <-> HEAD diffHeiko Voigt, Nov 23, 2013
  41. Sergey SharybinNov 25, 2013
  42. Heiko VoigtNov 28, 2013
  43. disable complete ignorance of submodules for index <-> HEAD diffHeiko Voigt, Nov 29, 2013
  44. Ramkumar RamachandraNov 23, 2013
  45. Jens LehmannNov 23, 2013
  46. Heiko VoigtNov 24, 2013
  47. Junio C HamanoNov 25, 2013
  48. Heiko VoigtNov 29, 2013
  49. Ramkumar RamachandraNov 23, 2013
  50. Ramkumar RamachandraNov 22, 2013
  51. Jens LehmannNov 22, 2013

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.