revision.c: reduce implicit dependency the_repository
[gitweb.git] / builtin / diff-tree.c
index 91ba67070e252fa13a0e32e08a251ca58c7f930b..ef996126d7b521ea1de2c837e4ed97fdcb6f1e71 100644 (file)
@@ -110,7 +110,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
                usage(diff_tree_usage);
 
        git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
-       init_revisions(opt, prefix);
+       repo_init_revisions(the_repository, opt, prefix);
        if (read_cache() < 0)
                die(_("index file corrupt"));
        opt->abbrev = 0;
@@ -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;