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

Re: [PATCH] builtin/describe.c: ignore untracked changes in submodules

From
Jens Lehmann <jens.lehmann@web.de>
Date
Sep 14, 2010, 20:30 UTC
Message-ID
<4C8FDB51.6010009@web.de>
In-Reply-To
<7v7hipb5ht.fsf@alter.siamese.dyndns.org>
Am 14.09.2010 01:14, schrieb Junio C Hamano:
> What makes untracked paths in the superproject different from the ones in
> a submodule?

That you can have a different state for each path inside the superproject (modified, untracked etc.) while you can't have that for the paths in the submodule (when looked at from the superproject): There is only a single state available for the whole submodule, it's either modified or it isn't. So IMO a modified submodule should tell the user: "There is a change in this submodule so that when you commit/push your superproject now, others might run into problems when fetching it; you want to be sure this is not the case before doing that". And this is just the same thing you could say about a file in the superproject when it shows up as modified, no? And for submodules this definition must also include new yet untracked files, as they are very likely to be missing in every but your work tree.

> "git diff" cannot be it as it does not show untracked paths
> in the superproject, so you are talking about "the user cannot tell from
> the 'git status' output", right?

Nope, it's "git diff" too. The thing that got me started working on this topic was that "git gui" and "gitk" were quiet about submodules which had modified tracked files and/or new untracked files, which lead to real world problems where I work. And both use diff-index and diff-files to get the paths they should display *and* to display the actual changes. (And as "git diff" uses the same machinery under the hood as "git status" does, everything fell into place pretty easily)

And I argue that this is sane behavior, as I'm sure other tools rely on "git diff" or "git status" too to check if there are modifications to the work tree (or they call run_diff_files() or run_diff_index() directly to do that). So all of these should agree on what they are saying about the state of a submodule, or things will get interesting. (Same goes for describe, it should append the "-dirty" when "git status" or "git diff" say a submodule is modified)

And this approach works really well at my dayjob. Since we are using it, me and my colleagues are really happy with it, because we can't forget to commit changes inside a submodule anymore. So judging from this real life experience "ignore=none" is a very sane default.

But I admit that this change in behavior can be strange for long time submodule users when they first encounter it. And if they still don't like the new behavior after some consideration, they can disable it easily using the new configuration options. But one of the advantages I really liked when I started using git was that is was not able to forget to commit new files anymore. So I suspect ignore=none is especially useful for new users of submodules, because it is on the safe side, and therefore should be the default setting. You can later turn the 'noise' down if you want (just like some users do when using the "-uno" option to "git status" if they don't want to be told about untracked files in the superproject or its submodules).

Previous: Junio C Hamano
Message 14 of 14 in “builtin/describe.c: ignore untracked changes in submodules”
  1. builtin/describe.c: ignore untracked changes in submodulesBrandon Casey, Sep 9, 2010
  2. Junio C HamanoSep 10, 2010
  3. Jens LehmannSep 10, 2010
  4. Brandon CaseySep 12, 2010
  5. Jens LehmannSep 13, 2010
  6. yj2133011Sep 12, 2010
  7. Jens LehmannSep 11, 2010
  8. Junio C HamanoSep 11, 2010
  9. Jens LehmannSep 11, 2010
  10. Junio C HamanoSep 12, 2010
  11. Junio C HamanoSep 12, 2010
  12. Jens LehmannSep 13, 2010
  13. Junio C HamanoSep 13, 2010
  14. Jens LehmannSep 14, 2010

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.