diff_flush(): leakfix.
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index ec51e7d..fa1613c 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -963,7 +963,7 @@ void diff_free_filepair(struct diff_filepair *p)
 }
 
 /* This is different from find_unique_abbrev() in that
- * it needs to deal with 0{40} SHA1.
+ * it stuffs the result with dots for alignment.
  */
 const char *diff_unique_abbrev(const unsigned char *sha1, int len)
 {
@@ -973,16 +973,8 @@ const char *diff_unique_abbrev(const unsigned char *sha1, int len)
                return sha1_to_hex(sha1);
 
        abbrev = find_unique_abbrev(sha1, len);
-       if (!abbrev) {
-               if (!memcmp(sha1, null_sha1, 20)) {
-                       char *buf = sha1_to_hex(null_sha1);
-                       if (len < 37)
-                               strcpy(buf + len, "...");
-                       return buf;
-               }
-               else 
-                       return sha1_to_hex(sha1);
-       }
+       if (!abbrev)
+               return sha1_to_hex(sha1);
        abblen = strlen(abbrev);
        if (abblen < 37) {
                static char hex[41];
@@ -1233,28 +1225,34 @@ void diff_flush(struct diff_options *options)
 
        for (i = 0; i < q->nr; i++) {
                struct diff_filepair *p = q->queue[i];
-               if ((diff_output_format == DIFF_FORMAT_NO_OUTPUT) ||
-                   (p->status == DIFF_STATUS_UNKNOWN))
-                       continue;
-               if (p->status == 0)
-                       die("internal error in diff-resolve-rename-copy");
-               switch (diff_output_format) {
-               case DIFF_FORMAT_PATCH:
-                       diff_flush_patch(p, options);
-                       break;
-               case DIFF_FORMAT_RAW:
-               case DIFF_FORMAT_NAME_STATUS:
-                       diff_flush_raw(p, line_termination,
-                                      inter_name_termination,
-                                      options);
+
+               switch (p->status) {
+               case DIFF_STATUS_UNKNOWN:
                        break;
-               case DIFF_FORMAT_NAME:
-                       diff_flush_name(p,
-                                       inter_name_termination,
-                                       line_termination);
+               case 0:
+                       die("internal error in diff-resolve-rename-copy");
                        break;
+               default:
+                       switch (diff_output_format) {
+                       case DIFF_FORMAT_PATCH:
+                               diff_flush_patch(p, options);
+                               break;
+                       case DIFF_FORMAT_RAW:
+                       case DIFF_FORMAT_NAME_STATUS:
+                               diff_flush_raw(p, line_termination,
+                                              inter_name_termination,
+                                              options);
+                               break;
+                       case DIFF_FORMAT_NAME:
+                               diff_flush_name(p,
+                                               inter_name_termination,
+                                               line_termination);
+                               break;
+                       case DIFF_FORMAT_NO_OUTPUT:
+                               break;
+                       }
                }
-               diff_free_filepair(q->queue[i]);
+               diff_free_filepair(p);
        }
        free(q->queue);
        q->queue = NULL;