git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH 3/3] builtin-ls-tree: enable traversal of submodules

From
LHLars Hjemli <hjemli@gmail.com>
Date
Jan 11, 2009, 23:45 UTC
Message-ID
<1231717555-10559-4-git-send-email-hjemli@gmail.com>
In-Reply-To
<1231717555-10559-3-git-send-email-hjemli@gmail.com>

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@gmail.com>
---
 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
Previous: Lars HjemliNext: Junio C Hamano
Message 4 of 9 in “Enable in-process submodule traversal”
  1. 0/3 Enable in-process submodule traversalLars Hjemli, Jan 11, 2009
  2. 1/3 tree.c: add support for traversal of submodulesLars Hjemli, Jan 11, 2009
  3. 2/3 archive.c: enable traversal of submodulesLars Hjemli, Jan 11, 2009
  4. 3/3 builtin-ls-tree: enable traversal of submodulesLars Hjemli, Jan 11, 2009
  5. Junio C HamanoJan 12, 2009
  6. Lars HjemliJan 12, 2009
  7. Junio C HamanoJan 12, 2009
  8. Lars HjemliJan 12, 2009
  9. Junio C HamanoJan 12, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.