git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Ensure that commit/status don't stat all files when core.ignoreStat = true
@ 2008-05-27  9:29 Marius Storm-Olsen
  2008-05-27 20:00 ` Junio C Hamano
  0 siblings, 1 reply; 32+ messages in thread
From: Marius Storm-Olsen @ 2008-05-27  9:29 UTC (permalink / raw)
  To: git; +Cc: gitster, Marius Storm-Olsen

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

^ permalink raw reply related	[flat|nested] 32+ messages in thread
* [PATCH] Ensure that commit/status don't stat all files when core.ignoreStat = true
@ 2008-05-27  8:15 Marius Storm-Olsen
  0 siblings, 0 replies; 32+ messages in thread
From: Marius Storm-Olsen @ 2008-05-27  8:15 UTC (permalink / raw)


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

^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2008-06-10  6:24 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-27  9:29 [PATCH] Ensure that commit/status don't stat all files when core.ignoreStat = true Marius Storm-Olsen
2008-05-27 20:00 ` Junio C Hamano
2008-05-27 20:21   ` Marius Storm-Olsen
2008-05-30 11:14     ` [PATCH 1/3] Clearify the documentation for core.ignoreStat Marius Storm-Olsen
2008-05-30  8:54       ` [PATCH 2/3] Introduce core.showUntrackedFiles to make it possible to disable showing of untracked files Simon Hausmann
2008-05-30 12:38         ` [PATCH 3/3] Add shortcut in refresh_cache_ent() for marked entries Marius Storm-Olsen
2008-05-30 13:14           ` Marius Storm-Olsen
2008-05-30 13:10         ` [PATCH 2/3] Introduce core.showUntrackedFiles to make it possible to disable showing of untracked files Marius Storm-Olsen
2008-05-30 13:16         ` Marius Storm-Olsen
2008-05-30 20:27         ` Junio C Hamano
2008-05-31  6:41           ` Marius Storm-Olsen
2008-06-03 13:09           ` [PATCH] Add an optional <mode> argument to commit/status -u|--untracked-files option Marius Storm-Olsen
2008-06-03 13:12             ` [PATCH] Add configuration option for default untracked files mode Marius Storm-Olsen
2008-06-03 20:02             ` [PATCH] Add an optional <mode> argument to commit/status -u|--untracked-files option Junio C Hamano
2008-06-03 21:00               ` Marius Storm-Olsen
2008-06-05  8:31               ` [PATCH 1/3] " Marius Storm-Olsen
2008-06-05 12:22                 ` [PATCH 2/3] Add argument 'no' commit/status option -u|--untracked-files Marius Storm-Olsen
2008-06-05 12:47                   ` [PATCH 3/3] Add configuration option for default untracked files mode Marius Storm-Olsen
2008-06-07  1:55                 ` [PATCH 1/3] Add an optional <mode> argument to commit/status -u|--untracked-files option Junio C Hamano
2008-06-09  6:54                   ` Marius Storm-Olsen
2008-06-05  8:31                     ` Marius Storm-Olsen
2008-06-05 12:22                       ` [PATCH 2/3] Add argument 'no' commit/status option -u|--untracked-files Marius Storm-Olsen
2008-06-05 12:47                         ` [PATCH 3/3] Add configuration option for default untracked files mode Marius Storm-Olsen
2008-06-10  6:23                     ` [PATCH 1/3] Add an optional <mode> argument to commit/status -u|--untracked-files option Junio C Hamano
2008-06-03 20:14             ` [PATCH] " Jeff King
2008-06-03 21:17               ` Marius Storm-Olsen
2008-06-03 22:27                 ` Jeff King
2008-06-03 22:26               ` しらいしななこ
     [not found]               ` <200806032227.m53MRLeD005668@mi0.bluebottle.com>
2008-06-03 22:53                 ` Jeff King
2008-06-06  6:32             ` Alex Riesen
2008-06-06  6:56               ` Marius Storm-Olsen
  -- strict thread matches above, loose matches on Subject: below --
2008-05-27  8:15 [PATCH] Ensure that commit/status don't stat all files when core.ignoreStat = true Marius Storm-Olsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).