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

Re: Confusing behavior with ignored submodules and `git commit -a`

From
Stefan Beller <sbeller@google.com>
Date
Nov 15, 2018, 19:39 UTC
Message-ID
<CAGZ79kb+KSt_verjDR0yMj3y_QjsS5npX151iKP5hZL0HvUs+g@mail.gmail.com>
In-Reply-To
<CAGw6cBvJSswpvrMwKU9b+ANEHO4tWjWVhLL54nUyod2NoHJe1w@mail.gmail.com>
Show 11 quoted lines
> I have a git repository which contains a number of submodules that
> refer to external repositories. Some of these repositories need to
> patched in some way, so patches are stored alongside the submodules,
> and are applied when building. This mostly works fine, but causes
> submodules to show up as modified in `git status` and get updated with
> `git commit -a`. To resolve this, I've added `ignore = all` to
> .gitmodules for all the submodules that need patches applied. This
> way, I can explicitly `git add` the submodule when I want to update
> the base commit, but otherwise pretend that they are clean. This has
> worked pretty well for me, but less so since git 2.15 when this issue
> was introduced.
Show 9 quoted lines
> > This is really bad. git-status and git-commit share some code,
> > and we'll populate the commit message with a status output.
> > So it seems reasonable to expect the status and the commit to match,
> > i.e. if status tells me there is no change, then commit should not record
> > the submodule update.
>
> I just checked and if I don't specify a message on the command-line,
> the status output in the message template *does* mention that `inner`
> is getting updated.
That's good.
Show 11 quoted lines
> >> > There have been a couple occasions where I accidentally pushed local
> >> > changes to ignored submodules because of this. Since they don't show
> >> > up in the log output, it is difficult to figure out what actually has
> >> > gone wrong.
> >
> > How was it prevented before? Just by git commit -a not picking up the
> > submodule change?
>
> Yes. Previously, `git commit -a` would not pick up the change (unless
> I added it explicitly with `git add`), and `git log` would still show
> changes to ignored submodules (which is the behavior I want).

and both are broken currently (commit -a will commit a submodule if it is changed, and it will also not show that in log, but it did show that it is committing it in the commit message template)

> I just came across someone else affected by this issue:
> https://github.com/git/git/commit/55568086#commitcomment-27137460
Point taken.
Previous: Stefan Beller
Message 12 of 12 in “Confusing behavior with ignored submodules and `git commit -a`”
  1. Michael ForneyMar 17, 2018
  2. Michael ForneyOct 25, 2018
  3. Stefan BellerOct 25, 2018
  4. Michael ForneyNov 15, 2018
  5. Michael ForneyNov 15, 2018
  6. Stefan BellerNov 15, 2018
  7. Michael ForneyNov 15, 2018
  8. Michael ForneyNov 15, 2018
  9. Stefan BellerNov 15, 2018
  10. Michael ForneyNov 16, 2018
  11. Stefan BellerNov 27, 2018
  12. Stefan BellerNov 15, 2018

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.