diff options
author | Junio C Hamano <junkio@cox.net> | 2005-04-20 18:06:49 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-20 18:06:49 -0700 |
commit | 38357e6703db9f2c1bff31de1ce7c7503c6db96a (patch) | |
tree | 122ad8b85c7e34ffbb897b0e9f6b1ad348f53cb8 /diff-cache.c | |
parent | f4913f91a960ebcfbc9c6a09dc909ce638cb5c66 (diff) | |
download | git-38357e6703db9f2c1bff31de1ce7c7503c6db96a.tar.gz git-38357e6703db9f2c1bff31de1ce7c7503c6db96a.tar.xz |
[PATCH] Teach diff-cache about commit objects
Updates diff-cache.c to use read_tree_with_tree_or_commit_sha1()
function. The end-user visible result is the same --- the command
takes either tree or commit ID.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'diff-cache.c')
-rw-r--r-- | diff-cache.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/diff-cache.c b/diff-cache.c index fcbc4900d..015fd5fec 100644 --- a/diff-cache.c +++ b/diff-cache.c @@ -220,7 +220,6 @@ int main(int argc, char **argv) unsigned char tree_sha1[20]; void *tree; unsigned long size; - char type[20]; read_cache(); while (argc > 2) { @@ -245,23 +244,9 @@ int main(int argc, char **argv) if (argc != 2 || get_sha1_hex(argv[1], tree_sha1)) usage("diff-cache [-r] [-z] <tree sha1>"); - tree = read_sha1_file(tree_sha1, type, &size); + tree = read_tree_with_tree_or_commit_sha1(tree_sha1, &size, 0); if (!tree) die("bad tree object %s", argv[1]); - /* We allow people to feed us a commit object, just because we're nice */ - if (!strcmp(type, "commit")) { - /* tree sha1 is always at offset 5 ("tree ") */ - if (get_sha1_hex(tree + 5, tree_sha1)) - die("bad commit object %s", argv[1]); - free(tree); - tree = read_sha1_file(tree_sha1, type, &size); - if (!tree) - die("unable to read tree object %s", sha1_to_hex(tree_sha1)); - } - - if (strcmp(type, "tree")) - die("bad tree object %s (%s)", sha1_to_hex(tree_sha1), type); - return diff_cache(tree, size, active_cache, active_nr, ""); } |