X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-ls-tree.c;h=22008dfa8fb94d971b6fb1bd7342ede02a8d3fd0;hb=e8dbd76d57806fd1305612d56d56a4cc7665c599;hp=cb61717685b09a2e409440206e27fce68831e04d;hpb=a1eb73d917e15cd97314e0a39cbe857329339a96;p=git.git diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c index cb6171768..22008dfa8 100644 --- a/builtin-ls-tree.c +++ b/builtin-ls-tree.c @@ -23,7 +23,7 @@ static int chomp_prefix; static const char *ls_tree_prefix; static const char ls_tree_usage[] = - "git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=]] [path...]"; + "git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=]] [path...]"; static int show_recursive(const char *base, int baselen, const char *pathname) { @@ -60,7 +60,6 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen, { int retval = 0; const char *type = blob_type; - unsigned long size; if (S_ISGITLINK(mode)) { /* @@ -68,13 +67,8 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen, * * Something similar to this incomplete example: * - if (show_subprojects(base, baselen, pathname)) { - struct child_process ls_tree; - - ls_tree.dir = base; - ls_tree.argv = ls-tree; - start_command(&ls_tree); - } + if (show_subprojects(base, baselen, pathname)) + retval = READ_TREE_RECURSIVE; * */ type = commit_type; @@ -95,17 +89,20 @@ 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)) { - sha1_object_info(sha1, &size); - printf("%06o %s %s %7lu\t", mode, type, - abbrev ? find_unique_abbrev(sha1, abbrev) - : sha1_to_hex(sha1), - size); + unsigned long size; + if (sha1_object_info(sha1, &size) == OBJ_BAD) + strcpy(size_text, "BAD"); + else + snprintf(size_text, sizeof(size_text), + "%lu", size); } else - printf("%06o %s %s %7c\t", mode, type, - abbrev ? find_unique_abbrev(sha1, abbrev) - : sha1_to_hex(sha1), - '-'); + strcpy(size_text, "-"); + printf("%06o %s %s %7s\t", mode, type, + abbrev ? find_unique_abbrev(sha1, abbrev) + : sha1_to_hex(sha1), + size_text); } else printf("%06o %s %s\t", mode, type, abbrev ? find_unique_abbrev(sha1, abbrev) @@ -156,6 +153,11 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix) chomp_prefix = 0; break; } + if (!strcmp(argv[1]+2, "full-tree")) { + ls_tree_prefix = prefix = NULL; + chomp_prefix = 0; + break; + } if (!prefixcmp(argv[1]+2, "abbrev=")) { abbrev = strtoul(argv[1]+9, NULL, 10); if (abbrev && abbrev < MINIMUM_ABBREV)