Signed-off-by: Brandon Williams <bmwill@xxxxxxxxxx> --- combine-diff.c | 10 +++++----- diff.h | 4 ++-- tree-diff.c | 63 +++++++++++++++++++++++++++++----------------------------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/combine-diff.c b/combine-diff.c index 04c4ae856..ec9d93044 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1364,22 +1364,22 @@ static struct combine_diff_path *find_paths_multitree( struct diff_options *opt) { int i, nparent = parents->nr; - const unsigned char **parents_sha1; + const struct object_id **parents_oid; struct combine_diff_path paths_head; struct strbuf base; - ALLOC_ARRAY(parents_sha1, nparent); + ALLOC_ARRAY(parents_oid, nparent); for (i = 0; i < nparent; i++) - parents_sha1[i] = parents->oid[i].hash; + parents_oid[i] = &parents->oid[i]; /* fake list head, so worker can assume it is non-NULL */ paths_head.next = NULL; strbuf_init(&base, PATH_MAX); - diff_tree_paths(&paths_head, oid->hash, parents_sha1, nparent, &base, opt); + diff_tree_paths(&paths_head, oid, parents_oid, nparent, &base, opt); strbuf_release(&base); - free(parents_sha1); + free(parents_oid); return paths_head.next; } diff --git a/diff.h b/diff.h index e0b503460..0d0c14f28 100644 --- a/diff.h +++ b/diff.h @@ -210,8 +210,8 @@ const char *diff_line_prefix(struct diff_options *); extern const char mime_boundary_leader[]; extern struct combine_diff_path *diff_tree_paths( - struct combine_diff_path *p, const unsigned char *sha1, - const unsigned char **parent_sha1, int nparent, + struct combine_diff_path *p, const struct object_id *oid, + const struct object_id **parents_oid, int nparent, struct strbuf *base, struct diff_options *opt); extern int diff_tree_oid(const struct object_id *old_oid, const struct object_id *new_oid, diff --git a/tree-diff.c b/tree-diff.c index 29e3f6144..6a960f569 100644 --- a/tree-diff.c +++ b/tree-diff.c @@ -26,11 +26,12 @@ } while(0) static struct combine_diff_path *ll_diff_tree_paths( - struct combine_diff_path *p, const unsigned char *sha1, - const unsigned char **parents_sha1, int nparent, + struct combine_diff_path *p, const struct object_id *oid, + const struct object_id **parents_oid, int nparent, struct strbuf *base, struct diff_options *opt); -static int ll_diff_tree_sha1(const unsigned char *old, const unsigned char *new, - struct strbuf *base, struct diff_options *opt); +static int ll_diff_tree_oid(const struct object_id *old_oid, + const struct object_id *new_oid, + struct strbuf *base, struct diff_options *opt); /* * Compare two tree entries, taking into account only path/S_ISDIR(mode), @@ -183,7 +184,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, { unsigned mode; const char *path; - const unsigned char *sha1; + const struct object_id *oid; int pathlen; int old_baselen = base->len; int i, isdir, recurse = 0, emitthis = 1; @@ -193,7 +194,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, if (t) { /* path present in resulting tree */ - sha1 = tree_entry_extract(t, &path, &mode)->hash; + oid = tree_entry_extract(t, &path, &mode); pathlen = tree_entry_len(&t->entry); isdir = S_ISDIR(mode); } else { @@ -208,7 +209,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, pathlen = tree_entry_len(&tp[imin].entry); isdir = S_ISDIR(mode); - sha1 = NULL; + oid = NULL; mode = 0; } @@ -220,7 +221,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, if (emitthis) { int keep; struct combine_diff_path *pprev = p; - p = path_appendnew(p, nparent, base, path, pathlen, mode, sha1); + p = path_appendnew(p, nparent, base, path, pathlen, mode, oid ? oid->hash : NULL); for (i = 0; i < nparent; ++i) { /* @@ -229,7 +230,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, */ int tpi_valid = tp && !(tp[i].entry.mode & S_IFXMIN_NEQ); - const unsigned char *sha1_i; + const struct object_id *oid_i; unsigned mode_i; p->parent[i].status = @@ -239,16 +240,16 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, DIFF_STATUS_ADDED; if (tpi_valid) { - sha1_i = tp[i].entry.oid->hash; + oid_i = tp[i].entry.oid; mode_i = tp[i].entry.mode; } else { - sha1_i = NULL; + oid_i = &null_oid; mode_i = 0; } p->parent[i].mode = mode_i; - hashcpy(p->parent[i].oid.hash, sha1_i ? sha1_i : null_sha1); + oidcpy(&p->parent[i].oid, oid_i); } keep = 1; @@ -273,21 +274,20 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, } if (recurse) { - const unsigned char **parents_sha1; + const struct object_id **parents_oid; - FAST_ARRAY_ALLOC(parents_sha1, nparent); + FAST_ARRAY_ALLOC(parents_oid, nparent); for (i = 0; i < nparent; ++i) { /* same rule as in emitthis */ int tpi_valid = tp && !(tp[i].entry.mode & S_IFXMIN_NEQ); - parents_sha1[i] = tpi_valid ? tp[i].entry.oid->hash - : NULL; + parents_oid[i] = tpi_valid ? tp[i].entry.oid : NULL; } strbuf_add(base, path, pathlen); strbuf_addch(base, '/'); - p = ll_diff_tree_paths(p, sha1, parents_sha1, nparent, base, opt); - FAST_ARRAY_FREE(parents_sha1, nparent); + p = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt); + FAST_ARRAY_FREE(parents_oid, nparent); } strbuf_setlen(base, old_baselen); @@ -312,7 +312,7 @@ static void skip_uninteresting(struct tree_desc *t, struct strbuf *base, /* - * generate paths for combined diff D(sha1,parents_sha1[]) + * generate paths for combined diff D(sha1,parents_oid[]) * * Resulting paths are appended to combine_diff_path linked list, and also, are * emitted on the go via opt->pathchange() callback, so it is possible to @@ -404,8 +404,8 @@ static inline void update_tp_entries(struct tree_desc *tp, int nparent) } static struct combine_diff_path *ll_diff_tree_paths( - struct combine_diff_path *p, const unsigned char *sha1, - const unsigned char **parents_sha1, int nparent, + struct combine_diff_path *p, const struct object_id *oid, + const struct object_id **parents_oid, int nparent, struct strbuf *base, struct diff_options *opt) { struct tree_desc t, *tp; @@ -422,8 +422,8 @@ static struct combine_diff_path *ll_diff_tree_paths( * diff_tree_oid(parent, commit) ) */ for (i = 0; i < nparent; ++i) - tptree[i] = fill_tree_descriptor(&tp[i], parents_sha1[i]); - ttree = fill_tree_descriptor(&t, sha1); + tptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]->hash); + ttree = fill_tree_descriptor(&t, oid->hash); /* Enable recursion indefinitely */ opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE); @@ -548,11 +548,11 @@ static struct combine_diff_path *ll_diff_tree_paths( } struct combine_diff_path *diff_tree_paths( - struct combine_diff_path *p, const unsigned char *sha1, - const unsigned char **parents_sha1, int nparent, + struct combine_diff_path *p, const struct object_id *oid, + const struct object_id **parents_oid, int nparent, struct strbuf *base, struct diff_options *opt) { - p = ll_diff_tree_paths(p, sha1, parents_sha1, nparent, base, opt); + p = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt); /* * free pre-allocated last element, if any @@ -617,7 +617,7 @@ static void try_to_follow_renames(const struct object_id *old_oid, diff_opts.break_opt = opt->break_opt; diff_opts.rename_score = opt->rename_score; diff_setup_done(&diff_opts); - ll_diff_tree_sha1(old_oid->hash, new_oid->hash, base, &diff_opts); + ll_diff_tree_oid(old_oid, new_oid, base, &diff_opts); diffcore_std(&diff_opts); clear_pathspec(&diff_opts.pathspec); @@ -676,15 +676,16 @@ static void try_to_follow_renames(const struct object_id *old_oid, q->nr = 1; } -static int ll_diff_tree_sha1(const unsigned char *old, const unsigned char *new, - struct strbuf *base, struct diff_options *opt) +static int ll_diff_tree_oid(const struct object_id *old_oid, + const struct object_id *new_oid, + struct strbuf *base, struct diff_options *opt) { struct combine_diff_path phead, *p; pathchange_fn_t pathchange_old = opt->pathchange; phead.next = NULL; opt->pathchange = emit_diff_first_parent_only; - diff_tree_paths(&phead, new, &old, 1, base, opt); + diff_tree_paths(&phead, new_oid, &old_oid, 1, base, opt); for (p = phead.next; p;) { struct combine_diff_path *pprev = p; @@ -706,7 +707,7 @@ int diff_tree_oid(const struct object_id *old_oid, strbuf_init(&base, PATH_MAX); strbuf_addstr(&base, base_str); - retval = ll_diff_tree_sha1(old_oid->hash, new_oid->hash, &base, opt); + retval = ll_diff_tree_oid(old_oid, new_oid, &base, opt); if (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename()) try_to_follow_renames(old_oid, new_oid, &base, opt); -- 2.13.0.219.gdb65acc882-goog