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

Re: What's cooking in git.git (Jan 2010, #07; Fri, 22)

From
Jens Lehmann <jens.lehmann@web.de>
Date
Jan 23, 2010, 16:37 UTC
Message-ID
<4B5B25C6.70604@web.de>
In-Reply-To
<7vtyudfqju.fsf@alter.siamese.dyndns.org>
Am 23.01.2010 04:28, schrieb Junio C Hamano:
Show 8 quoted lines
> * jl/submodule-diff (2010-01-18) 4 commits
>   (merged to 'next' on 2010-01-20 at 95cb513)
>  + Performance optimization for detection of modified submodules
>   (merged to 'next' on 2010-01-17 at 525075b)
>  + git status: Show uncommitted submodule changes too when enabled
>   (merged to 'next' on 2010-01-16 at 0a99e3c)
>  + Teach diff that modified submodule directory is dirty
>  + Show submodules as modified when they contain a dirty work tree

What about adding the following patch to this series? Without it i see a performance regression for people who use "git diff* --ignore-submodules".

A patch that teaches "git diff --submodule" to display if the submodule contains new untracked and/or modified files is also almost ready. Would you consider it for inclusion into 1.7.0 too or shall i wait until after the release?

------8<-----
Subject: [PATCH] git diff: Don't test submodule dirtiness with --ignore-submodules

The diff family suppresses the output of submodule changes when requested but checks them nonetheless. But since recently submodules get examined for their dirtiness, which is rather expensive. There is no need to do that when the --ignore-submodules option is used, as the gathered information is never used anyway.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
 diff-lib.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index ec2e2ac..e896b9c 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -161,7 +161,10 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 				continue;
 		}

-		if ((ce_uptodate(ce) && !S_ISGITLINK(ce->ce_mode)) || ce_skip_worktree(ce))
+		if ((ce_uptodate(ce)
+		     && (!S_ISGITLINK(ce->ce_mode)
+			 || DIFF_OPT_TST(&revs->diffopt, IGNORE_SUBMODULES)))
+		    || ce_skip_worktree(ce))
 			continue;

 		/* If CE_VALID is set, don't look at workdir for file removal */
@@ -179,6 +182,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 		}
 		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))
 		    && is_submodule_modified(ce->name)) {
 			changed = 1;
@@ -220,7 +224,7 @@ static int get_stat_data(struct cache_entry *ce,
 			 const unsigned char **sha1p,
 			 unsigned int *modep,
 			 int cached, int match_missing,
-			 unsigned *dirty_submodule, int output_format)
+			 unsigned *dirty_submodule, struct diff_options *diffopt)
 {
 	const unsigned char *sha1 = ce->sha1;
 	unsigned int mode = ce->ce_mode;
@@ -241,7 +245,8 @@ static int get_stat_data(struct cache_entry *ce,
 		}
 		changed = ce_match_stat(ce, &st, 0);
 		if (S_ISGITLINK(ce->ce_mode)
-		    && (!changed || (output_format & DIFF_FORMAT_PATCH))
+		    && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
+		    && (!changed || (diffopt->output_format & DIFF_FORMAT_PATCH))
 		    && is_submodule_modified(ce->name)) {
 			changed = 1;
 			*dirty_submodule = 1;
@@ -270,7 +275,7 @@ static void show_new_file(struct rev_info *revs,
 	 * the working copy.
 	 */
 	if (get_stat_data(new, &sha1, &mode, cached, match_missing,
-	    &dirty_submodule, revs->diffopt.output_format) < 0)
+	    &dirty_submodule, &revs->diffopt) < 0)
 		return;

 	diff_index_show_file(revs, "+", new, sha1, mode, dirty_submodule);
@@ -287,7 +292,7 @@ static int show_modified(struct rev_info *revs,
 	unsigned dirty_submodule = 0;

 	if (get_stat_data(new, &sha1, &mode, cached, match_missing,
-			  &dirty_submodule, revs->diffopt.output_format) < 0) {
+			  &dirty_submodule, &revs->diffopt) < 0) {
 		if (report_missing)
 			diff_index_show_file(revs, "-", old,
 					     old->sha1, old->ce_mode, 0);
-- 
1.6.6.1.558.g5c480.dirty
Previous: Jakub NarebskiNext: Junio C Hamano
Message 3 of 8 in “What's cooking in git.git (Jan 2010, #07; Fri, 22)”
  1. Junio C HamanoJan 23, 2010
  2. Jakub NarebskiJan 23, 2010
  3. Jens LehmannJan 23, 2010
  4. Junio C HamanoJan 23, 2010
  5. Junio C HamanoJan 24, 2010
  6. Junio C HamanoJan 24, 2010
  7. Jens LehmannJan 24, 2010
  8. [RFC/H] "git diff --submodule" showing submodule work tree dirtinessJunio C Hamano, Jan 25, 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.