diff: convert diff_addremove to struct object_id
authorBrandon Williams <bmwill@google.com>
Tue, 30 May 2017 17:30:47 +0000 (10:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Jun 2017 00:36:07 +0000 (09:36 +0900)
Convert diff_addremove to take a struct object_id. In addtion convert
the function pointer type 'add_remove_fn_t' to also take a struct
object_id.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib.c
diff.c
diff.h
revision.c
tree-diff.c
index 2c838aaf438bef9b06fa662ecfdcb7b64b8e42e2..7984ff962fd216a20f50ba8970310adf5b2d98d6 100644 (file)
@@ -210,14 +210,14 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
                                        continue;
                                }
                                diff_addremove(&revs->diffopt, '-', ce->ce_mode,
-                                              ce->oid.hash,
+                                              &ce->oid,
                                               !is_null_oid(&ce->oid),
                                               ce->name, 0);
                                continue;
                        } else if (revs->diffopt.ita_invisible_in_index &&
                                   ce_intent_to_add(ce)) {
                                diff_addremove(&revs->diffopt, '+', ce->ce_mode,
-                                              EMPTY_BLOB_SHA1_BIN, 0,
+                                              &empty_tree_oid, 0,
                                               ce->name, 0);
                                continue;
                        }
@@ -260,7 +260,7 @@ static void diff_index_show_file(struct rev_info *revs,
                                 unsigned dirty_submodule)
 {
        diff_addremove(&revs->diffopt, prefix[0], mode,
-                      oid->hash, oid_valid, ce->name, dirty_submodule);
+                      oid, oid_valid, ce->name, dirty_submodule);
 }
 
 static int get_stat_data(const struct cache_entry *ce,
diff --git a/diff.c b/diff.c
index f3546536b4b09097b85ec2ae8072362cdac32e06..3fa335f4464f156b9cfee0837ce400804756de3f 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -5081,8 +5081,8 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)
 
 void diff_addremove(struct diff_options *options,
                    int addremove, unsigned mode,
-                   const unsigned char *sha1,
-                   int sha1_valid,
+                   const struct object_id *oid,
+                   int oid_valid,
                    const char *concatpath, unsigned dirty_submodule)
 {
        struct diff_filespec *one, *two;
@@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,
        two = alloc_filespec(concatpath);
 
        if (addremove != '+')
-               fill_filespec(one, sha1, sha1_valid, mode);
+               fill_filespec(one, oid->hash, oid_valid, mode);
        if (addremove != '-') {
-               fill_filespec(two, sha1, sha1_valid, mode);
+               fill_filespec(two, oid->hash, oid_valid, mode);
                two->dirty_submodule = dirty_submodule;
        }
 
diff --git a/diff.h b/diff.h
index d75e6d15e28dea0318cbec174694d68ac695bb5d..1086975a5a68d0487300b232f7ec1a1a80977645 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -31,8 +31,8 @@ typedef void (*change_fn_t)(struct diff_options *options,
 
 typedef void (*add_remove_fn_t)(struct diff_options *options,
                    int addremove, unsigned mode,
-                   const unsigned char *sha1,
-                   int sha1_valid,
+                   const struct object_id *oid,
+                   int oid_valid,
                    const char *fullpath, unsigned dirty_submodule);
 
 typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
@@ -247,8 +247,8 @@ extern int diff_can_quit_early(struct diff_options *);
 extern void diff_addremove(struct diff_options *,
                           int addremove,
                           unsigned mode,
-                          const unsigned char *sha1,
-                          int sha1_valid,
+                          const struct object_id *oid,
+                          int oid_valid,
                           const char *fullpath, unsigned dirty_submodule);
 
 extern void diff_change(struct diff_options *,
index 475d5b2dc111d18315e089798cbf85078dac96d6..71519193caa6d6451698be4f3cbcd775e7c9953d 100644 (file)
@@ -401,8 +401,8 @@ static int tree_difference = REV_TREE_SAME;
 
 static void file_add_remove(struct diff_options *options,
                    int addremove, unsigned mode,
-                   const unsigned char *sha1,
-                   int sha1_valid,
+                   const struct object_id *oid,
+                   int oid_valid,
                    const char *fullpath, unsigned dirty_submodule)
 {
        int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;
index e164e532b2f76617d822c3bef9492b9525b56e83..f2c747ea509bf69d7fdadbd16a383e59b2324b2e 100644 (file)
@@ -78,21 +78,21 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_
                        1, 1, p->path, 0, 0);
        }
        else {
-               const unsigned char *sha1;
+               const struct object_id *oid;
                unsigned int mode;
                int addremove;
 
                if (p->mode) {
                        addremove = '+';
-                       sha1 = p->oid.hash;
+                       oid = &p->oid;
                        mode = p->mode;
                } else {
                        addremove = '-';
-                       sha1 = p0->oid.hash;
+                       oid = &p0->oid;
                        mode = p0->mode;
                }
 
-               opt->add_remove(opt, addremove, mode, sha1, 1, p->path, 0);
+               opt->add_remove(opt, addremove, mode, oid, 1, p->path, 0);
        }
 
        return 0;       /* we are done with p */