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

Re: [PATCH] Fix rev-list when showing objects involving submodules

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Nov 12, 2007, 20:43 UTC
Message-ID
<alpine.LFD.0.9999.0711121231570.3062@woody.linux-foundation.org>
In-Reply-To
<Pine.LNX.4.64.0711122020270.4362@racer.site>
On Mon, 12 Nov 2007, Johannes Schindelin wrote:
Show 6 quoted lines
> 
> You mean something like
> 
> 		else if (S_ISREG(entry.mod) || S_ISLNK(entry.mod))
> 
> Hmm?  Sure, I have no preference there.
Maybe more along the line of something like this?

In general, I suspect we should try to start moving away from using the "S_ISLNK()" like things for internal git state. It was a mistake to just assume the numbers all were same across all systems in the first place.

So this just converts to the "object_type", and then uses a case statement.

		Linus
---
 builtin-pack-objects.c |    2 +-
 revision.c             |   11 +++++++++--
 tree-walk.h            |    7 +++++++
 3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 545ece5..4f44658 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -990,7 +990,7 @@ static void add_pbase_object(struct tree_desc *tree,
 			return;
 		if (name[cmplen] != '/') {
 			add_object_entry(entry.sha1,
-					 S_ISDIR(entry.mode) ? OBJ_TREE : OBJ_BLOB,
+					 object_type(entry.mode),
 					 fullname, 1);
 			return;
 		}
diff --git a/revision.c b/revision.c
index 931f978..c054a82 100644
--- a/revision.c
+++ b/revision.c
@@ -67,10 +67,17 @@ void mark_tree_uninteresting(struct tree *tree)
 
 	init_tree_desc(&desc, tree->buffer, tree->size);
 	while (tree_entry(&desc, &entry)) {
-		if (S_ISDIR(entry.mode))
+		switch (object_type(entry.mode)) {
+		case OBJ_TREE:
 			mark_tree_uninteresting(lookup_tree(entry.sha1));
-		else
+			break;
+		case OBJ_BLOB:
 			mark_blob_uninteresting(lookup_blob(entry.sha1));
+			break;
+		default:
+			/* Subproject commit - not in this repository */
+			break;
+		}
 	}
 
 	/*
diff --git a/tree-walk.h b/tree-walk.h
index db0fbdc..903a7b0 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -7,6 +7,13 @@ struct name_entry {
 	unsigned int mode;
 };
 
+static inline enum object_type object_type(unsigned int mode)
+{
+	return S_ISDIR(mode) ? OBJ_TREE :
+		S_ISGITLINK(mode) ? OBJ_COMMIT :
+		OBJ_BLOB;
+}
+
 struct tree_desc {
 	const void *buffer;
 	struct name_entry entry;
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 4 of 5 in “Fix rev-list when showing objects involving submodules”
  1. Fix rev-list when showing objects involving submodulesJohannes Schindelin, Nov 11, 2007
  2. Sam VilainNov 12, 2007
  3. Johannes SchindelinNov 12, 2007
  4. Linus TorvaldsNov 12, 2007
  5. Johannes SchindelinNov 12, 2007

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.