summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 29e55cd)
raw | patch | inline | side by side (parent: 29e55cd)
author | Linus Torvalds <torvalds@osdl.org> | |
Sat, 11 Feb 2006 04:31:09 +0000 (20:31 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 11 Feb 2006 06:28:30 +0000 (22:28 -0800) |
It used to be that "git-unpack-objects" would give nice percentages, but
now that we don't unpack the initial clone pack any more, it doesn't. And
I'd love to do that nice percentage view in the pack objects downloader
too, but the thing doesn't even read the pack header, much less know how
much it's going to get, so I was lazy and didn't.
Instead, it at least prints out how much data it's gotten, and what the
packing speed is. Which makes the user realize that it's actually doing
something useful instead of sitting there silently (and if the recipient
knows how large the final result is, he can at least make a guess about
when it migt be done).
So with this patch, I get something like this on my DSL line:
[torvalds@g5 ~]$ time git clone master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 clone-test
Packing 188543 objects
48.398MB (154 kB/s)
where even the speed approximation seems to be roughtly correct (even
though my algorithm is a truly stupid one, and only really gives "speed in
the last half second or so").
Anyway, _something_ like this is definitely needed. It could certainly be
better (if it showed the same kind of thing that git-unpack-objects did,
that would be much nicer, but would require parsing the object stream as
it comes in). But this is big step forward, I think.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
now that we don't unpack the initial clone pack any more, it doesn't. And
I'd love to do that nice percentage view in the pack objects downloader
too, but the thing doesn't even read the pack header, much less know how
much it's going to get, so I was lazy and didn't.
Instead, it at least prints out how much data it's gotten, and what the
packing speed is. Which makes the user realize that it's actually doing
something useful instead of sitting there silently (and if the recipient
knows how large the final result is, he can at least make a guess about
when it migt be done).
So with this patch, I get something like this on my DSL line:
[torvalds@g5 ~]$ time git clone master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 clone-test
Packing 188543 objects
48.398MB (154 kB/s)
where even the speed approximation seems to be roughtly correct (even
though my algorithm is a truly stupid one, and only really gives "speed in
the last half second or so").
Anyway, _something_ like this is definitely needed. It could certainly be
better (if it showed the same kind of thing that git-unpack-objects did,
that would be much nicer, but would require parsing the object stream as
it comes in). But this is big step forward, I think.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
cache.h | patch | blob | history | |
clone-pack.c | patch | blob | history | |
fetch-clone.c | patch | blob | history | |
fetch-pack.c | patch | blob | history |
index bdbe2d683e18237e2a797573e45b9c38383eaf04..c255421ab96f1ca3ba1913e84d377ada003d04db 100644 (file)
--- a/cache.h
+++ b/cache.h
/* Finish off pack transfer receiving end */
extern int receive_unpack_pack(int fd[2], const char *me, int quiet);
-extern int receive_keep_pack(int fd[2], const char *me);
+extern int receive_keep_pack(int fd[2], const char *me, int quiet);
#endif /* CACHE_H */
diff --git a/clone-pack.c b/clone-pack.c
index f634431be1f6ba3fa518d987a227c33f19543fb6..719e1c4fc8df0aec13bdcbab16c4d9e16cd3072e 100644 (file)
--- a/clone-pack.c
+++ b/clone-pack.c
"git-clone-pack [--exec=<git-upload-pack>] [<host>:]<directory> [<heads>]*";
static const char *exec = "git-upload-pack";
+static int quiet = 0;
+
static void clone_handshake(int fd[2], struct ref *ref)
{
unsigned char sha1[20];
}
clone_handshake(fd, refs);
- status = receive_keep_pack(fd, "git-clone-pack");
+ if (!quiet)
+ fprintf(stderr, "Generating pack ...\r");
+ status = receive_keep_pack(fd, "git-clone-pack", quiet);
if (!status) {
if (nr_match == 0)
char *arg = argv[i];
if (*arg == '-') {
- if (!strcmp("-q", arg))
+ if (!strcmp("-q", arg)) {
+ quiet = 1;
continue;
+ }
if (!strncmp("--exec=", arg, 7)) {
exec = arg + 7;
continue;
diff --git a/fetch-clone.c b/fetch-clone.c
index 859f4009419d37c2a21ecf6941aaad4fe004e747..b67d9764978cc5758612884e2a906237d349795e 100644 (file)
--- a/fetch-clone.c
+++ b/fetch-clone.c
#include "cache.h"
#include "exec_cmd.h"
#include <sys/wait.h>
+#include <sys/time.h>
static int finish_pack(const char *pack_tmp_name, const char *me)
{
die("git-unpack-objects died of unnatural causes %d", status);
}
-int receive_keep_pack(int fd[2], const char *me)
+int receive_keep_pack(int fd[2], const char *me, int quiet)
{
char tmpfile[PATH_MAX];
int ofd, ifd;
+ unsigned long total;
+ static struct timeval prev_tv;
ifd = fd[0];
snprintf(tmpfile, sizeof(tmpfile),
if (ofd < 0)
return error("unable to create temporary file %s", tmpfile);
+ gettimeofday(&prev_tv, NULL);
+ total = 0;
while (1) {
char buf[8192];
ssize_t sz, wsz, pos;
}
pos += wsz;
}
+ total += sz;
+ if (!quiet) {
+ static unsigned long last;
+ struct timeval tv;
+ unsigned long diff = total - last;
+ /* not really "msecs", but a power-of-two millisec (1/1024th of a sec) */
+ unsigned long msecs;
+
+ gettimeofday(&tv, NULL);
+ msecs = tv.tv_sec - prev_tv.tv_sec;
+ msecs <<= 10;
+ msecs += (int)(tv.tv_usec - prev_tv.tv_usec) >> 10;
+ if (msecs > 500) {
+ prev_tv = tv;
+ last = total;
+ fprintf(stderr, "%4lu.%03luMB (%lu kB/s) \r",
+ total >> 20,
+ 1000*((total >> 10) & 1023)>>10,
+ diff / msecs );
+ }
+ }
}
close(ofd);
return finish_pack(tmpfile, me);
diff --git a/fetch-pack.c b/fetch-pack.c
index 27f5d2a5ff78340d791d1162ec07c153740ac2d2..aa6f42ae1b45c896395fc146990db22cb61e2f60 100644 (file)
--- a/fetch-pack.c
+++ b/fetch-pack.c
fprintf(stderr, "warning: no common commits\n");
if (keep_pack)
- status = receive_keep_pack(fd, "git-fetch-pack");
+ status = receive_keep_pack(fd, "git-fetch-pack", quiet);
else
status = receive_unpack_pack(fd, "git-fetch-pack", quiet);