diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2017-05-06 22:10:37 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-08 15:12:58 +0900 |
commit | a9dbc179100b7119cb44eb5b4adcb47967f346a6 (patch) | |
tree | 8c09732c9f70c38bde9256781b984d13d8518043 | |
parent | sequencer: convert do_recursive_merge to struct object_id (diff) | |
download | tgif-a9dbc179100b7119cb44eb5b4adcb47967f346a6.tar.xz |
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>
-rw-r--r-- | archive.c | 4 | ||||
-rw-r--r-- | builtin/am.c | 6 | ||||
-rw-r--r-- | builtin/checkout.c | 8 | ||||
-rw-r--r-- | builtin/clone.c | 2 | ||||
-rw-r--r-- | builtin/commit.c | 2 | ||||
-rw-r--r-- | builtin/ls-files.c | 2 | ||||
-rw-r--r-- | builtin/ls-tree.c | 2 | ||||
-rw-r--r-- | builtin/merge.c | 6 | ||||
-rw-r--r-- | builtin/read-tree.c | 2 | ||||
-rw-r--r-- | builtin/reset.c | 4 | ||||
-rw-r--r-- | diff-lib.c | 2 | ||||
-rw-r--r-- | merge.c | 4 | ||||
-rw-r--r-- | sequencer.c | 2 | ||||
-rw-r--r-- | t/helper/test-match-trees.c | 4 | ||||
-rw-r--r-- | tree.c | 4 | ||||
-rw-r--r-- | tree.h | 2 |
16 files changed, 28 insertions, 28 deletions
@@ -369,7 +369,7 @@ static void parse_treeish_arg(const char **argv, archive_time = time(NULL); } - tree = parse_tree_indirect(oid.hash); + tree = parse_tree_indirect(&oid); if (tree == NULL) die("not a tree object"); @@ -383,7 +383,7 @@ static void parse_treeish_arg(const char **argv, if (err || !S_ISDIR(mode)) die("current working directory is untracked"); - tree = parse_tree_indirect(tree_oid.hash); + tree = parse_tree_indirect(&tree_oid); } ar_args->tree = tree; ar_args->commit_sha1 = commit_sha1; diff --git a/builtin/am.c b/builtin/am.c index 200d9dbed4..a2867f347b 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -2045,11 +2045,11 @@ static int clean_index(const struct object_id *head, const struct object_id *rem struct tree *head_tree, *remote_tree, *index_tree; struct object_id index; - head_tree = parse_tree_indirect(head->hash); + head_tree = parse_tree_indirect(head); if (!head_tree) return error(_("Could not parse object '%s'."), oid_to_hex(head)); - remote_tree = parse_tree_indirect(remote->hash); + remote_tree = parse_tree_indirect(remote); if (!remote_tree) return error(_("Could not parse object '%s'."), oid_to_hex(remote)); @@ -2061,7 +2061,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem if (write_cache_as_tree(index.hash, 0, NULL)) return -1; - index_tree = parse_tree_indirect(index.hash); + index_tree = parse_tree_indirect(&index); if (!index_tree) return error(_("Could not parse object '%s'."), oid_to_hex(&index)); diff --git a/builtin/checkout.c b/builtin/checkout.c index 7f1eeea943..13365fb621 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -527,10 +527,10 @@ static int merge_working_tree(const struct checkout_opts *opts, setup_standard_excludes(topts.dir); } tree = parse_tree_indirect(old->commit ? - old->commit->object.oid.hash : - EMPTY_TREE_SHA1_BIN); + &old->commit->object.oid : + &empty_tree_oid); init_tree_desc(&trees[0], tree->buffer, tree->size); - tree = parse_tree_indirect(new->commit->object.oid.hash); + tree = parse_tree_indirect(&new->commit->object.oid); init_tree_desc(&trees[1], tree->buffer, tree->size); ret = unpack_trees(2, trees, &topts); @@ -1050,7 +1050,7 @@ static int parse_branchname_arg(int argc, const char **argv, new->commit = lookup_commit_reference_gently(rev, 1); if (!new->commit) { /* not a commit */ - *source_tree = parse_tree_indirect(rev->hash); + *source_tree = parse_tree_indirect(rev); } else { parse_commit_or_die(new->commit); *source_tree = new->commit->tree; diff --git a/builtin/clone.c b/builtin/clone.c index 646f287925..da2d3c1aef 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -739,7 +739,7 @@ static int checkout(int submodule_progress) opts.src_index = &the_index; opts.dst_index = &the_index; - tree = parse_tree_indirect(oid.hash); + tree = parse_tree_indirect(&oid); parse_tree(tree); init_tree_desc(&t, tree->buffer, tree->size); if (unpack_trees(1, &t, &opts) < 0) diff --git a/builtin/commit.c b/builtin/commit.c index e69f466d5b..6adc908b32 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -313,7 +313,7 @@ static void create_base_index(const struct commit *current_head) opts.dst_index = &the_index; opts.fn = oneway_merge; - tree = parse_tree_indirect(current_head->object.oid.hash); + tree = parse_tree_indirect(¤t_head->object.oid); if (!tree) die(_("failed to unpack HEAD tree object")); parse_tree(tree); diff --git a/builtin/ls-files.c b/builtin/ls-files.c index da0ff849f0..f20edabe6d 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -421,7 +421,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix) if (get_oid(tree_name, &oid)) die("tree-ish %s not found.", tree_name); - tree = parse_tree_indirect(oid.hash); + tree = parse_tree_indirect(&oid); if (!tree) die("bad tree-ish %s", tree_name); diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index 5baac3ef2f..ee7b293b11 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -180,7 +180,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix) for (i = 0; i < pathspec.nr; i++) pathspec.items[i].nowildcard_len = pathspec.items[i].len; pathspec.has_wildcard = 0; - tree = parse_tree_indirect(oid.hash); + tree = parse_tree_indirect(&oid); if (!tree) die("not a tree object"); return !!read_tree_recursive(tree, "", 0, 0, &pathspec, show_tree, NULL); diff --git a/builtin/merge.c b/builtin/merge.c index 5ea7f7da9a..a4a098f40f 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -605,13 +605,13 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head, opts.verbose_update = 1; opts.trivial_merges_only = 1; opts.merge = 1; - trees[nr_trees] = parse_tree_indirect(common->hash); + trees[nr_trees] = parse_tree_indirect(common); if (!trees[nr_trees++]) return -1; - trees[nr_trees] = parse_tree_indirect(head->hash); + trees[nr_trees] = parse_tree_indirect(head); if (!trees[nr_trees++]) return -1; - trees[nr_trees] = parse_tree_indirect(one->hash); + trees[nr_trees] = parse_tree_indirect(one); if (!trees[nr_trees++]) return -1; opts.fn = threeway_merge; diff --git a/builtin/read-tree.c b/builtin/read-tree.c index 92eff23e45..6d45175f6a 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -29,7 +29,7 @@ static int list_tree(struct object_id *oid) if (nr_trees >= MAX_UNPACK_TREES) die("I cannot read more than %d trees", MAX_UNPACK_TREES); - tree = parse_tree_indirect(oid->hash); + tree = parse_tree_indirect(oid); if (!tree) return -1; trees[nr_trees++] = tree; diff --git a/builtin/reset.c b/builtin/reset.c index 3415dac5d5..c782739c21 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -84,7 +84,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet) return -1; if (reset_type == MIXED || reset_type == HARD) { - tree = parse_tree_indirect(oid->hash); + tree = parse_tree_indirect(oid); prime_cache_tree(&the_index, tree); } @@ -311,7 +311,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) struct tree *tree; if (get_sha1_treeish(rev, oid.hash)) die(_("Failed to resolve '%s' as a valid tree."), rev); - tree = parse_tree_indirect(oid.hash); + tree = parse_tree_indirect(&oid); if (!tree) die(_("Could not parse object '%s'."), rev); oidcpy(&oid, &tree->object.oid); diff --git a/diff-lib.c b/diff-lib.c index ee9df0f847..2982bf055a 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -486,7 +486,7 @@ static int diff_cache(struct rev_info *revs, struct tree_desc t; struct unpack_trees_options opts; - tree = parse_tree_indirect(tree_oid->hash); + tree = parse_tree_indirect(tree_oid); if (!tree) return error("bad tree object %s", tree_name ? tree_name : oid_to_hex(tree_oid)); @@ -79,10 +79,10 @@ int checkout_fast_forward(const struct object_id *head, opts.fn = twoway_merge; setup_unpack_trees_porcelain(&opts, "merge"); - trees[nr_trees] = parse_tree_indirect(head->hash); + trees[nr_trees] = parse_tree_indirect(head); if (!trees[nr_trees++]) return -1; - trees[nr_trees] = parse_tree_indirect(remote->hash); + trees[nr_trees] = parse_tree_indirect(remote); if (!trees[nr_trees++]) return -1; for (i = 0; i < nr_trees; i++) { diff --git a/sequencer.c b/sequencer.c index adcc0a953f..5817d8a23d 100644 --- a/sequencer.c +++ b/sequencer.c @@ -446,7 +446,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next, if (is_rebase_i(opts)) o.buffer_output = 2; - head_tree = parse_tree_indirect(head->hash); + head_tree = parse_tree_indirect(head); next_tree = next ? next->tree : empty_tree(); base_tree = base ? base->tree : empty_tree(); diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c index e939502863..356d8edef1 100644 --- a/t/helper/test-match-trees.c +++ b/t/helper/test-match-trees.c @@ -12,10 +12,10 @@ int cmd_main(int ac, const char **av) die("cannot parse %s as an object name", av[1]); if (get_oid(av[2], &hash2)) die("cannot parse %s as an object name", av[2]); - one = parse_tree_indirect(hash1.hash); + one = parse_tree_indirect(&hash1); if (!one) die("not a tree-ish %s", av[1]); - two = parse_tree_indirect(hash2.hash); + two = parse_tree_indirect(&hash2); if (!two) die("not a tree-ish %s", av[2]); @@ -232,9 +232,9 @@ void free_tree_buffer(struct tree *tree) tree->object.parsed = 0; } -struct tree *parse_tree_indirect(const unsigned char *sha1) +struct tree *parse_tree_indirect(const struct object_id *oid) { - struct object *obj = parse_object(sha1); + struct object *obj = parse_object(oid->hash); do { if (!obj) return NULL; @@ -24,7 +24,7 @@ static inline int parse_tree(struct tree *tree) void free_tree_buffer(struct tree *tree); /* Parses and returns the tree in the given ent, chasing tags and commits. */ -struct tree *parse_tree_indirect(const unsigned char *sha1); +struct tree *parse_tree_indirect(const struct object_id *oid); #define READ_TREE_RECURSIVE 1 typedef int (*read_tree_fn_t)(const unsigned char *, struct strbuf *, const char *, unsigned int, int, void *); |