Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: (rework) [PATCH 2/5] Accept commit in some places when tree is needed.
Date: Wed, 20 Apr 2005 17:21:42 -0700	[thread overview]
Message-ID: <7v64yhhtd5.fsf@assigned-by-dhcp.cox.net> (raw)

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>
---

 diff-cache.c |   17 +----------------
 1 files changed, 1 insertion(+), 16 deletions(-)

diff-cache.c: fcbc4900d32f4ca24f67bb8f0fe344c6c5642ac9
--- 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, "");
 }



                 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=7v64yhhtd5.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