Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

prune: show progress while marking reachable objects

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information...
commit dc347195ccfbc87b6e445f5c31a5500e1df6c9b5 1 parent b04ba2b
Nguyễn Thái Ngọc Duy pclouds authored gitster committed
6 builtin/prune.c
@@ -5,6 +5,7 @@
5 5 #include "builtin.h"
6 6 #include "reachable.h"
7 7 #include "parse-options.h"
  8 +#include "progress.h"
8 9 #include "dir.h"
9 10
10 11 static const char * const prune_usage[] = {
@@ -124,6 +125,7 @@ static void remove_temporary_files(const char *path)
124 125 int cmd_prune(int argc, const char **argv, const char *prefix)
125 126 {
126 127 struct rev_info revs;
  128 + struct progress *progress;
127 129 const struct option options[] = {
128 130 OPT__DRY_RUN(&show_only, "do not remove, show only"),
129 131 OPT__VERBOSE(&verbose, "report pruned objects"),
@@ -152,7 +154,9 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
152 154 else
153 155 die("unrecognized argument: %s", name);
154 156 }
155   - mark_reachable_objects(&revs, 1);
  157 + progress = start_progress_delay("Checking connectivity", 0, 0, 2);
  158 + mark_reachable_objects(&revs, 1, progress);
  159 + stop_progress(&progress);
156 160 prune_object_dir(get_object_directory());
157 161
158 162 prune_packed_objects(show_only);
2  builtin/reflog.c
@@ -647,7 +647,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
647 647 init_revisions(&cb.revs, prefix);
648 648 if (cb.verbose)
649 649 printf("Marking reachable objects...");
650   - mark_reachable_objects(&cb.revs, 0);
  650 + mark_reachable_objects(&cb.revs, 0, NULL);
651 651 if (cb.verbose)
652 652 putchar('\n');
653 653 }
14 reachable.c
@@ -7,6 +7,7 @@
7 7 #include "revision.h"
8 8 #include "reachable.h"
9 9 #include "cache-tree.h"
  10 +#include "progress.h"
10 11
11 12 static void process_blob(struct blob *blob,
12 13 struct object_array *p,
@@ -81,21 +82,25 @@ static void process_tag(struct tag *tag, struct object_array *p, const char *nam
81 82 add_object(tag->tagged, p, NULL, name);
82 83 }
83 84
84   -static void walk_commit_list(struct rev_info *revs)
  85 +static void walk_commit_list(struct rev_info *revs, struct progress *progress)
85 86 {
86 87 int i;
87 88 struct commit *commit;
88 89 struct object_array objects = OBJECT_ARRAY_INIT;
  90 + uint32_t count = 0;
89 91
90 92 /* Walk all commits, process their trees */
91   - while ((commit = get_revision(revs)) != NULL)
  93 + while ((commit = get_revision(revs)) != NULL) {
92 94 process_tree(commit->tree, &objects, NULL, "");
  95 + display_progress(progress, ++count);
  96 + }
93 97
94 98 /* Then walk all the pending objects, recursively processing them too */
95 99 for (i = 0; i < revs->pending.nr; i++) {
96 100 struct object_array_entry *pending = revs->pending.objects + i;
97 101 struct object *obj = pending->item;
98 102 const char *name = pending->name;
  103 + display_progress(progress, ++count);
99 104 if (obj->type == OBJ_TAG) {
100 105 process_tag((struct tag *) obj, &objects, name);
101 106 continue;
@@ -191,7 +196,8 @@ static void add_cache_refs(struct rev_info *revs)
191 196 add_cache_tree(active_cache_tree, revs);
192 197 }
193 198
194   -void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
  199 +void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
  200 + struct progress *progress)
195 201 {
196 202 /*
197 203 * 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)
217 223 */
218 224 if (prepare_revision_walk(revs))
219 225 die("revision walk setup failed");
220   - walk_commit_list(revs);
  226 + walk_commit_list(revs, progress);
221 227 }
3  reachable.h
... ... @@ -1,6 +1,7 @@
1 1 #ifndef REACHEABLE_H
2 2 #define REACHEABLE_H
3 3
4   -extern void mark_reachable_objects(struct rev_info *revs, int mark_reflog);
  4 +struct progress;
  5 +extern void mark_reachable_objects(struct rev_info *revs, int mark_reflog, struct progress *);
5 6
6 7 #endif

0 comments on commit dc34719

Please sign in to comment.
Something went wrong with that request. Please try again.