http-push: stop using name_path

The graph traversal code here passes along a name_path to build up the pathname at which we find each blob. But we never actually do anything with the resulting names, making it a waste of code and memory. This usage came in aa1dbc9 (Update http-push functionality, 2006-03-07), and originally the result was passed to "add_object" (which stored it, but didn't really use it, either). But we stopped using that function in 1f1e895 (Add "named object array" concept, 2006-06-19) in favor of storing just the objects themselves. Moreover, the generation of the name in process_tree() is buggy. It sticks "name" onto the end of the name_path linked list, and then passes it down again as it recurses (instead of "entry.path"). So it's a good thing this was unused, as the resulting path for "a/b/c/d" would end up as "a/a/a/a". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 11, 2016 at 17:23 UTC c6bd2a1decc252d823104f9849c87ec8484b18ea
1 file changed +7 -16
http-push.c
+7 -16
@@ -1276,9 +1276,7 @@ static struct object_list **add_one_object(struct object *obj, struct object_lis
1276 }
1277
1278 static struct object_list **process_blob(struct blob *blob,
1279 - struct object_list **p,
1280 - struct name_path *path,
1281 - const char *name)
1279 + struct object_list **p)
1280 {
1281 struct object *obj = &blob->object;
1282
@@ -1292,14 +1290,11 @@ static struct object_list **process_blob(struct blob *blob,
1290 }
1291
1292 static struct object_list **process_tree(struct tree *tree,
1295 - struct object_list **p,
1296 - struct name_path *path,
1297 - const char *name)
1293 + struct object_list **p)
1294 {
1295 struct object *obj = &tree->object;
1296 struct tree_desc desc;
1297 struct name_entry entry;
1302 - struct name_path me;
1298
1299 obj->flags |= LOCAL;
1300
@@ -1309,21 +1304,17 @@ static struct object_list **process_tree(struct tree *tree,
1304 die("bad tree object %s", sha1_to_hex(obj->sha1));
1305
1306 obj->flags |= SEEN;
1312 - name = xstrdup(name);
1307 p = add_one_object(obj, p);
1314 - me.up = path;
1315 - me.elem = name;
1316 - me.elem_len = strlen(name);
1308
1309 init_tree_desc(&desc, tree->buffer, tree->size);
1310
1311 while (tree_entry(&desc, &entry))
1312 switch (object_type(entry.mode)) {
1313 case OBJ_TREE:
1323 - p = process_tree(lookup_tree(entry.sha1), p, &me, name);
1314 + p = process_tree(lookup_tree(entry.sha1), p);
1315 break;
1316 case OBJ_BLOB:
1326 - p = process_blob(lookup_blob(entry.sha1), p, &me, name);
1317 + p = process_blob(lookup_blob(entry.sha1), p);
1318 break;
1319 default:
1320 /* Subproject commit - not in this repository */
@@ -1342,7 +1333,7 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
1333 int count = 0;
1334
1335 while ((commit = get_revision(revs)) != NULL) {
1345 - p = process_tree(commit->tree, p, NULL, "");
1336 + p = process_tree(commit->tree, p);
1337 commit->object.flags |= LOCAL;
1338 if (!(commit->object.flags & UNINTERESTING))
1339 count += add_send_request(&commit->object, lock);
@@ -1361,11 +1352,11 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
1352 continue;
1353 }
1354 if (obj->type == OBJ_TREE) {
1364 - p = process_tree((struct tree *)obj, p, NULL, name);
1355 + p = process_tree((struct tree *)obj, p);
1356 continue;
1357 }
1358 if (obj->type == OBJ_BLOB) {
1368 - p = process_blob((struct blob *)obj, p, NULL, name);
1359 + p = process_blob((struct blob *)obj, p);
1360 continue;
1361 }
1362 die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);