diff: convert fill_filespec to struct object_id

Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 30, 2017 at 10:30 UTC f9704c2d823f437aeed50e591415f24aebdda71d
10 files changed +21 -21
builtin/blame.c
+1 -1
@@ -163,7 +163,7 @@ int textconv_object(const char *path,
163 struct userdiff_driver *textconv;
164
165 df = alloc_filespec(path);
166 - fill_filespec(df, oid->hash, oid_valid, mode);
166 + fill_filespec(df, oid, oid_valid, mode);
167 textconv = get_textconv(df);
168 if (!textconv) {
169 free_filespec(df);
builtin/diff.c
+2 -2
@@ -57,8 +57,8 @@ static void stuff_change(struct diff_options *opt,
57
58 one = alloc_filespec(old_name);
59 two = alloc_filespec(new_name);
60 - fill_filespec(one, old_oid->hash, old_oid_valid, old_mode);
61 - fill_filespec(two, new_oid->hash, new_oid_valid, new_mode);
60 + fill_filespec(one, old_oid, old_oid_valid, old_mode);
61 + fill_filespec(two, new_oid, new_oid_valid, new_mode);
62
63 diff_queue(&diff_queued_diff, one, two);
64 }
combine-diff.c
+2 -2
@@ -302,7 +302,7 @@ static char *grab_blob(const struct object_id *oid, unsigned int mode,
302 return xcalloc(1, 1);
303 } else if (textconv) {
304 struct diff_filespec *df = alloc_filespec(path);
305 - fill_filespec(df, oid->hash, 1, mode);
305 + fill_filespec(df, oid, 1, mode);
306 *size = fill_textconv(textconv, df, &blob);
307 free_filespec(df);
308 } else {
@@ -1022,7 +1022,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1022 &result_size, NULL, NULL);
1023 } else if (textconv) {
1024 struct diff_filespec *df = alloc_filespec(elem->path);
1025 - fill_filespec(df, null_sha1, 0, st.st_mode);
1025 + fill_filespec(df, &null_oid, 0, st.st_mode);
1026 result_size = fill_textconv(textconv, df, &result);
1027 free_filespec(df);
1028 } else if (0 <= (fd = open(elem->path, O_RDONLY))) {
diff-lib.c
+1 -1
@@ -409,7 +409,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
409 struct diff_filepair *pair;
410 pair = diff_unmerge(&revs->diffopt, idx->name);
411 if (tree)
412 - fill_filespec(pair->one, tree->oid.hash, 1,
412 + fill_filespec(pair->one, &tree->oid, 1,
413 tree->ce_mode);
414 return;
415 }
diff-no-index.c
+1 -1
@@ -82,7 +82,7 @@ static struct diff_filespec *noindex_filespec(const char *name, int mode)
82 if (!name)
83 name = "/dev/null";
84 s = alloc_filespec(name);
85 - fill_filespec(s, null_sha1, 0, mode);
85 + fill_filespec(s, &null_oid, 0, mode);
86 if (name == file_from_standard_input)
87 populate_from_stdin(s);
88 return s;
diff.c
+8 -8
@@ -2702,13 +2702,13 @@ void free_filespec(struct diff_filespec *spec)
2702 }
2703 }
2704
2705 -void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
2706 - int sha1_valid, unsigned short mode)
2705 +void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,
2706 + int oid_valid, unsigned short mode)
2707 {
2708 if (mode) {
2709 spec->mode = canon_mode(mode);
2710 - hashcpy(spec->oid.hash, sha1);
2711 - spec->oid_valid = sha1_valid;
2710 + oidcpy(&spec->oid, oid);
2711 + spec->oid_valid = oid_valid;
2712 }
2713 }
2714
@@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,
5114 two = alloc_filespec(concatpath);
5115
5116 if (addremove != '+')
5117 - fill_filespec(one, oid->hash, oid_valid, mode);
5117 + fill_filespec(one, oid, oid_valid, mode);
5118 if (addremove != '-') {
5119 - fill_filespec(two, oid->hash, oid_valid, mode);
5119 + fill_filespec(two, oid, oid_valid, mode);
5120 two->dirty_submodule = dirty_submodule;
5121 }
5122
@@ -5153,8 +5153,8 @@ void diff_change(struct diff_options *options,
5153
5154 one = alloc_filespec(concatpath);
5155 two = alloc_filespec(concatpath);
5156 - fill_filespec(one, old_oid->hash, old_oid_valid, old_mode);
5157 - fill_filespec(two, new_oid->hash, new_oid_valid, new_mode);
5156 + fill_filespec(one, old_oid, old_oid_valid, old_mode);
5157 + fill_filespec(two, new_oid, new_oid_valid, new_mode);
5158 one->dirty_submodule = old_dirty_submodule;
5159 two->dirty_submodule = new_dirty_submodule;
5160 p = diff_queue(&diff_queued_diff, one, two);
diffcore-rename.c
+1 -1
@@ -60,7 +60,7 @@ static int add_rename_dst(struct diff_filespec *two)
60 memmove(rename_dst + first + 1, rename_dst + first,
61 (rename_dst_nr - first - 1) * sizeof(*rename_dst));
62 rename_dst[first].two = alloc_filespec(two->path);
63 - fill_filespec(rename_dst[first].two, two->oid.hash, two->oid_valid,
63 + fill_filespec(rename_dst[first].two, &two->oid, two->oid_valid,
64 two->mode);
65 rename_dst[first].pair = NULL;
66 return 0;
diffcore.h
+1 -1
@@ -52,7 +52,7 @@ struct diff_filespec {
52
53 extern struct diff_filespec *alloc_filespec(const char *);
54 extern void free_filespec(struct diff_filespec *);
55 -extern void fill_filespec(struct diff_filespec *, const unsigned char *,
55 +extern void fill_filespec(struct diff_filespec *, const struct object_id *,
56 int, unsigned short);
57
58 #define CHECK_SIZE_ONLY 1
grep.c
+1 -1
@@ -1407,7 +1407,7 @@ static int fill_textconv_grep(struct userdiff_driver *driver,
1407 fill_filespec(df, gs->identifier, 1, 0100644);
1408 break;
1409 case GREP_SOURCE_FILE:
1410 - fill_filespec(df, null_sha1, 0, 0100644);
1410 + fill_filespec(df, &null_oid, 0, 0100644);
1411 break;
1412 default:
1413 die("BUG: attempt to textconv something without a path?");
line-log.c
+3 -3
@@ -500,12 +500,12 @@ static struct commit *check_single_commit(struct rev_info *revs)
500 static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)
501 {
502 unsigned mode;
503 - unsigned char sha1[20];
503 + struct object_id oid;
504
505 if (get_tree_entry(commit->object.oid.hash, spec->path,
506 - sha1, &mode))
506 + oid.hash, &mode))
507 die("There is no path %s in the commit", spec->path);
508 - fill_filespec(spec, sha1, 1, mode);
508 + fill_filespec(spec, &oid, 1, mode);
509
510 return;
511 }