@matheusbsbs / matheus-bagliano / commits / 2a128d63dc
Fork 0

add throughput display to git-push

This one triggers only when git-pack-objects is called with --all-progress and --stdout which is the combination used by git-push. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed Oct 30, 2007 at 17:06 UTC 2a128d63dc140e8daeaf68659d9263b7389b7d1b
3 files changed +13 -1
builtin-pack-objects.c
+1 -1
@@ -606,7 +606,7 @@ static void write_pack_file(void)
606 char *pack_tmp_name = NULL;
607
608 if (pack_to_stdout) {
609 - f = sha1fd(1, "<stdout>");
609 + f = sha1fd_throughput(1, "<stdout>", progress_state);
610 } else {
611 char tmpname[PATH_MAX];
612 int fd;
csum-file.c
+8
@@ -8,6 +8,7 @@
8 * able to verify hasn't been messed with afterwards.
9 */
10 #include "cache.h"
11 +#include "progress.h"
12 #include "csum-file.h"
13
14 static void sha1flush(struct sha1file *f, unsigned int count)
@@ -17,6 +18,7 @@ static void sha1flush(struct sha1file *f, unsigned int count)
18 for (;;) {
19 int ret = xwrite(f->fd, buf, count);
20 if (ret > 0) {
21 + display_throughput(f->tp, ret);
22 buf = (char *) buf + ret;
23 count -= ret;
24 if (count)
@@ -79,6 +81,11 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)
81 }
82
83 struct sha1file *sha1fd(int fd, const char *name)
84 +{
85 + return sha1fd_throughput(fd, name, NULL);
86 +}
87 +
88 +struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp)
89 {
90 struct sha1file *f;
91 unsigned len;
@@ -94,6 +101,7 @@ struct sha1file *sha1fd(int fd, const char *name)
101 f->fd = fd;
102 f->error = 0;
103 f->offset = 0;
104 + f->tp = tp;
105 f->do_crc = 0;
106 SHA1_Init(&f->ctx);
107 return f;
csum-file.h
+4
@@ -1,11 +1,14 @@
1 #ifndef CSUM_FILE_H
2 #define CSUM_FILE_H
3
4 +struct progress;
5 +
6 /* A SHA1-protected file */
7 struct sha1file {
8 int fd, error;
9 unsigned int offset, namelen;
10 SHA_CTX ctx;
11 + struct progress *tp;
12 char name[PATH_MAX];
13 int do_crc;
14 uint32_t crc32;
@@ -13,6 +16,7 @@ struct sha1file {
16 };
17
18 extern struct sha1file *sha1fd(int fd, const char *name);
19 +extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
20 extern int sha1close(struct sha1file *, unsigned char *, int);
21 extern int sha1write(struct sha1file *, void *, unsigned int);
22 extern void crc32_begin(struct sha1file *);