Skip to content

Commit 2a128d6

Browse files
Nicolas Pitregitster
authored andcommitted
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>
1 parent 74b6792 commit 2a128d6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

builtin-pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static void write_pack_file(void)
606606
char *pack_tmp_name = NULL;
607607

608608
if (pack_to_stdout) {
609-
f = sha1fd(1, "<stdout>");
609+
f = sha1fd_throughput(1, "<stdout>", progress_state);
610610
} else {
611611
char tmpname[PATH_MAX];
612612
int fd;

csum-file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* able to verify hasn't been messed with afterwards.
99
*/
1010
#include "cache.h"
11+
#include "progress.h"
1112
#include "csum-file.h"
1213

1314
static void sha1flush(struct sha1file *f, unsigned int count)
@@ -17,6 +18,7 @@ static void sha1flush(struct sha1file *f, unsigned int count)
1718
for (;;) {
1819
int ret = xwrite(f->fd, buf, count);
1920
if (ret > 0) {
21+
display_throughput(f->tp, ret);
2022
buf = (char *) buf + ret;
2123
count -= ret;
2224
if (count)
@@ -79,6 +81,11 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)
7981
}
8082

8183
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)
8289
{
8390
struct sha1file *f;
8491
unsigned len;
@@ -94,6 +101,7 @@ struct sha1file *sha1fd(int fd, const char *name)
94101
f->fd = fd;
95102
f->error = 0;
96103
f->offset = 0;
104+
f->tp = tp;
97105
f->do_crc = 0;
98106
SHA1_Init(&f->ctx);
99107
return f;

csum-file.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
#ifndef CSUM_FILE_H
22
#define CSUM_FILE_H
33

4+
struct progress;
5+
46
/* A SHA1-protected file */
57
struct sha1file {
68
int fd, error;
79
unsigned int offset, namelen;
810
SHA_CTX ctx;
11+
struct progress *tp;
912
char name[PATH_MAX];
1013
int do_crc;
1114
uint32_t crc32;
1215
unsigned char buffer[8192];
1316
};
1417

1518
extern struct sha1file *sha1fd(int fd, const char *name);
19+
extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
1620
extern int sha1close(struct sha1file *, unsigned char *, int);
1721
extern int sha1write(struct sha1file *, void *, unsigned int);
1822
extern void crc32_begin(struct sha1file *);

0 commit comments

Comments
 (0)