[PATCH v2 07/10] diff: convert struct combine_diff_path to object_id
Also, convert a constant to GIT_SHA1_HEXSZ. Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- combine-diff.c | 56 diff-lib.c | 10 +- diff.h | 5 +++-- tree-diff.c| 10 +- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/combine-diff.c b/combine-diff.c index 91edce5..8eb7278 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -44,9 +44,9 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, memset(p-parent, 0, sizeof(p-parent[0]) * num_parent); - hashcpy(p-sha1, q-queue[i]-two-sha1); + hashcpy(p-oid.hash, q-queue[i]-two-sha1); p-mode = q-queue[i]-two-mode; - hashcpy(p-parent[n].sha1, q-queue[i]-one-sha1); + hashcpy(p-parent[n].oid.hash, q-queue[i]-one-sha1); p-parent[n].mode = q-queue[i]-one-mode; p-parent[n].status = q-queue[i]-status; *tail = p; @@ -77,7 +77,7 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, continue; } - hashcpy(p-parent[n].sha1, q-queue[i]-one-sha1); + hashcpy(p-parent[n].oid.hash, q-queue[i]-one-sha1); p-parent[n].mode = q-queue[i]-one-mode; p-parent[n].status = q-queue[i]-status; @@ -284,7 +284,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase, return base; } -static char *grab_blob(const unsigned char *sha1, unsigned int mode, +static char *grab_blob(const struct object_id *oid, unsigned int mode, unsigned long *size, struct userdiff_driver *textconv, const char *path) { @@ -294,20 +294,20 @@ static char *grab_blob(const unsigned char *sha1, unsigned int mode, if (S_ISGITLINK(mode)) { blob = xmalloc(100); *size = snprintf(blob, 100, -Subproject commit %s\n, sha1_to_hex(sha1)); - } else if (is_null_sha1(sha1)) { +Subproject commit %s\n, oid_to_hex(oid)); + } else if (is_null_oid(oid)) { /* deleted blob */ *size = 0; return xcalloc(1, 1); } else if (textconv) { struct diff_filespec *df = alloc_filespec(path); - fill_filespec(df, sha1, 1, mode); + fill_filespec(df, oid-hash, 1, mode); *size = fill_textconv(textconv, df, blob); free_filespec(df); } else { - blob = read_sha1_file(sha1, type, size); + blob = read_sha1_file(oid-hash, type, size); if (type != OBJ_BLOB) - die(object '%s' is not a blob!, sha1_to_hex(sha1)); + die(object '%s' is not a blob!, oid_to_hex(oid)); } return blob; } @@ -389,7 +389,7 @@ static void consume_line(void *state_, char *line, unsigned long len) } } -static void combine_diff(const unsigned char *parent, unsigned int mode, +static void combine_diff(const struct object_id *parent, unsigned int mode, mmfile_t *result_file, struct sline *sline, unsigned int cnt, int n, int num_parent, int result_deleted, @@ -897,7 +897,7 @@ static void show_combined_header(struct combine_diff_path *elem, int show_file_header) { struct diff_options *opt = rev-diffopt; - int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? 40 : DEFAULT_ABBREV; + int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV; const char *a_prefix = opt-a_prefix ? opt-a_prefix : a/; const char *b_prefix = opt-b_prefix ? opt-b_prefix : b/; const char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO); @@ -914,11 +914,11 @@ static void show_combined_header(struct combine_diff_path *elem, , elem-path, line_prefix, c_meta, c_reset); printf(%s%sindex , line_prefix, c_meta); for (i = 0; i num_parent; i++) { - abb = find_unique_abbrev(elem-parent[i].sha1, + abb = find_unique_abbrev(elem-parent[i].oid.hash, abbrev); printf(%s%s, i ? , : , abb); } - abb = find_unique_abbrev(elem-sha1, abbrev); + abb = find_unique_abbrev(elem-oid.hash, abbrev); printf(..%s%s\n, abb, c_reset); if (mode_differs) { @@ -991,7 +991,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, /* Read the result of merge first */ if (!working_tree_file) - result = grab_blob(elem-sha1,
[PATCH v2 07/10] diff: convert struct combine_diff_path to object_id
Also, convert a constant to GIT_SHA1_HEXSZ. Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- combine-diff.c | 56 diff-lib.c | 10 +- diff.h | 5 +++-- tree-diff.c| 10 +- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/combine-diff.c b/combine-diff.c index 91edce5..ec25202 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -44,9 +44,9 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, memset(p-parent, 0, sizeof(p-parent[0]) * num_parent); - hashcpy(p-sha1, q-queue[i]-two-sha1); + hashcpy(p-oid.sha1, q-queue[i]-two-sha1); p-mode = q-queue[i]-two-mode; - hashcpy(p-parent[n].sha1, q-queue[i]-one-sha1); + hashcpy(p-parent[n].oid.sha1, q-queue[i]-one-sha1); p-parent[n].mode = q-queue[i]-one-mode; p-parent[n].status = q-queue[i]-status; *tail = p; @@ -77,7 +77,7 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, continue; } - hashcpy(p-parent[n].sha1, q-queue[i]-one-sha1); + hashcpy(p-parent[n].oid.sha1, q-queue[i]-one-sha1); p-parent[n].mode = q-queue[i]-one-mode; p-parent[n].status = q-queue[i]-status; @@ -284,7 +284,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase, return base; } -static char *grab_blob(const unsigned char *sha1, unsigned int mode, +static char *grab_blob(const struct object_id *oid, unsigned int mode, unsigned long *size, struct userdiff_driver *textconv, const char *path) { @@ -294,20 +294,20 @@ static char *grab_blob(const unsigned char *sha1, unsigned int mode, if (S_ISGITLINK(mode)) { blob = xmalloc(100); *size = snprintf(blob, 100, -Subproject commit %s\n, sha1_to_hex(sha1)); - } else if (is_null_sha1(sha1)) { +Subproject commit %s\n, oid_to_hex(oid)); + } else if (is_null_oid(oid)) { /* deleted blob */ *size = 0; return xcalloc(1, 1); } else if (textconv) { struct diff_filespec *df = alloc_filespec(path); - fill_filespec(df, sha1, 1, mode); + fill_filespec(df, oid-sha1, 1, mode); *size = fill_textconv(textconv, df, blob); free_filespec(df); } else { - blob = read_sha1_file(sha1, type, size); + blob = read_sha1_file(oid-sha1, type, size); if (type != OBJ_BLOB) - die(object '%s' is not a blob!, sha1_to_hex(sha1)); + die(object '%s' is not a blob!, oid_to_hex(oid)); } return blob; } @@ -389,7 +389,7 @@ static void consume_line(void *state_, char *line, unsigned long len) } } -static void combine_diff(const unsigned char *parent, unsigned int mode, +static void combine_diff(const struct object_id *parent, unsigned int mode, mmfile_t *result_file, struct sline *sline, unsigned int cnt, int n, int num_parent, int result_deleted, @@ -897,7 +897,7 @@ static void show_combined_header(struct combine_diff_path *elem, int show_file_header) { struct diff_options *opt = rev-diffopt; - int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? 40 : DEFAULT_ABBREV; + int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV; const char *a_prefix = opt-a_prefix ? opt-a_prefix : a/; const char *b_prefix = opt-b_prefix ? opt-b_prefix : b/; const char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO); @@ -914,11 +914,11 @@ static void show_combined_header(struct combine_diff_path *elem, , elem-path, line_prefix, c_meta, c_reset); printf(%s%sindex , line_prefix, c_meta); for (i = 0; i num_parent; i++) { - abb = find_unique_abbrev(elem-parent[i].sha1, + abb = find_unique_abbrev(elem-parent[i].oid.sha1, abbrev); printf(%s%s, i ? , : , abb); } - abb = find_unique_abbrev(elem-sha1, abbrev); + abb = find_unique_abbrev(elem-oid.sha1, abbrev); printf(..%s%s\n, abb, c_reset); if (mode_differs) { @@ -991,7 +991,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, /* Read the result of merge first */ if (!working_tree_file) - result = grab_blob(elem-sha1,