From 362d7659150511cb8ef0f4af690d39881f53822d Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 30 May 2017 10:30:45 -0700 Subject: diff: convert get_stat_data to struct object_id Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- diff-lib.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'diff-lib.c') diff --git a/diff-lib.c b/diff-lib.c index 2982bf055..a3bc78162 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -264,12 +264,12 @@ static void diff_index_show_file(struct rev_info *revs, } static int get_stat_data(const struct cache_entry *ce, - const unsigned char **sha1p, + const struct object_id **oidp, unsigned int *modep, int cached, int match_missing, unsigned *dirty_submodule, struct diff_options *diffopt) { - const unsigned char *sha1 = ce->oid.hash; + const struct object_id *oid = &ce->oid; unsigned int mode = ce->ce_mode; if (!cached && !ce_uptodate(ce)) { @@ -280,7 +280,7 @@ static int get_stat_data(const struct cache_entry *ce, return -1; else if (changed) { if (match_missing) { - *sha1p = sha1; + *oidp = oid; *modep = mode; return 0; } @@ -290,11 +290,11 @@ static int get_stat_data(const struct cache_entry *ce, 0, dirty_submodule); if (changed) { mode = ce_mode_from_stat(ce, st.st_mode); - sha1 = null_sha1; + oid = &null_oid; } } - *sha1p = sha1; + *oidp = oid; *modep = mode; return 0; } @@ -303,7 +303,7 @@ static void show_new_file(struct rev_info *revs, const struct cache_entry *new, int cached, int match_missing) { - const unsigned char *sha1; + const struct object_id *oid; unsigned int mode; unsigned dirty_submodule = 0; @@ -311,11 +311,11 @@ static void show_new_file(struct rev_info *revs, * New file in the index: it might actually be different in * the working tree. */ - if (get_stat_data(new, &sha1, &mode, cached, match_missing, + if (get_stat_data(new, &oid, &mode, cached, match_missing, &dirty_submodule, &revs->diffopt) < 0) return; - diff_index_show_file(revs, "+", new, sha1, !is_null_sha1(sha1), mode, dirty_submodule); + diff_index_show_file(revs, "+", new, oid->hash, !is_null_oid(oid), mode, dirty_submodule); } static int show_modified(struct rev_info *revs, @@ -325,10 +325,10 @@ static int show_modified(struct rev_info *revs, int cached, int match_missing) { unsigned int mode, oldmode; - const unsigned char *sha1; + const struct object_id *oid; unsigned dirty_submodule = 0; - if (get_stat_data(new, &sha1, &mode, cached, match_missing, + if (get_stat_data(new, &oid, &mode, cached, match_missing, &dirty_submodule, &revs->diffopt) < 0) { if (report_missing) diff_index_show_file(revs, "-", old, @@ -338,7 +338,7 @@ static int show_modified(struct rev_info *revs, } if (revs->combine_merges && !cached && - (hashcmp(sha1, old->oid.hash) || oidcmp(&old->oid, &new->oid))) { + (oidcmp(oid, &old->oid) || oidcmp(&old->oid, &new->oid))) { struct combine_diff_path *p; int pathlen = ce_namelen(new); @@ -362,12 +362,12 @@ static int show_modified(struct rev_info *revs, } oldmode = old->ce_mode; - if (mode == oldmode && !hashcmp(sha1, old->oid.hash) && !dirty_submodule && + if (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER)) return 0; diff_change(&revs->diffopt, oldmode, mode, - old->oid.hash, sha1, 1, !is_null_sha1(sha1), + old->oid.hash, oid->hash, 1, !is_null_oid(oid), old->name, 0, dirty_submodule); return 0; } -- cgit v1.2.1 From fcf2cfb54b6be34749feb6ffb50fe2bdd7bac8bc Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 30 May 2017 10:30:46 -0700 Subject: diff: convert diff_index_show_file to struct object_id Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- diff-lib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'diff-lib.c') diff --git a/diff-lib.c b/diff-lib.c index a3bc78162..2c838aaf4 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -255,12 +255,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option) static void diff_index_show_file(struct rev_info *revs, const char *prefix, const struct cache_entry *ce, - const unsigned char *sha1, int sha1_valid, + const struct object_id *oid, int oid_valid, unsigned int mode, unsigned dirty_submodule) { diff_addremove(&revs->diffopt, prefix[0], mode, - sha1, sha1_valid, ce->name, dirty_submodule); + oid->hash, oid_valid, ce->name, dirty_submodule); } static int get_stat_data(const struct cache_entry *ce, @@ -315,7 +315,7 @@ static void show_new_file(struct rev_info *revs, &dirty_submodule, &revs->diffopt) < 0) return; - diff_index_show_file(revs, "+", new, oid->hash, !is_null_oid(oid), mode, dirty_submodule); + diff_index_show_file(revs, "+", new, oid, !is_null_oid(oid), mode, dirty_submodule); } static int show_modified(struct rev_info *revs, @@ -332,7 +332,7 @@ static int show_modified(struct rev_info *revs, &dirty_submodule, &revs->diffopt) < 0) { if (report_missing) diff_index_show_file(revs, "-", old, - old->oid.hash, 1, old->ce_mode, + &old->oid, 1, old->ce_mode, 0); return -1; } @@ -426,7 +426,7 @@ static void do_oneway_diff(struct unpack_trees_options *o, * Something removed from the tree? */ if (!idx) { - diff_index_show_file(revs, "-", tree, tree->oid.hash, 1, + diff_index_show_file(revs, "-", tree, &tree->oid, 1, tree->ce_mode, 0); return; } -- cgit v1.2.1 From c26022ea8f54649ed6b3b545dd3158907abe5d2c Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 30 May 2017 10:30:47 -0700 Subject: 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 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'diff-lib.c') diff --git a/diff-lib.c b/diff-lib.c index 2c838aaf4..7984ff962 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, -- cgit v1.2.1 From 55497b8c9e0163cb6d02cdf3b3cc3a10330c2b66 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 30 May 2017 10:30:48 -0700 Subject: diff: convert run_diff_files to struct object_id Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- diff-lib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'diff-lib.c') diff --git a/diff-lib.c b/diff-lib.c index 7984ff962..c82b07dc1 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -101,7 +101,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) struct cache_entry *ce = active_cache[i]; int changed; unsigned dirty_submodule = 0; - const unsigned char *old_sha1, *new_sha1; + const struct object_id *old_oid, *new_oid; if (diff_can_quit_early(&revs->diffopt)) break; @@ -233,12 +233,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option) continue; } oldmode = ce->ce_mode; - old_sha1 = ce->oid.hash; - new_sha1 = changed ? null_sha1 : ce->oid.hash; + old_oid = &ce->oid; + new_oid = changed ? &null_oid : &ce->oid; diff_change(&revs->diffopt, oldmode, newmode, - old_sha1, new_sha1, - !is_null_sha1(old_sha1), - !is_null_sha1(new_sha1), + old_oid->hash, new_oid->hash, + !is_null_oid(old_oid), + !is_null_oid(new_oid), ce->name, 0, dirty_submodule); } -- cgit v1.2.1 From 94a0097a41f09e00322add6d1cf62b3610b6a85c Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 30 May 2017 10:30:49 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- diff-lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'diff-lib.c') diff --git a/diff-lib.c b/diff-lib.c index c82b07dc1..1e8215df5 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -236,7 +236,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) old_oid = &ce->oid; new_oid = changed ? &null_oid : &ce->oid; diff_change(&revs->diffopt, oldmode, newmode, - old_oid->hash, new_oid->hash, + old_oid, new_oid, !is_null_oid(old_oid), !is_null_oid(new_oid), ce->name, 0, dirty_submodule); @@ -367,7 +367,7 @@ static int show_modified(struct rev_info *revs, return 0; diff_change(&revs->diffopt, oldmode, mode, - old->oid.hash, oid->hash, 1, !is_null_oid(oid), + &old->oid, oid, 1, !is_null_oid(oid), old->name, 0, dirty_submodule); return 0; } -- cgit v1.2.1 From f9704c2d823f437aeed50e591415f24aebdda71d Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 30 May 2017 10:30:50 -0700 Subject: diff: convert fill_filespec to struct object_id Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- diff-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'diff-lib.c') diff --git a/diff-lib.c b/diff-lib.c index 1e8215df5..9e076a488 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -409,7 +409,7 @@ static void do_oneway_diff(struct unpack_trees_options *o, struct diff_filepair *pair; pair = diff_unmerge(&revs->diffopt, idx->name); if (tree) - fill_filespec(pair->one, tree->oid.hash, 1, + fill_filespec(pair->one, &tree->oid, 1, tree->ce_mode); return; } -- cgit v1.2.1