{"thread":{"id":"13688","subject":"[PATCH] Ensure that commit/status don't stat all files when core.ignoreStat = true","startedAt":"2008-05-27T08:15:09Z","lastAt":"2008-05-27T08:15:09Z","messageCount":1,"participants":["Marius Storm-Olsen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"77842","messageId":"\"Storm-Olsen*Marius___oslo/trolltech////////////////Marius#b#Storm-Olsen\"@MHS","threadId":"13688","inReplyTo":null,"subject":"[PATCH] Ensure that commit/status don't stat all files when core.ignoreStat = true","fromName":"Marius Storm-Olsen","fromEmail":"marius@trolltech.com","sentAt":"2008-05-27T08:15:09Z","receivedAt":"2008-05-27T08:15:09Z","isPatch":true,"sender":{"key":"marius@trolltech.com","avatar":"https://gravatar.com/avatar/a40071d8f651862c6ab10bd7996f0ad84d94f06c0399de9e3fa4f06beb390a71?d=mp&s=160"},"body":"The core.ignoreStat option is used to assume that files in the\nindex are unchanged, thus avoiding expensive lstat()s on slow\nsystems. However, due to refresh_cache_ent still stating but\nignoring the info, and the listing of untracked files in\ncommit/status, we would still lstat() all the files.\n\nThis change shortcuts the refresh_cache_ent(), and makes\ncommit/status not list untracked files, unless the -u option\nis specified.\n\nSigned-off-by: Marius Storm-Olsen <marius@trolltech.com>\n---\n read-cache.c |   10 ++++++++++\n wt-status.c  |   11 ++++++++++-\n 2 files changed, 20 insertions(+), 1 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 8b467f8..104e387 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -882,6 +882,16 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,\n \tif (ce_uptodate(ce))\n \t\treturn ce;\n \n+\t/*\n+\t * assume_unchanged is used to avoid lstats to check if the\n+\t * file has been modified. When true, the user need to\n+\t * manually update the index.\n+\t */\n+\tif (assume_unchanged) {\n+\t\tce_mark_uptodate(ce);\n+\t\treturn ce;\n+\t}\n+\n \tif (lstat(ce->name, &st) < 0) {\n \t\tif (err)\n \t\t\t*err = errno;\ndiff --git a/wt-status.c b/wt-status.c\nindex a44c543..72db466 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -342,7 +342,14 @@ void wt_status_print(struct wt_status *s)\n \twt_status_print_changed(s);\n \tif (wt_status_submodule_summary)\n \t\twt_status_print_submodule_summary(s);\n-\twt_status_print_untracked(s);\n+\n+\tif (assume_unchanged && !s->untracked) {\n+\t\tif (s->commitable)\n+\t\t\tfprintf(s->fp, \"# Untracked files not listed (use -u option to show untracked files)\\n\");\n+\t\t/* !s->commitable message displayed below */\n+\t}\n+\telse\n+\t\twt_status_print_untracked(s);\n \n \tif (s->verbose && !s->is_initial)\n \t\twt_status_print_verbose(s);\n@@ -357,6 +364,8 @@ void wt_status_print(struct wt_status *s)\n \t\t\tprintf(\"nothing added to commit but untracked files present (use \\\"git add\\\" to track)\\n\");\n \t\telse if (s->is_initial)\n \t\t\tprintf(\"nothing to commit (create/copy files and use \\\"git add\\\" to track)\\n\");\n+\t\telse if (assume_unchanged && !s->untracked)\n+\t\t\tprintf(\"nothing to commit (use -u to show untracked files)\\n\");\n \t\telse\n \t\t\tprintf(\"nothing to commit (working directory clean)\\n\");\n \t}\n-- \n1.5.5.1.501.gefb4\n"}]}