Merge branch 'nd/no-the-index'
[gitweb.git] / builtin / diff-tree.c
index a5718d96ee2c5304ed19fe633c7fdd86dc18ec8e..d07bf2e4c4b5c2ec2f93930c0dd16897df32b25f 100644 (file)
@@ -25,7 +25,7 @@ static int stdin_diff_commit(struct commit *commit, const char *p)
 
        /* Graft the fake parents locally to the commit */
        while (isspace(*p++) && !parse_oid_hex(p, &oid, &p)) {
-               struct commit *parent = lookup_commit(&oid);
+               struct commit *parent = lookup_commit(the_repository, &oid);
                if (!pptr) {
                        /* Free the real parent list */
                        free_commit_list(commit->parents);
@@ -163,9 +163,11 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
                int saved_nrl = 0;
                int saved_dcctc = 0;
 
-               if (opt->diffopt.detect_rename)
-                       opt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |
-                                              DIFF_SETUP_USE_CACHE);
+               if (opt->diffopt.detect_rename) {
+                       if (!the_index.cache)
+                               read_index(&the_index);
+                       opt->diffopt.setup |= DIFF_SETUP_USE_SIZE_CACHE;
+               }
                while (fgets(line, sizeof(line), stdin)) {
                        struct object_id oid;