diff options
Diffstat (limited to 'diff-lib.c')
-rw-r--r-- | diff-lib.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/diff-lib.c b/diff-lib.c index 875aff8643..3007c8524c 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -101,6 +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; if (diff_can_quit_early(&revs->diffopt)) break; @@ -124,7 +125,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) dpath->next = NULL; memcpy(dpath->path, ce->name, path_len); dpath->path[path_len] = '\0'; - hashclr(dpath->sha1); + oidclr(&dpath->oid); memset(&(dpath->parent[0]), 0, sizeof(struct combine_diff_parent)*5); @@ -154,7 +155,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option) if (2 <= stage) { int mode = nce->ce_mode; num_compare_stages++; - hashcpy(dpath->parent[stage-2].sha1, nce->sha1); + oidcpy(&dpath->parent[stage - 2].oid, + &nce->oid); dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode); dpath->parent[stage-2].status = DIFF_STATUS_MODIFIED; @@ -208,7 +210,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option) continue; } diff_addremove(&revs->diffopt, '-', ce->ce_mode, - ce->sha1, !is_null_sha1(ce->sha1), + ce->oid.hash, + !is_null_oid(&ce->oid), ce->name, 0); continue; } @@ -224,9 +227,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; diff_change(&revs->diffopt, oldmode, newmode, - ce->sha1, (changed ? null_sha1 : ce->sha1), - !is_null_sha1(ce->sha1), (changed ? 0 : !is_null_sha1(ce->sha1)), + old_sha1, new_sha1, + !is_null_sha1(old_sha1), + !is_null_sha1(new_sha1), ce->name, 0, dirty_submodule); } @@ -257,7 +263,7 @@ static int get_stat_data(const struct cache_entry *ce, int cached, int match_missing, unsigned *dirty_submodule, struct diff_options *diffopt) { - const unsigned char *sha1 = ce->sha1; + const unsigned char *sha1 = ce->oid.hash; unsigned int mode = ce->ce_mode; if (!cached && !ce_uptodate(ce)) { @@ -320,12 +326,13 @@ static int show_modified(struct rev_info *revs, &dirty_submodule, &revs->diffopt) < 0) { if (report_missing) diff_index_show_file(revs, "-", old, - old->sha1, 1, old->ce_mode, 0); + old->oid.hash, 1, old->ce_mode, + 0); return -1; } if (revs->combine_merges && !cached && - (hashcmp(sha1, old->sha1) || hashcmp(old->sha1, new->sha1))) { + (hashcmp(sha1, old->oid.hash) || oidcmp(&old->oid, &new->oid))) { struct combine_diff_path *p; int pathlen = ce_namelen(new); @@ -335,26 +342,26 @@ static int show_modified(struct rev_info *revs, memcpy(p->path, new->name, pathlen); p->path[pathlen] = 0; p->mode = mode; - hashclr(p->sha1); + oidclr(&p->oid); memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent)); p->parent[0].status = DIFF_STATUS_MODIFIED; p->parent[0].mode = new->ce_mode; - hashcpy(p->parent[0].sha1, new->sha1); + oidcpy(&p->parent[0].oid, &new->oid); p->parent[1].status = DIFF_STATUS_MODIFIED; p->parent[1].mode = old->ce_mode; - hashcpy(p->parent[1].sha1, old->sha1); + oidcpy(&p->parent[1].oid, &old->oid); show_combined_diff(p, 2, revs->dense_combined_merges, revs); free(p); return 0; } oldmode = old->ce_mode; - if (mode == oldmode && !hashcmp(sha1, old->sha1) && !dirty_submodule && + if (mode == oldmode && !hashcmp(sha1, old->oid.hash) && !dirty_submodule && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER)) return 0; diff_change(&revs->diffopt, oldmode, mode, - old->sha1, sha1, 1, !is_null_sha1(sha1), + old->oid.hash, sha1, 1, !is_null_sha1(sha1), old->name, 0, dirty_submodule); return 0; } @@ -388,7 +395,8 @@ 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->sha1, 1, tree->ce_mode); + fill_filespec(pair->one, tree->oid.hash, 1, + tree->ce_mode); return; } @@ -404,7 +412,8 @@ static void do_oneway_diff(struct unpack_trees_options *o, * Something removed from the tree? */ if (!idx) { - diff_index_show_file(revs, "-", tree, tree->sha1, 1, tree->ce_mode, 0); + diff_index_show_file(revs, "-", tree, tree->oid.hash, 1, + tree->ce_mode, 0); return; } @@ -489,7 +498,7 @@ int run_diff_index(struct rev_info *revs, int cached) struct object_array_entry *ent; ent = revs->pending.objects; - if (diff_cache(revs, ent->item->sha1, ent->name, cached)) + if (diff_cache(revs, ent->item->oid.hash, ent->name, cached)) exit(128); diff_set_mnemonic_prefix(&revs->diffopt, "c/", cached ? "i/" : "w/"); |