Thread (80 messages) flat view 80 messages, 6 authors, 2016-06-15

Re: [PATCH 66/68] fsck: use for_each_loose_file_in_objdir

From: Jeff King <hidden>
Date: 2016-06-15 23:06:42
Subsystem: the rest · Maintainer: Linus Torvalds

On Thu, Sep 24, 2015 at 05:08:32PM -0400, Jeff King wrote:
quoted hunk ↗ jump to hunk
+static int fsck_subdir(int nr, const char *path, void *progress)
+{
+	display_progress(progress, nr + 1);
+	return 0;
+}
+
 static void fsck_object_dir(const char *path)
 {
-	int i;
 	struct progress *progress = NULL;
 
 	if (verbose)
@@ -501,12 +481,9 @@ static void fsck_object_dir(const char *path)
 
 	if (show_progress)
 		progress = start_progress(_("Checking object directories"), 256);
-	for (i = 0; i < 256; i++) {
-		static char dir[4096];
-		sprintf(dir, "%s/%02x", path, i);
-		fsck_dir(i, dir);
-		display_progress(progress, i+1);
-	}
+
+	for_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir,
+				      progress);
 	stop_progress(&progress);
I happened to be running git-fsck today and noticed that it finished
with the progress bar still reading 94%. The problem is that we update
the progress when we finish a subdir, but of course we do not
necessarily have all 256 subdirs, and the for_each_loose code only
triggers our callback for ones that exist.

So we need this on top:
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 2fe6a31..d50efd5 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -484,6 +484,7 @@ static void fsck_object_dir(const char *path)
 
 	for_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir,
 				      progress);
+	display_progress(progress, 256);
 	stop_progress(&progress);
 }
 
to make things pretty.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help