git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] prune: show progress while marking reachable objects
Date: Sat,  5 Nov 2011 19:00:08 +0700	[thread overview]
Message-ID: <1320494408-6373-1-git-send-email-pclouds@gmail.com> (raw)

prune already shows progress meter while pruning. The marking part may
take a few seconds or more, depending on repository size. Show
progress meter during this time too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/prune.c  |    6 +++++-
 builtin/reflog.c |    2 +-
 reachable.c      |   14 ++++++++++----
 reachable.h      |    3 ++-
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/builtin/prune.c b/builtin/prune.c
index e65690b..6b39d3f 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -5,6 +5,7 @@
 #include "builtin.h"
 #include "reachable.h"
 #include "parse-options.h"
+#include "progress.h"
 #include "dir.h"
 
 static const char * const prune_usage[] = {
@@ -124,6 +125,7 @@ static void remove_temporary_files(const char *path)
 int cmd_prune(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info revs;
+	struct progress *progress;
 	const struct option options[] = {
 		OPT__DRY_RUN(&show_only, "do not remove, show only"),
 		OPT__VERBOSE(&verbose, "report pruned objects"),
@@ -152,7 +154,9 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 		else
 			die("unrecognized argument: %s", name);
 	}
-	mark_reachable_objects(&revs, 1);
+	progress = start_progress_delay("Checking connectivity", 0, 0, 2);
+	mark_reachable_objects(&revs, 1, progress);
+	stop_progress(&progress);
 	prune_object_dir(get_object_directory());
 
 	prune_packed_objects(show_only);
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 3a9c80f..062d7da 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -647,7 +647,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 		init_revisions(&cb.revs, prefix);
 		if (cb.verbose)
 			printf("Marking reachable objects...");
-		mark_reachable_objects(&cb.revs, 0);
+		mark_reachable_objects(&cb.revs, 0, NULL);
 		if (cb.verbose)
 			putchar('\n');
 	}
diff --git a/reachable.c b/reachable.c
index 3fc6b1d..293d37d 100644
--- a/reachable.c
+++ b/reachable.c
@@ -7,6 +7,7 @@
 #include "revision.h"
 #include "reachable.h"
 #include "cache-tree.h"
+#include "progress.h"
 
 static void process_blob(struct blob *blob,
 			 struct object_array *p,
@@ -81,21 +82,25 @@ static void process_tag(struct tag *tag, struct object_array *p, const char *nam
 		add_object(tag->tagged, p, NULL, name);
 }
 
-static void walk_commit_list(struct rev_info *revs)
+static void walk_commit_list(struct rev_info *revs, struct progress *progress)
 {
 	int i;
 	struct commit *commit;
 	struct object_array objects = OBJECT_ARRAY_INIT;
+	uint32_t count = 0;
 
 	/* Walk all commits, process their trees */
-	while ((commit = get_revision(revs)) != NULL)
+	while ((commit = get_revision(revs)) != NULL) {
 		process_tree(commit->tree, &objects, NULL, "");
+		display_progress(progress, ++count);
+	}
 
 	/* Then walk all the pending objects, recursively processing them too */
 	for (i = 0; i < revs->pending.nr; i++) {
 		struct object_array_entry *pending = revs->pending.objects + i;
 		struct object *obj = pending->item;
 		const char *name = pending->name;
+		display_progress(progress, ++count);
 		if (obj->type == OBJ_TAG) {
 			process_tag((struct tag *) obj, &objects, name);
 			continue;
@@ -191,7 +196,8 @@ static void add_cache_refs(struct rev_info *revs)
 		add_cache_tree(active_cache_tree, revs);
 }
 
-void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
+void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
+			    struct progress *progress)
 {
 	/*
 	 * Set up revision parsing, and mark us as being interested
@@ -217,5 +223,5 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
 	 */
 	if (prepare_revision_walk(revs))
 		die("revision walk setup failed");
-	walk_commit_list(revs);
+	walk_commit_list(revs, progress);
 }
diff --git a/reachable.h b/reachable.h
index 4075181..5d082ad 100644
--- a/reachable.h
+++ b/reachable.h
@@ -1,6 +1,7 @@
 #ifndef REACHEABLE_H
 #define REACHEABLE_H
 
-extern void mark_reachable_objects(struct rev_info *revs, int mark_reflog);
+struct progress;
+extern void mark_reachable_objects(struct rev_info *revs, int mark_reflog, struct progress *);
 
 #endif
-- 
1.7.4.74.g639db

             reply	other threads:[~2011-11-05 12:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-05 12:00 Nguyễn Thái Ngọc Duy [this message]
2011-11-08  5:31 ` [PATCH] prune: show progress while marking reachable objects Jeff King
2011-11-08  5:34   ` [PATCH 1/2] prune: handle --progress/no-progress Jeff King
2011-11-09  4:23     ` [PATCH] " Nguyễn Thái Ngọc Duy
2011-11-08  5:37   ` [PATCH 2/2] reachable: per-object progress Jeff King
2011-11-08  5:40   ` [PATCH] prune: show progress while marking reachable objects Junio C Hamano
2011-11-09  4:26   ` Nguyen Thai Ngoc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1320494408-6373-1-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).