Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Fredrik Kuivinen <freku045@student.liu.se>, git@vger.kernel.org
Subject: Re: git-ls-tree: add "-t" option to always show the tree entries
Date: Thu, 01 Dec 2005 13:15:20 -0800	[thread overview]
Message-ID: <7vlkz4friv.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: Pine.LNX.4.64.0512011022520.3099@g5.osdl.org

Linus Torvalds <torvalds@osdl.org> writes:

> NOTE! This also means that it will show all trees leading up to that tree. 

... which is logical but slightly unexpected.  Also I noticed we
lost '-d' but still accept it as an option, so...

-- >8 --
[PATCH]: ls-tree: resurrect '-d' to mean 'show trees only'

With this:

	git-ls-tree -d HEAD -- drivers/net/

shows only immediate subtrees of drivers/net.

	git-ls-tree -d -t HEAD -- drivers/net/

shows drivers, drivers/net and immediate subtrees of
drivers/net.

	git-ls-tree -d -r HEAD -- drivers/net/

shows drivers, drivers/net and all subtrees of drivers/net (but
not blobs).

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 * The practical value of this patch is dubious, and we might
   want to simply remove '-d' from the options.  But the output
   from this looks kind-of nice.  Thoughts?

diff --git a/ls-tree.c b/ls-tree.c
index a2a5eb0..07db863 100644
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -61,6 +61,8 @@ static int show_tree(unsigned char *sha1
 		}
 		type = "tree";
 	}
+	else if (ls_options & LS_TREE_ONLY)
+		return 0;
 
 	printf("%06o %s %s\t", mode, type, sha1_to_hex(sha1));
 	write_name_quoted(base, baselen, pathname, line_termination, stdout);
@@ -95,6 +97,10 @@ int main(int argc, const char **argv)
 		}
 		argc--; argv++;
 	}
+	/* -d -r should imply -t, but -d by itself should not have to. */
+	if ( (LS_TREE_ONLY|LS_RECURSIVE) ==
+	    ((LS_TREE_ONLY|LS_RECURSIVE) & ls_options))
+		ls_options |= LS_SHOW_TREES;
 
 	if (argc < 2)
 		usage(ls_tree_usage);

  reply	other threads:[~2005-12-01 21:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-30 22:57 What's new in git.git master branch Junio C Hamano
2005-12-01  8:54 ` Fredrik Kuivinen
2005-12-01  9:38   ` Junio C Hamano
2005-12-02  5:45     ` Junio C Hamano
2005-12-02  5:46     ` Junio C Hamano
2005-12-02  8:46       ` Fredrik Kuivinen
2005-12-02  8:36     ` Fredrik Kuivinen
2005-12-07 10:01       ` [PATCH 3/3] update-index: allow --index-info to add higher stages Junio C Hamano
2005-12-01 18:35   ` git-ls-tree: add "-t" option to always show the tree entries Linus Torvalds
2005-12-01 21:15     ` Junio C Hamano [this message]
2005-12-01 21:57       ` Linus Torvalds
2005-12-01 22:04         ` Junio C Hamano
2005-12-01 22:56         ` [PATCH] ls-tree: --name-only Junio C Hamano
2005-12-02 22:12         ` git-ls-tree: add "-t" option to always show the tree entries Junio C Hamano
2005-12-02 23:11           ` Linus Torvalds

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=7vlkz4friv.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=freku045@student.liu.se \
    --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