summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-09-15 17:56:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-09-17 16:38:50 (GMT)
commitae9af12287b2c37512f12c137173dde7ea5192a0 (patch)
treec4177e26c27cfd9d282ea4879adb2ced55e0af99 /builtin/commit.c
parent1d4361b0f344188ab5eec6dcea01f61a3a3a1670 (diff)
downloadgit-ae9af12287b2c37512f12c137173dde7ea5192a0.zip
git-ae9af12287b2c37512f12c137173dde7ea5192a0.tar.gz
git-ae9af12287b2c37512f12c137173dde7ea5192a0.tar.bz2
status: show progress bar if refreshing the index takes too long
Refreshing the index is usually very fast, but it can still take a long time sometimes. Cold cache is one. Or copying a repo to a new place (*). It's good to show something to let the user know "git status" is not hanging, it's just busy doing something. (*) In this case, all stat info in the index becomes invalid and git falls back to rehashing all file content to see if there's any difference between updating stat info in the index. This is quite expensive. Even with a repo as small as git.git, it takes 3 seconds. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 0d9828e..7523463 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1295,6 +1295,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
static int no_renames = -1;
static const char *rename_score_arg = (const char *)-1;
static struct wt_status s;
+ unsigned int progress_flag = 0;
int fd;
struct object_id oid;
static struct option builtin_status_options[] = {
@@ -1355,8 +1356,13 @@ int cmd_status(int argc, const char **argv, const char *prefix)
PATHSPEC_PREFER_FULL,
prefix, argv);
- read_cache_preload(&s.pathspec);
- refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &s.pathspec, NULL, NULL);
+ if (status_format != STATUS_FORMAT_PORCELAIN &&
+ status_format != STATUS_FORMAT_PORCELAIN_V2)
+ progress_flag = REFRESH_PROGRESS;
+ read_index_preload(&the_index, &s.pathspec, progress_flag);
+ refresh_index(&the_index,
+ REFRESH_QUIET|REFRESH_UNMERGED|progress_flag,
+ &s.pathspec, NULL, NULL);
if (use_optional_locks())
fd = hold_locked_index(&index_lock, 0);