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

[PATCH] Ensure that commit/status don't stat all files when core.ignoreStat = true

From
Marius Storm-Olsen <marius@trolltech.com>
Date
May 27, 2008, 09:29 UTC
Message-ID
<1211880549-15758-1-git-send-email-marius@trolltech.com>

The core.ignoreStat option is used to assume that files in the index are unchanged, thus avoiding expensive lstat()s on slow systems. However, due to refresh_cache_ent still stating but ignoring the info, and the listing of untracked files in commit/status, we would still lstat() all the files.

This change shortcuts the refresh_cache_ent(), and makes commit/status not list untracked files, unless the -u option is specified.

Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
---
 read-cache.c |   10 ++++++++++
 wt-status.c  |   11 ++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 8b467f8..104e387 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -882,6 +882,16 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
 	if (ce_uptodate(ce))
 		return ce;
 
+	/*
+	 * assume_unchanged is used to avoid lstats to check if the
+	 * file has been modified. When true, the user need to
+	 * manually update the index.
+	 */
+	if (assume_unchanged) {
+		ce_mark_uptodate(ce);
+		return ce;
+	}
+
 	if (lstat(ce->name, &st) < 0) {
 		if (err)
 			*err = errno;
diff --git a/wt-status.c b/wt-status.c
index a44c543..72db466 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -342,7 +342,14 @@ void wt_status_print(struct wt_status *s)
 	wt_status_print_changed(s);
 	if (wt_status_submodule_summary)
 		wt_status_print_submodule_summary(s);
-	wt_status_print_untracked(s);
+
+	if (assume_unchanged && !s->untracked) {
+		if (s->commitable)
+			fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
+		/* !s->commitable message displayed below */
+	}
+	else
+		wt_status_print_untracked(s);
 
 	if (s->verbose && !s->is_initial)
 		wt_status_print_verbose(s);
@@ -357,6 +364,8 @@ void wt_status_print(struct wt_status *s)
 			printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
 		else if (s->is_initial)
 			printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
+		else if (assume_unchanged && !s->untracked)
+			printf("nothing to commit (use -u to show untracked files)\n");
 		else
 			printf("nothing to commit (working directory clean)\n");
 	}
-- 
1.5.5.1.501.gefb4
Next: Junio C Hamano
Message 1 of 11 in “Ensure that commit/status don't stat all files when core.ignoreStat = true”
  1. Ensure that commit/status don't stat all files when core.ignoreStat = trueMarius Storm-Olsen, May 27, 2008
  2. Junio C HamanoMay 27, 2008
  3. Marius Storm-OlsenMay 27, 2008
  4. 1/3 Clearify the documentation for core.ignoreStatMarius Storm-Olsen, May 30, 2008
  5. 2/3 Introduce core.showUntrackedFiles to make it possible to disable showing of untracked files.Simon Hausmann, May 30, 2008
  6. 3/3 Add shortcut in refresh_cache_ent() for marked entries.Marius Storm-Olsen, May 30, 2008
  7. Marius Storm-OlsenMay 30, 2008
  8. Marius Storm-OlsenMay 30, 2008
  9. Marius Storm-OlsenMay 30, 2008
  10. Junio C HamanoMay 30, 2008
  11. Marius Storm-OlsenMay 31, 2008

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.