Make it possible to not clobber object.util in sort_in_topological_order (take 2)
[git.git] / blame.c
diff --git a/blame.c b/blame.c
index 168b1f5..90338af 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -92,7 +92,7 @@ static struct patch *get_patch(struct commit *commit, struct commit *other)
                die("write failed: %s", strerror(errno));
        close(fd);
 
-       sprintf(diff_cmd, "diff -u0 %s %s", tmp_path1, tmp_path2);
+       sprintf(diff_cmd, "diff -0 %s %s", tmp_path1, tmp_path2);
        fin = popen(diff_cmd, "r");
        if (!fin)
                die("popen failed: %s", strerror(errno));
@@ -234,7 +234,7 @@ static void print_patch(struct patch *p)
        }
 }
 
-#if 0
+#if DEBUG
 /* For debugging only */
 static void print_map(struct commit *cmit, struct commit *other)
 {
@@ -550,13 +550,22 @@ static void get_commit_info(struct commit* commit, struct commit_info* ret)
        *tmp = 0;
 }
 
-char* format_time(unsigned long time, const char* tz)
+static const char* format_time(unsigned long time, const char* tz_str)
 {
        static char time_buf[128];
        time_t t = time;
-
-       strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", gmtime(&t));
-       strcat(time_buf, tz);
+       int minutes, tz;
+       struct tm *tm;
+
+       tz = atoi(tz_str);
+       minutes = tz < 0 ? -tz : tz;
+       minutes = (minutes / 100)*60 + (minutes % 100);
+       minutes = tz < 0 ? -minutes : minutes;
+       t = time + minutes * 60;
+       tm = gmtime(&t);
+
+       strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", tm);
+       strcat(time_buf, tz_str);
        return time_buf;
 }
 
@@ -589,7 +598,7 @@ int main(int argc, const char **argv)
                                usage(blame_usage);
                        else if(!strcmp(argv[i], "-l") ||
                                !strcmp(argv[i], "--long")) {
-                               sha1_len = 20;
+                               sha1_len = 40;
                                continue;
                        } else if(!strcmp(argv[i], "-c") ||
                                  !strcmp(argv[i], "--compability")) {
@@ -651,7 +660,9 @@ int main(int argc, const char **argv)
        process_commits(&rev, filename, &initial);
 
        buf = blame_contents;
-       max_digits = 1 + log(num_blame_lines+1)/log(10);
+       for (max_digits = 1, i = 10; i <= num_blame_lines + 1; max_digits++)
+               i *= 10;
+
        for (i = 0; i < num_blame_lines; i++) {
                struct commit *c = blame_lines[i];
                if (!c)