WIP fetch command, very dirty
[gitlite/.git] / callbacks.h
CommitLineData
e545bdd1
SB
1static int
2progress_cb(const char *str, int len, void *data)
3{
4 (void)data;
5 printf("remote: %.*s", len, str);
6 fflush(stdout); /* We don't have the \n to force the flush */
7 return 0;
8}
9
10static int
11update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data)
12{
13 char a_str[GIT_OID_HEXSZ+1], b_str[GIT_OID_HEXSZ+1];
14 (void)data;
15
16 git_oid_fmt(b_str, b);
17 b_str[GIT_OID_HEXSZ] = '\0';
18
19 if (git_oid_is_zero(a)) {
20 printf("[new] %.20s %s\n", b_str, refname);
21 } else {
22 git_oid_fmt(a_str, a);
23 a_str[GIT_OID_HEXSZ] = '\0';
24 printf("[updated] %.10s..%.10s %s\n", a_str, b_str, refname);
25 }
26
27 return 0;
28}
29
30static int
31transfer_progress_cb(const git_indexer_progress *stats, void *payload)
32{
33 (void)payload;
34
35 if (stats->received_objects == stats->total_objects) {
36 printf("Resolving deltas %u/%u\r", stats->indexed_deltas, stats->total_deltas);
37 } else if (stats->total_objects > 0) {
38 printf("Received %u/%u objects (%u) in %" PRIuZ " bytes\r", stats->received_objects, stats->total_objects, stats->indexed_objects, stats->received_bytes);
39 }
40 return 0;
41}