The option '--submodules', which implies '-r', activates the traversal of all submodules for which the linked commit is reachable. Signed-off-by: Lars Hjemli <hjemli@xxxxxxxxx> --- builtin-ls-tree.c | 23 ++++++++--------------- 1 files changed, 8 insertions(+), 15 deletions(-) diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c index cb61717..8a1db54 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[=<n>]] <tree-ish> [path...]"; + "git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] [--submodules] <tree-ish> [path...]"; static int show_recursive(const char *base, int baselen, const char *pathname) { @@ -63,20 +63,8 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen, unsigned long size; if (S_ISGITLINK(mode)) { - /* - * Maybe we want to have some recursive version here? - * - * 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_recursive(base, baselen, pathname)) + retval = READ_TREE_RECURSIVE; type = commit_type; } else if (S_ISDIR(mode)) { if (show_recursive(base, baselen, pathname)) { @@ -168,6 +156,11 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix) abbrev = DEFAULT_ABBREV; break; } + if (!strcmp(argv[1]+2, "submodules")) { + ls_options |= LS_RECURSIVE; + traverse_gitlinks = 1; + break; + } /* otherwise fallthru */ default: usage(ls_tree_usage); -- 1.6.1.81.g1df1.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html