commit: add repository argument to lookup_commit_reference
[gitweb.git] / builtin / diff-tree.c
index d66499909e82e255a8d1356b606f9b901935317f..a5718d96ee2c5304ed19fe633c7fdd86dc18ec8e 100644 (file)
@@ -5,12 +5,13 @@
 #include "log-tree.h"
 #include "builtin.h"
 #include "submodule.h"
+#include "repository.h"
 
 static struct rev_info log_tree_opt;
 
 static int diff_tree_commit_oid(const struct object_id *oid)
 {
-       struct commit *commit = lookup_commit_reference(oid);
+       struct commit *commit = lookup_commit_reference(the_repository, oid);
        if (!commit)
                return -1;
        return log_tree_commit(&log_tree_opt, commit);
@@ -45,7 +46,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
        struct tree *tree2;
        if (!isspace(*p++) || parse_oid_hex(p, &oid, &p) || *p)
                return error("Need exactly two trees, separated by a space");
-       tree2 = lookup_tree(&oid);
+       tree2 = lookup_tree(the_repository, &oid);
        if (!tree2 || parse_tree(tree2))
                return -1;
        printf("%s %s\n", oid_to_hex(&tree1->object.oid),
@@ -68,7 +69,7 @@ static int diff_tree_stdin(char *line)
        line[len-1] = 0;
        if (parse_oid_hex(line, &oid, &p))
                return -1;
-       obj = parse_object(&oid);
+       obj = parse_object(the_repository, &oid);
        if (!obj)
                return -1;
        if (obj->type == OBJ_COMMIT)
@@ -76,7 +77,7 @@ static int diff_tree_stdin(char *line)
        if (obj->type == OBJ_TREE)
                return stdin_diff_trees((struct tree *)obj, p);
        error("Object %s is a %s, not a commit or tree",
-             oid_to_hex(&oid), typename(obj->type));
+             oid_to_hex(&oid), type_name(obj->type));
        return -1;
 }
 
@@ -110,6 +111,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 
        git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
        init_revisions(opt, prefix);
+       if (read_cache() < 0)
+               die(_("index file corrupt"));
        opt->abbrev = 0;
        opt->diff = 1;
        opt->disable_stdin = 1;