/* 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 */
 
 "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;
 
 #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);
 
                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);