diff: convert diff_change to struct object_id

Convert diff_change to take a struct object_id. In addition convert the function pointer type 'change_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>

Brandon Williams committed May 30, 2017 at 10:30 UTC 94a0097a41f09e00322add6d1cf62b3610b6a85c
5 files changed +19 -20
diff-lib.c
+2 -2
@@ -236,7 +236,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
236 old_oid = &ce->oid;
237 new_oid = changed ? &null_oid : &ce->oid;
238 diff_change(&revs->diffopt, oldmode, newmode,
239 - old_oid->hash, new_oid->hash,
239 + old_oid, new_oid,
240 !is_null_oid(old_oid),
241 !is_null_oid(new_oid),
242 ce->name, 0, dirty_submodule);
@@ -367,7 +367,7 @@ static int show_modified(struct rev_info *revs,
367 return 0;
368
369 diff_change(&revs->diffopt, oldmode, mode,
370 - old->oid.hash, oid->hash, 1, !is_null_oid(oid),
370 + &old->oid, oid, 1, !is_null_oid(oid),
371 old->name, 0, dirty_submodule);
372 return 0;
373 }
diff.c
+7 -7
@@ -5127,9 +5127,9 @@ void diff_addremove(struct diff_options *options,
5127
5128 void diff_change(struct diff_options *options,
5129 unsigned old_mode, unsigned new_mode,
5130 - const unsigned char *old_sha1,
5131 - const unsigned char *new_sha1,
5132 - int old_sha1_valid, int new_sha1_valid,
5130 + const struct object_id *old_oid,
5131 + const struct object_id *new_oid,
5132 + int old_oid_valid, int new_oid_valid,
5133 const char *concatpath,
5134 unsigned old_dirty_submodule, unsigned new_dirty_submodule)
5135 {
@@ -5142,8 +5142,8 @@ void diff_change(struct diff_options *options,
5142
5143 if (DIFF_OPT_TST(options, REVERSE_DIFF)) {
5144 SWAP(old_mode, new_mode);
5145 - SWAP(old_sha1, new_sha1);
5146 - SWAP(old_sha1_valid, new_sha1_valid);
5145 + SWAP(old_oid, new_oid);
5146 + SWAP(old_oid_valid, new_oid_valid);
5147 SWAP(old_dirty_submodule, new_dirty_submodule);
5148 }
5149
@@ -5153,8 +5153,8 @@ void diff_change(struct diff_options *options,
5153
5154 one = alloc_filespec(concatpath);
5155 two = alloc_filespec(concatpath);
5156 - fill_filespec(one, old_sha1, old_sha1_valid, old_mode);
5157 - fill_filespec(two, new_sha1, new_sha1_valid, new_mode);
5156 + fill_filespec(one, old_oid->hash, old_oid_valid, old_mode);
5157 + fill_filespec(two, new_oid->hash, new_oid_valid, new_mode);
5158 one->dirty_submodule = old_dirty_submodule;
5159 two->dirty_submodule = new_dirty_submodule;
5160 p = diff_queue(&diff_queued_diff, one, two);
diff.h
+6 -7
@@ -23,9 +23,9 @@ typedef int (*pathchange_fn_t)(struct diff_options *options,
23
24 typedef void (*change_fn_t)(struct diff_options *options,
25 unsigned old_mode, unsigned new_mode,
26 - const unsigned char *old_sha1,
27 - const unsigned char *new_sha1,
28 - int old_sha1_valid, int new_sha1_valid,
26 + const struct object_id *old_oid,
27 + const struct object_id *new_oid,
28 + int old_oid_valid, int new_oid_valid,
29 const char *fullpath,
30 unsigned old_dirty_submodule, unsigned new_dirty_submodule);
31
@@ -253,10 +253,9 @@ extern void diff_addremove(struct diff_options *,
253
254 extern void diff_change(struct diff_options *,
255 unsigned mode1, unsigned mode2,
256 - const unsigned char *sha1,
257 - const unsigned char *sha2,
258 - int sha1_valid,
259 - int sha2_valid,
256 + const struct object_id *old_oid,
257 + const struct object_id *new_oid,
258 + int old_oid_valid, int new_oid_valid,
259 const char *fullpath,
260 unsigned dirty_submodule1, unsigned dirty_submodule2);
261
revision.c
+3 -3
@@ -414,9 +414,9 @@ static void file_add_remove(struct diff_options *options,
414
415 static void file_change(struct diff_options *options,
416 unsigned old_mode, unsigned new_mode,
417 - const unsigned char *old_sha1,
418 - const unsigned char *new_sha1,
419 - int old_sha1_valid, int new_sha1_valid,
417 + const struct object_id *old_oid,
418 + const struct object_id *new_oid,
419 + int old_oid_valid, int new_oid_valid,
420 const char *fullpath,
421 unsigned old_dirty_submodule, unsigned new_dirty_submodule)
422 {
tree-diff.c
+1 -1
@@ -74,7 +74,7 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_
74 {
75 struct combine_diff_parent *p0 = &p->parent[0];
76 if (p->mode && p0->mode) {
77 - opt->change(opt, p0->mode, p->mode, p0->oid.hash, p->oid.hash,
77 + opt->change(opt, p0->mode, p->mode, &p0->oid, &p->oid,
78 1, 1, p->path, 0, 0);
79 }
80 else {