On Wed, Dec 19, 2007 at 01:40:27PM +0000, Johannes Schindelin wrote: > When you are in a deeply-nested directory structure, and just want > to reference a blob in a past revision, it can be pretty slow to > type out "HEAD~29:/bla/blub/.../that-file". > > This patch makes "HEAD~29:./that-file" substitute the current prefix > for "./". If there is not working directory, the prefix is empty. > > Note that this patch does not handle "../", and neither do I plan to. I think this is definitely the right approach. Here's a (possibly insane) alternative. Revert the change in get_sha1_with_mode and detect "./" in get_tree_entry: diff --git a/tree-walk.c b/tree-walk.c index 8d4b673..fc54354 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -191,6 +191,7 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch unsigned long size; struct tree_desc t; unsigned char root[20]; + const char *prefix; tree = read_object_with_reference(tree_sha1, tree_type, &size, root); if (!tree) @@ -202,7 +203,11 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch } init_tree_desc(&t, tree, size); - retval = find_tree_entry(&t, name, sha1, mode); + if (!prefixcmp(name, "./") && (prefix = get_current_prefix())) + retval = find_tree_entry(&t, mkpath("%s%s", prefix, name + 2), + sha1, mode); + else + retval = find_tree_entry(&t, name, sha1, mode); free(tree); return retval; } This means that the directory '.' becomes a token replacement for "my current path" in tree paths. So if you are in "foo/bar", and you are looking at a distance commit where the same content was in "baz/foo/bar", you can do: git show distant:baz/./file This is probably insane because: - this is a fairly unlikely use case - get_tree_entry gets called in a lot of places, and I have no idea if there will be some crazy fallouts. So it is probably not worth pursuing, but maybe somebody else can think of a good use. -Peff - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html