From d4789c60aae4bbc97aaef5cf2e0a9aa0a4df05d2 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 25 Dec 2008 16:54:23 -0800 Subject: ls-tree: add --full-tree option The established behaviour of "git ls-tree $tree_ish" run from a subdirectory "sub/dir" in a work tree is to limit the output to the paths in the subdirectory, and strip off the leading "sub/dir" from the output, since 3c5e846 (ls-tree: major rewrite to do pathspec, 2005-11-26). This was a "usability" feature made back in the days when the line between Porcelain and plumbing was blurry, and in retrospect, it probably was misguided. The behaviour may be what the end user would expect when the command is run interactively from a subdirectory, but it also means that a scripted Porcelain that wants to use the command to list the full contents of a tree object has to do cd_to_toplevel (and save the output from "rev-parse --show-prefix" before doing so, so that it can be used as a pathspec if it wants to limit its operation to the original subdirectory in other commands). This new option makes the command operate on the full tree object, regardless of where in the work tree it is run from. It also implies the behaviour that is triggered by the existing --full-name option. Signed-off-by: Junio C Hamano --- builtin-ls-tree.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'builtin-ls-tree.c') diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c index cb61717685..c386aa5754 100644 --- a/builtin-ls-tree.c +++ b/builtin-ls-tree.c @@ -156,6 +156,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) -- cgit v1.2.3 From e1a59774077e21fc9862a968440dd23003345b4a Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Wed, 31 Dec 2008 19:00:50 +0900 Subject: Document git-ls-tree --full-tree Signed-off-by: Nanako Shiraishi Signed-off-by: Junio C Hamano --- builtin-ls-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin-ls-tree.c') diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c index c386aa5754..5b63e6eada 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) { -- cgit v1.2.3