git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: Jakub Narebski <jnareb@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] ls-tree: show size of trees with -l
Date: Sat, 14 Aug 2010 03:20:23 +0700	[thread overview]
Message-ID: <1281730823-10797-1-git-send-email-pclouds@gmail.com> (raw)

In commit a5bbda8 (Add an option to git-ls-tree to display also the
size of blob), Jakub said that size of non-blob entries had no
meaning therefore dashes were printed instead.

I would say tree size, along with blob size, helps estimate bandwidth
needed to transfer a single commit, for example. Of course it's not
completely accurate as all objects will be compressed. But it gives a
rough figure to compare.

Pack v4 has not come yet (and it's been three years, I truely hope it
will come next year). When it comes, I will gladly send a revert patch
of this one if it proves too expensive to compute tree size.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 By the way, dashes will still be printed for subprojects, I guess.

 Documentation/git-ls-tree.txt |    2 +-
 builtin/ls-tree.c             |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt
index 1f89d36..9e02905 100644
--- a/Documentation/git-ls-tree.txt
+++ b/Documentation/git-ls-tree.txt
@@ -50,7 +50,7 @@ OPTIONS
 
 -l::
 --long::
-	Show object size of blob (file) entries.
+	Show object size of entries.
 
 -z::
 	\0 line termination on output.
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index dc86b0d..7df87ec 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -93,7 +93,7 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
 	if (!(ls_options & LS_NAME_ONLY)) {
 		if (ls_options & LS_SHOW_SIZE) {
 			char size_text[24];
-			if (!strcmp(type, blob_type)) {
+			if (!strcmp(type, blob_type) || !strcmp(type, tree_type)) {
 				unsigned long size;
 				if (sha1_object_info(sha1, &size) == OBJ_BAD)
 					strcpy(size_text, "BAD");
-- 
1.7.1.rc1.69.g24c2f7

             reply	other threads:[~2010-08-14  9:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-13 20:20 Nguyễn Thái Ngọc Duy [this message]
2010-08-14 14:40 ` [PATCH] ls-tree: show size of trees with -l Jakub Narebski

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1281730823-10797-1-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).