All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] get_tree_entry: map blank requested entry to tree root
Date: Tue, 9 Jan 2007 11:11:47 -0500	[thread overview]
Message-ID: <20070109161147.GA9313@coredump.intra.peff.net> (raw)

This means that
  git show HEAD:
will now return HEAD^{tree}, which is logically consistent with
  git show HEAD:Documentation

Signed-off-by: Jeff King <peff@peff.net>
---
 tree-walk.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tree-walk.c b/tree-walk.c
index 22f4550..70f8999 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -199,10 +199,17 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch
 	int retval;
 	void *tree;
 	struct tree_desc t;
+	unsigned char root[20];
 
-	tree = read_object_with_reference(tree_sha1, tree_type, &t.size, NULL);
+	tree = read_object_with_reference(tree_sha1, tree_type, &t.size, root);
 	if (!tree)
 		return -1;
+
+	if (name[0] == '\0') {
+		hashcpy(sha1, root);
+		return 0;
+	}
+
 	t.buf = tree;
 	retval = find_tree_entry(&t, name, sha1, mode);
 	free(tree);
-- 
1.4.4.4.g9612-dirty

             reply	other threads:[~2007-01-09 16:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-09 16:11 Jeff King [this message]
2007-01-09 16:15 ` [PATCH] get_tree_entry: map blank requested entry to tree root Johannes Schindelin
2007-01-09 23:48 ` Junio C Hamano
2007-01-10  0:46   ` Jeff King
2007-01-10  0:57     ` Junio C Hamano
2007-01-10  0:57       ` Jeff King
2007-01-10  1:04         ` Junio C Hamano

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=20070109161147.GA9313@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.