Skip to content

Commit 740ee05

Browse files
bk2204gitster
authored andcommitted
Convert lookup_tree to struct object_id
Convert the lookup_tree function to take a pointer to struct object_id. The commit was created with manual changes to tree.c, tree.h, and object.c, plus the following semantic patch: @@ @@ - lookup_tree(EMPTY_TREE_SHA1_BIN) + lookup_tree(&empty_tree_oid) @@ expression E1; @@ - lookup_tree(E1.hash) + lookup_tree(&E1) @@ expression E1; @@ - lookup_tree(E1->hash) + lookup_tree(E1) Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 49a09e7 commit 740ee05

File tree

18 files changed

+25
-25
lines changed

18 files changed

+25
-25
lines changed

builtin/am.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,9 +1453,9 @@ static void write_index_patch(const struct am_state *state)
14531453
FILE *fp;
14541454

14551455
if (!get_sha1_tree("HEAD", head.hash))
1456-
tree = lookup_tree(head.hash);
1456+
tree = lookup_tree(&head);
14571457
else
1458-
tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
1458+
tree = lookup_tree(&empty_tree_oid);
14591459

14601460
fp = xfopen(am_path(state, "patch"), "w");
14611461
init_revisions(&rev_info, NULL);

builtin/diff-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
4444
struct tree *tree2;
4545
if (!isspace(*p++) || parse_oid_hex(p, &oid, &p) || *p)
4646
return error("Need exactly two trees, separated by a space");
47-
tree2 = lookup_tree(oid.hash);
47+
tree2 = lookup_tree(&oid);
4848
if (!tree2 || parse_tree(tree2))
4949
return -1;
5050
printf("%s %s\n", oid_to_hex(&tree1->object.oid),

builtin/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
381381
add_head_to_pending(&rev);
382382
if (!rev.pending.nr) {
383383
struct tree *tree;
384-
tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
384+
tree = lookup_tree(&empty_tree_oid);
385385
add_pending_object(&rev, &tree->object, "HEAD");
386386
}
387387
break;

builtin/reflog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int tree_is_complete(const struct object_id *oid)
6262
int complete;
6363
struct tree *tree;
6464

65-
tree = lookup_tree(oid->hash);
65+
tree = lookup_tree(oid);
6666
if (!tree)
6767
return 0;
6868
if (tree->object.flags & SEEN)

cache-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
672672
cnt++;
673673
else {
674674
struct cache_tree_sub *sub;
675-
struct tree *subtree = lookup_tree(entry.oid->hash);
675+
struct tree *subtree = lookup_tree(entry.oid);
676676
if (!subtree->object.parsed)
677677
parse_tree(subtree);
678678
sub = cache_tree_sub(it, entry.path);

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
331331
if (get_sha1_hex(bufptr + 5, parent.hash) < 0)
332332
return error("bad tree pointer in commit %s",
333333
oid_to_hex(&item->object.oid));
334-
item->tree = lookup_tree(parent.hash);
334+
item->tree = lookup_tree(&parent);
335335
bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
336336
pptr = &item->parents;
337337

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
358358
continue;
359359

360360
if (S_ISDIR(entry.mode)) {
361-
obj = &lookup_tree(entry.oid->hash)->object;
361+
obj = &lookup_tree(entry.oid)->object;
362362
if (name)
363363
put_object_name(options, obj, "%s%s/", name,
364364
entry.path);

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ static struct object_list **process_tree(struct tree *tree,
13121312
while (tree_entry(&desc, &entry))
13131313
switch (object_type(entry.mode)) {
13141314
case OBJ_TREE:
1315-
p = process_tree(lookup_tree(entry.oid->hash), p);
1315+
p = process_tree(lookup_tree(entry.oid), p);
13161316
break;
13171317
case OBJ_BLOB:
13181318
p = process_blob(lookup_blob(entry.oid), p);

list-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static void process_tree(struct rev_info *revs,
110110

111111
if (S_ISDIR(entry.mode))
112112
process_tree(revs,
113-
lookup_tree(entry.oid->hash),
113+
lookup_tree(entry.oid),
114114
show, base, entry.path,
115115
cb_data);
116116
else if (S_ISGITLINK(entry.mode))

merge-recursive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two,
6767
}
6868
if (!oidcmp(&two->object.oid, &shifted))
6969
return two;
70-
return lookup_tree(shifted.hash);
70+
return lookup_tree(&shifted);
7171
}
7272

7373
static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
@@ -304,7 +304,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)
304304
return NULL;
305305
}
306306

307-
result = lookup_tree(active_cache_tree->oid.hash);
307+
result = lookup_tree(&active_cache_tree->oid);
308308

309309
return result;
310310
}
@@ -2042,7 +2042,7 @@ int merge_recursive(struct merge_options *o,
20422042
/* if there is no common ancestor, use an empty tree */
20432043
struct tree *tree;
20442044

2045-
tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
2045+
tree = lookup_tree(&empty_tree_oid);
20462046
merged_common_ancestors = make_virtual_commit(tree, "ancestor");
20472047
}
20482048

0 commit comments

Comments
 (0)