From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: (rework) [PATCH 3/5] Accept commit in some places when tree is needed.
Date: Wed, 20 Apr 2005 17:22:30 -0700 [thread overview]
Message-ID: <7v1x95htbt.fsf@assigned-by-dhcp.cox.net> (raw)
Updates diff-tree.c to use read_tree_with_tree_or_commit_sha1()
function. The command can take either tree or commit IDs with this patch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff-tree.c | 25 ++++---------------------
1 files changed, 4 insertions(+), 21 deletions(-)
diff-tree.c: 65bb9d66c5610b2ede11f03a9120da48c59629f8
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -164,14 +164,13 @@ static int diff_tree_sha1(const unsigned
{
void *tree1, *tree2;
unsigned long size1, size2;
- char type[20];
int retval;
- tree1 = read_sha1_file(old, type, &size1);
- if (!tree1 || strcmp(type, "tree"))
+ tree1 = read_tree_with_tree_or_commit_sha1(old, &size1, 0);
+ if (!tree1)
die("unable to read source tree (%s)", sha1_to_hex(old));
- tree2 = read_sha1_file(new, type, &size2);
- if (!tree2 || strcmp(type, "tree"))
+ tree2 = read_tree_with_tree_or_commit_sha1(new, &size2, 0);
+ if (!tree2)
die("unable to read destination tree (%s)", sha1_to_hex(new));
retval = diff_tree(tree1, size1, tree2, size2, base);
free(tree1);
@@ -179,20 +178,6 @@ static int diff_tree_sha1(const unsigned
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];
@@ -214,7 +199,5 @@ 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, "");
}
reply other threads:[~2005-04-21 0:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v1x95htbt.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox