aboutsummaryrefslogtreecommitdiffstats
path: root/diff-tree.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-19 21:39:28 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-19 21:39:28 -0700
commitabdb007d1f0ee1579c3719fc4fadbe4755163d74 (patch)
treed73f1dd6dcd5bf2a5526593e5cc8202929549cf0 /diff-tree.c
parente74f8f6aa7807d479d78bfc680a18a9a5198b172 (diff)
downloadgit-abdb007d1f0ee1579c3719fc4fadbe4755163d74.tar.gz
Make "diff-tree" take commit objects too, like "diff-cache" does.
Sometimes it's just easier to not have to look up the "commit"->"tree" translation by hand first. It's trivial to do inside diff-tree, and it's just being polite.
Diffstat (limited to 'diff-tree.c')
-rw-r--r--diff-tree.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/diff-tree.c b/diff-tree.c
index 826812af83..65bb9d66c5 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -179,6 +179,20 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co
return retval;
}
+static void commit_to_tree(unsigned char *sha1)
+{
+ void *buf;
+ char type[20];
+ unsigned long size;
+
+ buf = read_sha1_file(sha1, type, &size);
+ if (buf) {
+ if (!strcmp(type, "commit"))
+ get_sha1_hex(buf+5, sha1);
+ free(buf);
+ }
+}
+
int main(int argc, char **argv)
{
unsigned char old[20], new[20];
@@ -200,5 +214,7 @@ int main(int argc, char **argv)
if (argc != 3 || get_sha1_hex(argv[1], old) || get_sha1_hex(argv[2], new))
usage("diff-tree <tree sha1> <tree sha1>");
+ commit_to_tree(old);
+ commit_to_tree(new);
return diff_tree_sha1(old, new, "");
}