Skip to contentSkip to conversation

ls-tree: show size of trees with -l

PATCH In review Nguyễn Thái Ngọc Duy 2 participants 2 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ls-tree: show size of trees with -l

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.

---
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(-)
Documentation/git-ls-tree.txt +1 -1
index 1f89d36..9e02905 100644
@@ -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.
builtin/ls-tree.c +1 -1
index dc86b0d..7df87ec 100644
@@ -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");
Signature · 1 line
1.7.1.rc1.69.g24c2f7
#1 lore raw
Quoted 3 lines · Nguyễn Thái Ngọc Duy

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 wrote that?

Quoted 6 lines

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.

Quoted 6 lines

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.

---

Actually "git ls-tree -l <tree-ish>" doesn't show size of tree objects because packv4 was to be ready soon, and in packv4 trees would be stored decomposed, so getting size of tree object (e.g. using git-cat-file) is would be costly because git would have to re-generate tree object just to get its size (if it is in packfile).

But we don't have packv4 yet, even though it is 3 years since a5bbda8. It looks like packv4 development moves with the speed of Perl 6 development. But if Rakudo * (Perl 6 implementation) could have get released (even if it is developers release), then there is hope for packv4 yet... I hope...

Signature · 2 lines
Jakub Narebski
Poland