summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 96a02f8)
raw | patch | inline | side by side (parent: 96a02f8)
author | Nicolas Pitre <nico@cam.org> | |
Fri, 20 Apr 2007 18:10:07 +0000 (14:10 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 23 Apr 2007 05:18:05 +0000 (22:18 -0700) |
If the progress bar ends up in a box, better provide a title for it too.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-pack-objects.c | patch | blob | history | |
builtin-unpack-objects.c | patch | blob | history | |
index-pack.c | patch | blob | history | |
progress.c | patch | blob | history | |
progress.h | patch | blob | history | |
unpack-trees.c | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index d7d9996f5e3b6ce58c4dbe26d89adf6d66de6281..b82762767013195fb58fe552296e61e951d92dbe 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
f = sha1fd(fd, pack_tmp_name);
}
- if (do_progress) {
- fprintf(stderr, "Writing %u objects.\n", nr_result);
- start_progress(&progress_state, "", nr_result);
- }
+ if (do_progress)
+ start_progress(&progress_state, "Writing %u objects...", "", nr_result);
hdr.hdr_signature = htonl(PACK_SIGNATURE);
hdr.hdr_version = htonl(PACK_VERSION);
return;
array = xmalloc(array_size);
memset(array, 0, array_size);
- if (progress) {
- fprintf(stderr, "Deltifying %u objects.\n", nr_result);
- start_progress(&progress_state, "", nr_result);
- }
+ if (progress)
+ start_progress(&progress_state, "Deltifying %u objects...", "", nr_result);
do {
struct object_entry *entry = list[--i];
prepare_packed_git();
- if (progress) {
- fprintf(stderr, "Generating pack...\n");
- start_progress(&progress_state, "Counting objects: ", 0);
- }
+ if (progress)
+ start_progress(&progress_state, "Generating pack...",
+ "Counting objects: ", 0);
if (!use_internal_rev_list)
read_object_list_from_stdin();
else {
index c370c7f834f69ba69d5366d47aadab3b6162b095..2bbda67fabfcc5292313c4ac6c462cd8911d9128 100644 (file)
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
die("unknown pack file version %d", ntohl(hdr->hdr_version));
use(sizeof(struct pack_header));
- if (!quiet) {
- fprintf(stderr, "Unpacking %d objects\n", nr_objects);
- start_progress(&progress, "", nr_objects);
- }
+ if (!quiet)
+ start_progress(&progress, "Unpacking %u objects...", "", nr_objects);
obj_list = xmalloc(nr_objects * sizeof(*obj_list));
for (i = 0; i < nr_objects; i++) {
unpack_one(i);
diff --git a/index-pack.c b/index-pack.c
index a49d03d6de170dbffa63b55c07bf9425b704380c..824004f9a2a53dcef1db3c083a4a94ce0eff9028 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
* - calculate SHA1 of all non-delta objects;
* - remember base (SHA1 or offset) for all deltas.
*/
- if (verbose) {
- fprintf(stderr, "Indexing %d objects.\n", nr_objects);
- start_progress(&progress, "", nr_objects);
- }
+ if (verbose)
+ start_progress(&progress, "Indexing %u objects...", "", nr_objects);
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
data = unpack_raw_entry(obj, &delta->base);
* recursively checking if the resulting object is used as a base
* for some more deltas.
*/
- if (verbose) {
- fprintf(stderr, "Resolving %d deltas.\n", nr_deltas);
- start_progress(&progress, "", nr_deltas);
- }
+ if (verbose)
+ start_progress(&progress, "Resolving %u deltas...", "", nr_deltas);
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
union delta_base base;
diff --git a/progress.c b/progress.c
index 702e1160660363ba727e5ad398edd1f6e13c0fde..478134bc69ea89877523c7650e264cd94419ec9b 100644 (file)
--- a/progress.c
+++ b/progress.c
if (percent != progress->last_percent || progress_update) {
progress->last_percent = percent;
fprintf(stderr, "%s%4u%% (%u/%u) done\r",
- progress->msg, percent, n, progress->total);
+ progress->prefix, percent, n, progress->total);
progress_update = 0;
return 1;
}
} else if (progress_update) {
- fprintf(stderr, "%s%u\r", progress->msg, n);
+ fprintf(stderr, "%s%u\r", progress->prefix, n);
progress_update = 0;
return 1;
}
return 0;
}
-void start_progress(struct progress *progress, const char *msg, unsigned total)
+void start_progress(struct progress *progress, const char *title,
+ const char *prefix, unsigned total)
{
- progress->msg = msg;
+ char buf[80];
+ progress->prefix = prefix;
progress->total = total;
progress->last_percent = -1;
+ if (snprintf(buf, sizeof(buf), title, total))
+ fprintf(stderr, "%s\n", buf);
set_progress_signal();
}
diff --git a/progress.h b/progress.h
index 5fa4948117824904a0249b03e29f8936e351748b..1f2661e81094ce44a11223a2cb1880b302e88b7a 100644 (file)
--- a/progress.h
+++ b/progress.h
#define __progress_h__
struct progress {
- const char *msg;
+ const char *prefix;
unsigned total;
unsigned last_percent;
};
int display_progress(struct progress *progress, unsigned n);
-void start_progress(struct progress *progress, const char *msg, unsigned total);
+void start_progress(struct progress *progress, const char *title,
+ const char *prefix, unsigned total);
void stop_progress(struct progress *progress);
#endif
diff --git a/unpack-trees.c b/unpack-trees.c
index 8a11622ccb58b192425b9300078e82760a6bce38..cefc4042d515d0df2b9ba76b2f5580289c641541 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
if (total < 250)
total = 0;
- if (total) {
- fprintf(stderr, "Checking files out...\n");
- start_progress(&progress, "", total);
- }
+ if (total)
+ start_progress(&progress, "Checking %u files out...",
+ "", total);
cnt = 0;
}