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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, 12 Nov 2007, Johannes Schindelin wrote:
> 
> 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;
-
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux