]> asedeno.scripts.mit.edu Git - git.git/blobdiff - log-tree.c
blame: --show-stats for easier optimization work.
[git.git] / log-tree.c
index 4e3c7fd6fb1e0665d9be8ac6840ec66a4e3130fb..ac8619404797633436258dbf9d76f9f4aa323395 100644 (file)
@@ -102,6 +102,16 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
        return at;
 }
 
+static unsigned int digits_in_number(unsigned int number)
+{
+       unsigned int i = 10, result = 1;
+       while (i <= number) {
+               i *= 10;
+               result++;
+       }
+       return result;
+}
+
 void show_log(struct rev_info *opt, const char *sep)
 {
        static char this_header[16384];
@@ -155,7 +165,8 @@ void show_log(struct rev_info *opt, const char *sep)
                if (opt->total > 0) {
                        static char buffer[64];
                        snprintf(buffer, sizeof(buffer),
-                                       "Subject: [PATCH %d/%d] ",
+                                       "Subject: [PATCH %0*d/%d] ",
+                                       digits_in_number(opt->total),
                                        opt->nr, opt->total);
                        subject = buffer;
                } else if (opt->total == 0)