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 415959387e0642842be7aad05fa5d95ea4ed350f
1 file changed +7 -16
http-push.c
+7 -16
@@ -1277,9 +1277,7 @@ static struct object_list **add_one_object(struct object *obj, struct object_lis
1277 }
1278
1279 static struct object_list **process_blob(struct blob *blob,
1280 - struct object_list **p,
1281 - struct name_path *path,
1282 - const char *name)
1280 + struct object_list **p)
1281 {
1282 struct object *obj = &blob->object;
1283
@@ -1293,14 +1291,11 @@ static struct object_list **process_blob(struct blob *blob,
1291 }
1292
1293 static struct object_list **process_tree(struct tree *tree,
1296 - struct object_list **p,
1297 - struct name_path *path,
1298 - const char *name)
1294 + struct object_list **p)
1295 {
1296 struct object *obj = &tree->object;
1297 struct tree_desc desc;
1298 struct name_entry entry;
1303 - struct name_path me;
1299
1300 obj->flags |= LOCAL;
1301
@@ -1310,21 +1305,17 @@ static struct object_list **process_tree(struct tree *tree,
1305 die("bad tree object %s", oid_to_hex(&obj->oid));
1306
1307 obj->flags |= SEEN;
1313 - name = xstrdup(name);
1308 p = add_one_object(obj, p);
1315 - me.up = path;
1316 - me.elem = name;
1317 - me.elem_len = strlen(name);
1309
1310 init_tree_desc(&desc, tree->buffer, tree->size);
1311
1312 while (tree_entry(&desc, &entry))
1313 switch (object_type(entry.mode)) {
1314 case OBJ_TREE:
1324 - p = process_tree(lookup_tree(entry.sha1), p, &me, name);
1315 + p = process_tree(lookup_tree(entry.sha1), p);
1316 break;
1317 case OBJ_BLOB:
1327 - p = process_blob(lookup_blob(entry.sha1), p, &me, name);
1318 + p = process_blob(lookup_blob(entry.sha1), p);
1319 break;
1320 default:
1321 /* Subproject commit - not in this repository */
@@ -1343,7 +1334,7 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
1334 int count = 0;
1335
1336 while ((commit = get_revision(revs)) != NULL) {
1346 - p = process_tree(commit->tree, p, NULL, "");
1337 + p = process_tree(commit->tree, p);
1338 commit->object.flags |= LOCAL;
1339 if (!(commit->object.flags & UNINTERESTING))
1340 count += add_send_request(&commit->object, lock);
@@ -1362,11 +1353,11 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
1353 continue;
1354 }
1355 if (obj->type == OBJ_TREE) {
1365 - p = process_tree((struct tree *)obj, p, NULL, name);
1356 + p = process_tree((struct tree *)obj, p);
1357 continue;
1358 }
1359 if (obj->type == OBJ_BLOB) {
1369 - p = process_blob((struct blob *)obj, p, NULL, name);
1360 + p = process_blob((struct blob *)obj, p);
1361 continue;
1362 }
1363 die("unknown pending object %s (%s)", oid_to_hex(&obj->oid), name);