diff-tree: convert diff_tree_sha1 to struct object_id
authorBrandon Williams <bmwill@google.com>
Tue, 30 May 2017 17:31:03 +0000 (10:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Jun 2017 02:23:58 +0000 (11:23 +0900)
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 files changed:
builtin/blame.c
builtin/diff-tree.c
builtin/diff.c
builtin/fast-export.c
builtin/log.c
builtin/merge.c
combine-diff.c
diff.h
line-log.c
log-tree.c
merge-recursive.c
notes-merge.c
patch-ids.c
revision.c
sequencer.c
tree-diff.c
index 5ad435380f2055055744881465874001e7d037c9..7645aa991daadcf5beb87048cc64e49849f1ee10 100644 (file)
@@ -565,9 +565,9 @@ static struct origin *find_origin(struct scoreboard *sb,
        if (is_null_oid(&origin->commit->object.oid))
                do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
-               diff_tree_sha1(parent->tree->object.oid.hash,
-                              origin->commit->tree->object.oid.hash,
-                              "", &diff_opts);
+               diff_tree_oid(&parent->tree->object.oid,
+                             &origin->commit->tree->object.oid,
+                             "", &diff_opts);
        diffcore_std(&diff_opts);
 
        if (!diff_queued_diff.nr) {
@@ -635,9 +635,9 @@ static struct origin *find_rename(struct scoreboard *sb,
        if (is_null_oid(&origin->commit->object.oid))
                do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
-               diff_tree_sha1(parent->tree->object.oid.hash,
-                              origin->commit->tree->object.oid.hash,
-                              "", &diff_opts);
+               diff_tree_oid(&parent->tree->object.oid,
+                             &origin->commit->tree->object.oid,
+                             "", &diff_opts);
        diffcore_std(&diff_opts);
 
        for (i = 0; i < diff_queued_diff.nr; i++) {
@@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
        /* Try "find copies harder" on new path if requested;
         * we do not want to use diffcore_rename() actually to
         * match things up; find_copies_harder is set only to
-        * force diff_tree_sha1() to feed all filepairs to diff_queue,
+        * force diff_tree_oid() to feed all filepairs to diff_queue,
         * and this code needs to be after diff_setup_done(), which
         * usually makes find-copies-harder imply copy detection.
         */
@@ -1274,9 +1274,9 @@ static void find_copy_in_parent(struct scoreboard *sb,
        if (is_null_oid(&target->commit->object.oid))
                do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
-               diff_tree_sha1(parent->tree->object.oid.hash,
-                              target->commit->tree->object.oid.hash,
-                              "", &diff_opts);
+               diff_tree_oid(&parent->tree->object.oid,
+                             &target->commit->tree->object.oid,
+                             "", &diff_opts);
 
        if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
                diffcore_std(&diff_opts);
index 5ea1c143171af792773bed34994edaf82f122c3b..aef167619886e82ddf1aeb92c80549d8a5a43ed0 100644 (file)
@@ -49,8 +49,8 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
                return -1;
        printf("%s %s\n", oid_to_hex(&tree1->object.oid),
                          oid_to_hex(&tree2->object.oid));
-       diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
-                      "", &log_tree_opt.diffopt);
+       diff_tree_oid(&tree1->object.oid, &tree2->object.oid,
+                     "", &log_tree_opt.diffopt);
        log_tree_diff_flush(&log_tree_opt);
        return 0;
 }
@@ -148,9 +148,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
                if (tree2->flags & UNINTERESTING) {
                        SWAP(tree2, tree1);
                }
-               diff_tree_sha1(tree1->oid.hash,
-                              tree2->oid.hash,
-                              "", &opt->diffopt);
+               diff_tree_oid(&tree1->oid, &tree2->oid, "", &opt->diffopt);
                log_tree_diff_flush(opt);
                break;
        }
index 73b4ff3db28d5653e0d0dd2d8d60bbf3ca4c6748..4c6a1a962fa3f86cf7c17870eadf2f97f46d875a 100644 (file)
@@ -174,7 +174,7 @@ static int builtin_diff_tree(struct rev_info *revs,
                swap = 1;
        oid[swap] = &ent0->item->oid;
        oid[1 - swap] = &ent1->item->oid;
-       diff_tree_sha1(oid[0]->hash, oid[1]->hash, "", &revs->diffopt);
+       diff_tree_oid(oid[0], oid[1], "", &revs->diffopt);
        log_tree_diff_flush(revs);
        return 0;
 }
index e242726f08e2397c8875e0d1794d58561ac4ecd9..d57f36c43844cefcfa9302de4c3118f156f1383d 100644 (file)
@@ -562,8 +562,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
            get_object_mark(&commit->parents->item->object) != 0 &&
            !full_tree) {
                parse_commit_or_die(commit->parents->item);
-               diff_tree_sha1(commit->parents->item->tree->object.oid.hash,
-                              commit->tree->object.oid.hash, "", &rev->diffopt);
+               diff_tree_oid(&commit->parents->item->tree->object.oid,
+                             &commit->tree->object.oid, "", &rev->diffopt);
        }
        else
                diff_root_tree_oid(&commit->tree->object.oid,
index 6bdba3444659d860f5449b0e637b616c39dd97f6..4ef522ee50030f81d8eaf73b4a87793a4242a46d 100644 (file)
@@ -1043,9 +1043,9 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 
        diff_setup_done(&opts);
 
-       diff_tree_sha1(origin->tree->object.oid.hash,
-                      head->tree->object.oid.hash,
-                      "", &opts);
+       diff_tree_oid(&origin->tree->object.oid,
+                     &head->tree->object.oid,
+                     "", &opts);
        diffcore_std(&opts);
        diff_flush(&opts);
 
index a4a098f40f8e3e61c3f8b730a6b22a83c3c23566..afaed6a2c2fa4d426e440b2bdcc7bb0461253449 100644 (file)
@@ -415,7 +415,7 @@ static void finish(struct commit *head_commit,
                        DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
                opts.detect_rename = DIFF_DETECT_RENAME;
                diff_setup_done(&opts);
-               diff_tree_sha1(head->hash, new_head->hash, "", &opts);
+               diff_tree_oid(head, new_head, "", &opts);
                diffcore_std(&opts);
                diff_flush(&opts);
        }
index c823645106bde99c24c0942c8938f59768fb5a5b..04c4ae85643a606e312847422460ae9030603e58 100644 (file)
@@ -1336,7 +1336,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
                        opt->output_format = stat_opt;
                else
                        opt->output_format = DIFF_FORMAT_NO_OUTPUT;
-               diff_tree_sha1(parents->oid[i].hash, oid->hash, "", opt);
+               diff_tree_oid(&parents->oid[i], oid, "", opt);
                diffcore_std(opt);
                paths = intersect_paths(paths, i, num_parent);
 
@@ -1463,7 +1463,7 @@ void diff_tree_combined(const struct object_id *oid,
                if (stat_opt) {
                        diffopts.output_format = stat_opt;
 
-                       diff_tree_sha1(parents->oid[0].hash, oid->hash, "", &diffopts);
+                       diff_tree_oid(&parents->oid[0], oid, "", &diffopts);
                        diffcore_std(&diffopts);
                        if (opt->orderfile)
                                diffcore_order(opt->orderfile);
diff --git a/diff.h b/diff.h
index 8d46a670990856af2653d5f158cb34ca4e2fc91b..e0b5034603a764d3495bee4f1ae4461b3e42216d 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -213,8 +213,9 @@ extern struct combine_diff_path *diff_tree_paths(
        struct combine_diff_path *p, const unsigned char *sha1,
        const unsigned char **parent_sha1, int nparent,
        struct strbuf *base, struct diff_options *opt);
-extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
-                         const char *base, struct diff_options *opt);
+extern int diff_tree_oid(const struct object_id *old_oid,
+                        const struct object_id *new_oid,
+                        const char *base, struct diff_options *opt);
 extern int diff_root_tree_oid(const struct object_id *new_oid, const char *base,
                              struct diff_options *opt);
 
index a3bd2f2d5f6fc25fbe5a77a9233eebe6c76d3f80..2588ce076749ecbb6bfbe591666430edf4ff9073 100644 (file)
@@ -819,8 +819,8 @@ static void queue_diffs(struct line_log_data *range,
        assert(commit);
 
        DIFF_QUEUE_CLEAR(&diff_queued_diff);
-       diff_tree_sha1(parent ? parent->tree->object.oid.hash : NULL,
-                       commit->tree->object.oid.hash, "", opt);
+       diff_tree_oid(parent ? &parent->tree->object.oid : NULL,
+                     &commit->tree->object.oid, "", opt);
        if (opt->detect_rename) {
                filter_diffs_for_paths(range, 1);
                if (diff_might_be_rename())
index b40242534b0829f7352ba45112512f0d7042f7ac..2903874ecf156c374ae0a120cdc20a5f5e41df53 100644 (file)
@@ -822,8 +822,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
                         * we merged _in_.
                         */
                        parse_commit_or_die(parents->item);
-                       diff_tree_sha1(parents->item->tree->object.oid.hash,
-                                      oid->hash, "", &opt->diffopt);
+                       diff_tree_oid(&parents->item->tree->object.oid,
+                                     oid, "", &opt->diffopt);
                        log_tree_diff_flush(opt);
                        return !opt->loginfo;
                }
@@ -837,8 +837,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
                struct commit *parent = parents->item;
 
                parse_commit_or_die(parent);
-               diff_tree_sha1(parent->tree->object.oid.hash,
-                              oid->hash, "", &opt->diffopt);
+               diff_tree_oid(&parent->tree->object.oid,
+                             oid, "", &opt->diffopt);
                log_tree_diff_flush(opt);
 
                showed_log |= !opt->loginfo;
index ae5238d82ca8c86b99391a0836a0539efe7eacde..5cc86df2d15729e9b0e8b36fdb151d5986f42a10 100644 (file)
@@ -528,7 +528,7 @@ static struct string_list *get_renames(struct merge_options *o,
        opts.show_rename_progress = o->show_rename_progress;
        opts.output_format = DIFF_FORMAT_NO_OUTPUT;
        diff_setup_done(&opts);
-       diff_tree_sha1(o_tree->object.oid.hash, tree->object.oid.hash, "", &opts);
+       diff_tree_oid(&o_tree->object.oid, &tree->object.oid, "", &opts);
        diffcore_std(&opts);
        if (opts.needed_rename_limit > o->needed_rename_limit)
                o->needed_rename_limit = opts.needed_rename_limit;
index 7d88857a8046efa491b2198b5483ea0f231485cd..70e3fbeefbe24233a545e75c0322a8a310778e43 100644 (file)
@@ -129,7 +129,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
        DIFF_OPT_SET(&opt, RECURSIVE);
        opt.output_format = DIFF_FORMAT_NO_OUTPUT;
        diff_setup_done(&opt);
-       diff_tree_sha1(base->hash, remote->hash, "", &opt);
+       diff_tree_oid(base, remote, "", &opt);
        diffcore_std(&opt);
 
        changes = xcalloc(diff_queued_diff.nr, sizeof(struct notes_merge_pair));
@@ -192,7 +192,7 @@ static void diff_tree_local(struct notes_merge_options *o,
        DIFF_OPT_SET(&opt, RECURSIVE);
        opt.output_format = DIFF_FORMAT_NO_OUTPUT;
        diff_setup_done(&opt);
-       diff_tree_sha1(base->hash, local->hash, "", &opt);
+       diff_tree_oid(base, local, "", &opt);
        diffcore_std(&opt);
 
        for (i = 0; i < diff_queued_diff.nr; i++) {
index aaf462c03085e164f6b93a686fb8d2575b5bb7ba..9c0ab9e67a80b54f87d9b9d52fa08de7167aec4a 100644 (file)
@@ -17,8 +17,8 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
                return -1;
 
        if (commit->parents)
-               diff_tree_sha1(commit->parents->item->object.oid.hash,
-                              commit->object.oid.hash, "", options);
+               diff_tree_oid(&commit->parents->item->object.oid,
+                             &commit->object.oid, "", options);
        else
                diff_root_tree_oid(&commit->object.oid, "", options);
        diffcore_std(options);
index 7637e75561971dfa8d45412c999886feb944cab8..3030f33eedb6381d03607059edbb3bba1da6073c 100644 (file)
@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,
 
        tree_difference = REV_TREE_SAME;
        DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
-       if (diff_tree_sha1(t1->object.oid.hash, t2->object.oid.hash, "",
+       if (diff_tree_oid(&t1->object.oid, &t2->object.oid, "",
                           &revs->pruning) < 0)
                return REV_TREE_DIFFERENT;
        return tree_difference;
@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
 
        tree_difference = REV_TREE_SAME;
        DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
-       retval = diff_tree_sha1(NULL, t1->object.oid.hash, "", &revs->pruning);
+       retval = diff_tree_oid(NULL, &t1->object.oid, "", &revs->pruning);
 
        return retval >= 0 && (tree_difference == REV_TREE_SAME);
 }
index a23b948ac148304dbebfe38955ec8b40cab3e1e5..7a114def84e7d8649934d28c51da7306617b089c 100644 (file)
@@ -2129,8 +2129,8 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
                        if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
                            !get_sha1(buf.buf, orig.hash) &&
                            !get_sha1("HEAD", head.hash)) {
-                               diff_tree_sha1(orig.hash, head.hash,
-                                              "", &log_tree_opt.diffopt);
+                               diff_tree_oid(&orig, &head, "",
+                                             &log_tree_opt.diffopt);
                                log_tree_diff_flush(&log_tree_opt);
                        }
                }
index f9bbaf3c472bc45289a2b2050e132a22f43b4d5e..fc020d76dc651757ea0c6d69d42dedf066370200 100644 (file)
@@ -419,7 +419,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
         * load parents first, as they are probably already cached.
         *
         * ( log_tree_diff() parses commit->parent before calling here via
-        *   diff_tree_sha1(parent, commit) )
+        *   diff_tree_oid(parent, commit) )
         */
        for (i = 0; i < nparent; ++i)
                tptree[i] = fill_tree_descriptor(&tp[i], parents_sha1[i]);
@@ -694,7 +694,9 @@ static int ll_diff_tree_sha1(const unsigned char *old, const unsigned char *new,
        return 0;
 }
 
-int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const char *base_str, struct diff_options *opt)
+int diff_tree_oid(const struct object_id *old_oid,
+                 const struct object_id *new_oid,
+                 const char *base_str, struct diff_options *opt)
 {
        struct strbuf base;
        int retval;
@@ -702,9 +704,9 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
        strbuf_init(&base, PATH_MAX);
        strbuf_addstr(&base, base_str);
 
-       retval = ll_diff_tree_sha1(old, new, &base, opt);
+       retval = ll_diff_tree_sha1(old_oid->hash, new_oid->hash, &base, opt);
        if (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())
-               try_to_follow_renames(old, new, &base, opt);
+               try_to_follow_renames(old_oid->hash, new_oid->hash, &base, opt);
 
        strbuf_release(&base);
 
@@ -713,5 +715,5 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
 
 int diff_root_tree_oid(const struct object_id *new_oid, const char *base, struct diff_options *opt)
 {
-       return diff_tree_sha1(NULL, new_oid->hash, base, opt);
+       return diff_tree_oid(NULL, new_oid, base, opt);
 }