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

Re: Adding "--ignore-submodules" switch to git-describe

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 1, 2013, 17:46 UTC
Message-ID
<7v621bggi5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAC9WiBjHEoX154Y2q1NxEB1my78Gqf__+v-KR5jNVqT-MN9ZaQ@mail.gmail.com>
Francis Moreau <francis.moro@gmail.com> writes:
> Would it make sense to add the option --ignore-submodules (currently
> available in git-status) to git-describe when the later is used with
> --dirty option ?

I think the spirit of "describe --dirty" is to allow people who gives out binaries this assurance:

	The version string I got out of "describe --dirty" does not
	say dirty. If the recipient of the binary later reports
	issues, I should be able to reproduce the same binary by
	starting from a pristine checkout of the version (provided
	if I didn't screw up and depended on an untracked file when
	I initially created the binary, or used a custom build
	option, or lost the toolchain, ..., of course).
With that in mind, does --ignore-submodules make sense?

As we do not take untracked content at the superproject level into account when deciding "--dirty"-ness, I think it is very sensible to either do one of the following:

 (1) always ignore untracked files in submodule working trees; or
 (2) if we were to introduce some form of --ignore-submodules,
     ignore untracked files in the superproject working tree when we
     use that mechanism to ignore untracked files in submodule
     working trees.
Strictly speaking, (1) is a degenerate case of (2).

Using the same semantics of "--ignore-submodules" as "git status" would not make much sense. "git status --ignore-submodules" does not show modified submodules at all (e.g. the gitlink recorded in the HEAD of the superproject being described does not match what is checked out), so a clean output from the "describe --dirty" at the superproject level does not give any assurance on the build artifact. It defeats the whole point of "describe --dirty".

I think what is missing from "--dirty" is not "--ignore-submodules", but "--do-not-ignore-untracked" option [*1*]. "describe --dirty" ignores untracked files in the superproject by default, and we should ignore untracked files in submodule working trees, but the current code does not. Fixing that is (1) above.

And then when "--do-not-ignore-untracked" is in effect, we should report a "dirty" revision when the working tree of the superproject or any of the submodule working trees has untracked cruft.

You might want to argue, in the longer term, that the default should be "--do-not-ignore-untracked" and people who want the current toplevel behaviour should ask it with "--ignore-untracked". I am somewhat sympathetic to that position, but I do not think it is practical. People are not perfect and they do keep untracked and unignored paths in the working tree; ignoring untracked paths does have an excuse to be the default from practical point of view.

But when we ignore untracked paths in the superproject, we should ignore untracked paths in submodule working trees consistently.

[Footnote]

*1* Ignoring any other kind of change in submodules (i.e. "none", "dirty" or "all" for "git status --ignore-submodules=<when>") in the context of "describe --dirty" in the superproject tree does not make any sense, so

	BAD$ git describe --dirty --ignore-submodules=<when>
is not a right thing to do.
Previous: Francis MoreauNext: Jens Lehmann
Message 2 of 5 in “Adding "--ignore-submodules" switch to git-describe”
  1. Francis MoreauMar 1, 2013
  2. Junio C HamanoMar 1, 2013
  3. Jens LehmannMar 1, 2013
  4. Francis MoreauMar 8, 2013
  5. Junio C HamanoMar 8, 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.