Merge branch 'jc/maint-blame-minimal'
[gitweb.git] / builtin / diff.c
index 0fe638fc45c780e53901b8be22d3b4d715be3c30..9069dc41be33a362ff04d52c00b4830eed272826 100644 (file)
@@ -14,6 +14,7 @@
 #include "log-tree.h"
 #include "builtin.h"
 #include "submodule.h"
+#include "sha1-array.h"
 
 struct blobinfo {
        unsigned char sha1[20];
@@ -169,7 +170,7 @@ static int builtin_diff_combined(struct rev_info *revs,
                                 struct object_array_entry *ent,
                                 int ents)
 {
-       const unsigned char (*parent)[20];
+       struct sha1_array parents = SHA1_ARRAY_INIT;
        int i;
 
        if (argc > 1)
@@ -177,12 +178,11 @@ static int builtin_diff_combined(struct rev_info *revs,
 
        if (!revs->dense_combined_merges && !revs->combine_merges)
                revs->dense_combined_merges = revs->combine_merges = 1;
-       parent = xmalloc(ents * sizeof(*parent));
-       for (i = 0; i < ents; i++)
-               hashcpy((unsigned char *)(parent + i), ent[i].item->sha1);
-       diff_tree_combined(parent[0], parent + 1, ents - 1,
+       for (i = 1; i < ents; i++)
+               sha1_array_append(&parents, ent[i].item->sha1);
+       diff_tree_combined(ent[0].item->sha1, &parents,
                           revs->dense_combined_merges, revs);
-       free((void *)parent);
+       sha1_array_clear(&parents);
        return 0;
 }
 
@@ -285,6 +285,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        /* Otherwise, we are doing the usual "git" diff */
        rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
 
+       /* Scale to real terminal size and respect statGraphWidth config */
+       rev.diffopt.stat_width = -1;
+       rev.diffopt.stat_graph_width = -1;
+
        /* Default to let external and textconv be used */
        DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
        DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
@@ -323,7 +327,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                                add_head_to_pending(&rev);
                                if (!rev.pending.nr) {
                                        struct tree *tree;
-                                       tree = lookup_tree((const unsigned char*)EMPTY_TREE_SHA1_BIN);
+                                       tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
                                        add_pending_object(&rev, &tree->object, "HEAD");
                                }
                                break;