From c26022ea8f54649ed6b3b545dd3158907abe5d2c Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 30 May 2017 10:30:47 -0700 Subject: [PATCH] diff: convert diff_addremove to struct object_id 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 Signed-off-by: Junio C Hamano --- diff-lib.c | 6 +++--- diff.c | 8 ++++---- diff.h | 8 ++++---- revision.c | 4 ++-- tree-diff.c | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/diff-lib.c b/diff-lib.c index 2c838aaf43..7984ff962f 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -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 f3546536b4..3fa335f446 100644 --- 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 d75e6d15e2..1086975a5a 100644 --- 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 *, diff --git a/revision.c b/revision.c index 475d5b2dc1..71519193ca 100644 --- a/revision.c +++ b/revision.c @@ -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; diff --git a/tree-diff.c b/tree-diff.c index e164e532b2..f2c747ea50 100644 --- a/tree-diff.c +++ b/tree-diff.c @@ -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 */ -- 2.32.0.93.g670b81a890