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

Re: [PATCH] git status: Show detailed dirty status of submodules in long format

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2010, 05:41 UTC
Message-ID
<7vtyssadtx.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4B90EB19.2070300@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
> # Changed but not updated:
> #   (use "git add <file>..." to update what will be committed)
> #   (use "git checkout -- <file>..." to discard changes in working directory)
> #   (commit or discard the untracked or modified content in submodules)

Can we do this additional line only when there is a submodule involved in the changes? The whole point of "collect first and then print" is so that we can compute things like "has_deleted" before starting to emit any output to intelligently give an appropriate advice message, and it feels silly to say submodules to users who don't even use any submodule. I have a suspicion that the majority of users may not even know nor care what a submodule is.

> I am not so proud of DIFF_FORMAT_DIRTY_SUBMODULES, the new flag i
> introduced to tell run_diff_files() it should gather the information
> needed even if we don't want patch output. It isn't a "format" per se,
> but i couldn't come up with a better way to do this. Opinions?

It indeed does sound like DIFF_OPT_* than DIFF_FORMAT_*. In any case, we probably would want to have a small helper function that encapsulates this part that appear twice:

	changed = ce_match_stat(ce, &st, ce_option);
	if (S_ISGITLINK(ce->ce_mode)
	    && !DIFF_OPT_TST(&revs->diffopt, IGNORE_SUBMODULES)
	    && (!changed || (revs->diffopt.output_format & DIFF_FORMAT_PATCH)
		|| (revs->diffopt.output_format & DIFF_FORMAT_DIRTY_SUBMODULES))) {
		dirty_submodule = is_submodule_modified(ce->name);
		if (dirty_submodule)
			changed = 1;
	}
to something like
	changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
        					ce_option, &dirty_submodule);

and the implementation of match_stat_with_submodule() a bit more heavily commented so that people will know what it is for.

Previous: Jens LehmannNext: Jens Lehmann
Message 2 of 5 in “git status: Show detailed dirty status of submodules in long format”
  1. git status: Show detailed dirty status of submodules in long formatJens Lehmann, Mar 5, 2010
  2. Junio C HamanoMar 7, 2010
  3. git status: Show detailed dirty status of submodules in long formatJens Lehmann, Mar 7, 2010
  4. Junio C HamanoMar 8, 2010
  5. git status: Show detailed dirty status of submodules in long formatJens Lehmann, Mar 8, 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.