[PATCH 2/3, v2] http-push: do not get confused by submodules

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>, <gitster@...>, <mh@...>
Date: Thursday, February 14, 2008 - 7:32 pm

When encountering submodules in a tree, http-push should not try sending
the respective object.  Instead, it should ignore it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	I just remembered that Linus did something similar, but more 
	elegant, in 481f0ee60eef2c34b891e5d04b7e6e5a955eedf4.  This
	patch imitates that commit.

 http-push.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/http-push.c b/http-push.c
index 7a6c669..4d200bc 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1634,12 +1634,19 @@ static struct object_list **process_tree(struct tree *tree,
 
 	init_tree_desc(&desc, tree->buffer, tree->size);
 
-	while (tree_entry(&desc, &entry)) {
-		if (S_ISDIR(entry.mode))
+	while (tree_entry(&desc, &entry))
+		switch (object_type(entry.mode)) {
+		case OBJ_TREE:
 			p = process_tree(lookup_tree(entry.sha1), p, &me, name);
-		else
+			break;
+		case OBJ_BLOB:
 			p = process_blob(lookup_blob(entry.sha1), p, &me, name);
-	}
+			break;
+		default:
+			/* Subproject commit - not in this repository */
+			break;
+		}
+
 	free(tree->buffer);
 	tree->buffer = NULL;
 	return p;
-- 
1.5.4.1.1353.g0d5dd

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/3] http-push fixes, Johannes Schindelin, (Thu Feb 14, 7:25 pm)
[PATCH 3/3] http-push: avoid a needless goto, Johannes Schindelin, (Thu Feb 14, 7:26 pm)
[PATCH 2/3] http-push: do not get confused by submodules, Johannes Schindelin, (Thu Feb 14, 7:25 pm)
[PATCH 2/3, v2] http-push: do not get confused by submodules, Johannes Schindelin, (Thu Feb 14, 7:32 pm)
[PATCH 1/3] http-push: avoid invalid memory accesses, Johannes Schindelin, (Thu Feb 14, 7:25 pm)
Re: [PATCH 1/3] http-push: avoid invalid memory accesses, Junio C Hamano, (Sat Feb 16, 3:23 am)
Re: [PATCH 1/3] http-push: avoid invalid memory accesses, Johannes Schindelin, (Sat Feb 16, 8:12 am)