Skip to content

Commit c6bd2a1

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d770187 commit c6bd2a1

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

http-push.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,9 +1276,7 @@ static struct object_list **add_one_object(struct object *obj, struct object_lis
12761276
}
12771277

12781278
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)
12821280
{
12831281
struct object *obj = &blob->object;
12841282

@@ -1292,14 +1290,11 @@ static struct object_list **process_blob(struct blob *blob,
12921290
}
12931291

12941292
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)
12981294
{
12991295
struct object *obj = &tree->object;
13001296
struct tree_desc desc;
13011297
struct name_entry entry;
1302-
struct name_path me;
13031298

13041299
obj->flags |= LOCAL;
13051300

@@ -1309,21 +1304,17 @@ static struct object_list **process_tree(struct tree *tree,
13091304
die("bad tree object %s", sha1_to_hex(obj->sha1));
13101305

13111306
obj->flags |= SEEN;
1312-
name = xstrdup(name);
13131307
p = add_one_object(obj, p);
1314-
me.up = path;
1315-
me.elem = name;
1316-
me.elem_len = strlen(name);
13171308

13181309
init_tree_desc(&desc, tree->buffer, tree->size);
13191310

13201311
while (tree_entry(&desc, &entry))
13211312
switch (object_type(entry.mode)) {
13221313
case OBJ_TREE:
1323-
p = process_tree(lookup_tree(entry.sha1), p, &me, name);
1314+
p = process_tree(lookup_tree(entry.sha1), p);
13241315
break;
13251316
case OBJ_BLOB:
1326-
p = process_blob(lookup_blob(entry.sha1), p, &me, name);
1317+
p = process_blob(lookup_blob(entry.sha1), p);
13271318
break;
13281319
default:
13291320
/* Subproject commit - not in this repository */
@@ -1342,7 +1333,7 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
13421333
int count = 0;
13431334

13441335
while ((commit = get_revision(revs)) != NULL) {
1345-
p = process_tree(commit->tree, p, NULL, "");
1336+
p = process_tree(commit->tree, p);
13461337
commit->object.flags |= LOCAL;
13471338
if (!(commit->object.flags & UNINTERESTING))
13481339
count += add_send_request(&commit->object, lock);
@@ -1361,11 +1352,11 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
13611352
continue;
13621353
}
13631354
if (obj->type == OBJ_TREE) {
1364-
p = process_tree((struct tree *)obj, p, NULL, name);
1355+
p = process_tree((struct tree *)obj, p);
13651356
continue;
13661357
}
13671358
if (obj->type == OBJ_BLOB) {
1368-
p = process_blob((struct blob *)obj, p, NULL, name);
1359+
p = process_blob((struct blob *)obj, p);
13691360
continue;
13701361
}
13711362
die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);

0 commit comments

Comments
 (0)