Skip to content

Commit a9dbc17

Browse files
bk2204gitster
authored andcommitted
tree: convert parse_tree_indirect to struct object_id
Convert parse_tree_indirect to take a pointer to struct object_id. Update all the callers. This transformation was achieved using the following semantic patch and manual updates to the declaration and definition. Update builtin/checkout.c manually as well, since it uses a ternary expression not handled by the semantic patch. @@ expression E1; @@ - parse_tree_indirect(E1.hash) + parse_tree_indirect(&E1) @@ expression E1; @@ - parse_tree_indirect(E1->hash) + parse_tree_indirect(E1) Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 48be4c6 commit a9dbc17

File tree

16 files changed

+28
-28
lines changed

16 files changed

+28
-28
lines changed

archive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static void parse_treeish_arg(const char **argv,
369369
archive_time = time(NULL);
370370
}
371371

372-
tree = parse_tree_indirect(oid.hash);
372+
tree = parse_tree_indirect(&oid);
373373
if (tree == NULL)
374374
die("not a tree object");
375375

@@ -383,7 +383,7 @@ static void parse_treeish_arg(const char **argv,
383383
if (err || !S_ISDIR(mode))
384384
die("current working directory is untracked");
385385

386-
tree = parse_tree_indirect(tree_oid.hash);
386+
tree = parse_tree_indirect(&tree_oid);
387387
}
388388
ar_args->tree = tree;
389389
ar_args->commit_sha1 = commit_sha1;

builtin/am.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,11 +2045,11 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
20452045
struct tree *head_tree, *remote_tree, *index_tree;
20462046
struct object_id index;
20472047

2048-
head_tree = parse_tree_indirect(head->hash);
2048+
head_tree = parse_tree_indirect(head);
20492049
if (!head_tree)
20502050
return error(_("Could not parse object '%s'."), oid_to_hex(head));
20512051

2052-
remote_tree = parse_tree_indirect(remote->hash);
2052+
remote_tree = parse_tree_indirect(remote);
20532053
if (!remote_tree)
20542054
return error(_("Could not parse object '%s'."), oid_to_hex(remote));
20552055

@@ -2061,7 +2061,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
20612061
if (write_cache_as_tree(index.hash, 0, NULL))
20622062
return -1;
20632063

2064-
index_tree = parse_tree_indirect(index.hash);
2064+
index_tree = parse_tree_indirect(&index);
20652065
if (!index_tree)
20662066
return error(_("Could not parse object '%s'."), oid_to_hex(&index));
20672067

builtin/checkout.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
527527
setup_standard_excludes(topts.dir);
528528
}
529529
tree = parse_tree_indirect(old->commit ?
530-
old->commit->object.oid.hash :
531-
EMPTY_TREE_SHA1_BIN);
530+
&old->commit->object.oid :
531+
&empty_tree_oid);
532532
init_tree_desc(&trees[0], tree->buffer, tree->size);
533-
tree = parse_tree_indirect(new->commit->object.oid.hash);
533+
tree = parse_tree_indirect(&new->commit->object.oid);
534534
init_tree_desc(&trees[1], tree->buffer, tree->size);
535535

536536
ret = unpack_trees(2, trees, &topts);
@@ -1050,7 +1050,7 @@ static int parse_branchname_arg(int argc, const char **argv,
10501050
new->commit = lookup_commit_reference_gently(rev, 1);
10511051
if (!new->commit) {
10521052
/* not a commit */
1053-
*source_tree = parse_tree_indirect(rev->hash);
1053+
*source_tree = parse_tree_indirect(rev);
10541054
} else {
10551055
parse_commit_or_die(new->commit);
10561056
*source_tree = new->commit->tree;

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ static int checkout(int submodule_progress)
739739
opts.src_index = &the_index;
740740
opts.dst_index = &the_index;
741741

742-
tree = parse_tree_indirect(oid.hash);
742+
tree = parse_tree_indirect(&oid);
743743
parse_tree(tree);
744744
init_tree_desc(&t, tree->buffer, tree->size);
745745
if (unpack_trees(1, &t, &opts) < 0)

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static void create_base_index(const struct commit *current_head)
313313
opts.dst_index = &the_index;
314314

315315
opts.fn = oneway_merge;
316-
tree = parse_tree_indirect(current_head->object.oid.hash);
316+
tree = parse_tree_indirect(&current_head->object.oid);
317317
if (!tree)
318318
die(_("failed to unpack HEAD tree object"));
319319
parse_tree(tree);

builtin/ls-files.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
421421

422422
if (get_oid(tree_name, &oid))
423423
die("tree-ish %s not found.", tree_name);
424-
tree = parse_tree_indirect(oid.hash);
424+
tree = parse_tree_indirect(&oid);
425425
if (!tree)
426426
die("bad tree-ish %s", tree_name);
427427

builtin/ls-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
180180
for (i = 0; i < pathspec.nr; i++)
181181
pathspec.items[i].nowildcard_len = pathspec.items[i].len;
182182
pathspec.has_wildcard = 0;
183-
tree = parse_tree_indirect(oid.hash);
183+
tree = parse_tree_indirect(&oid);
184184
if (!tree)
185185
die("not a tree object");
186186
return !!read_tree_recursive(tree, "", 0, 0, &pathspec, show_tree, NULL);

builtin/merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,13 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head,
605605
opts.verbose_update = 1;
606606
opts.trivial_merges_only = 1;
607607
opts.merge = 1;
608-
trees[nr_trees] = parse_tree_indirect(common->hash);
608+
trees[nr_trees] = parse_tree_indirect(common);
609609
if (!trees[nr_trees++])
610610
return -1;
611-
trees[nr_trees] = parse_tree_indirect(head->hash);
611+
trees[nr_trees] = parse_tree_indirect(head);
612612
if (!trees[nr_trees++])
613613
return -1;
614-
trees[nr_trees] = parse_tree_indirect(one->hash);
614+
trees[nr_trees] = parse_tree_indirect(one);
615615
if (!trees[nr_trees++])
616616
return -1;
617617
opts.fn = threeway_merge;

builtin/read-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static int list_tree(struct object_id *oid)
2929

3030
if (nr_trees >= MAX_UNPACK_TREES)
3131
die("I cannot read more than %d trees", MAX_UNPACK_TREES);
32-
tree = parse_tree_indirect(oid->hash);
32+
tree = parse_tree_indirect(oid);
3333
if (!tree)
3434
return -1;
3535
trees[nr_trees++] = tree;

builtin/reset.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)
8484
return -1;
8585

8686
if (reset_type == MIXED || reset_type == HARD) {
87-
tree = parse_tree_indirect(oid->hash);
87+
tree = parse_tree_indirect(oid);
8888
prime_cache_tree(&the_index, tree);
8989
}
9090

@@ -311,7 +311,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
311311
struct tree *tree;
312312
if (get_sha1_treeish(rev, oid.hash))
313313
die(_("Failed to resolve '%s' as a valid tree."), rev);
314-
tree = parse_tree_indirect(oid.hash);
314+
tree = parse_tree_indirect(&oid);
315315
if (!tree)
316316
die(_("Could not parse object '%s'."), rev);
317317
oidcpy(&oid, &tree->object.oid);

0 commit comments

Comments
 (0)