diff: rename struct diff_filespec's sha1_valid member

Now that this struct's sha1 member is called "oid", update the comment and the sha1_valid member to be called "oid_valid" instead. The following Coccinelle semantic patch was used to implement this, followed by the transformations in object_id.cocci: @@ struct diff_filespec o; @@ - o.sha1_valid + o.oid_valid @@ struct diff_filespec *p; @@ - p->sha1_valid + p->oid_valid Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Jun 24, 2016 at 23:09 UTC 41c9560ee5f9fc4bd3c6580272bd292083a9fe18
6 files changed +25 -25
combine-diff.c
+2 -2
@@ -1269,7 +1269,7 @@ static struct diff_filepair *combined_pair(struct combine_diff_path *p,
1269 pair->one[i].path = p->path;
1270 pair->one[i].mode = p->parent[i].mode;
1271 oidcpy(&pair->one[i].oid, &p->parent[i].oid);
1272 - pair->one[i].sha1_valid = !is_null_oid(&p->parent[i].oid);
1272 + pair->one[i].oid_valid = !is_null_oid(&p->parent[i].oid);
1273 pair->one[i].has_more_entries = 1;
1274 }
1275 pair->one[num_parent - 1].has_more_entries = 0;
@@ -1277,7 +1277,7 @@ static struct diff_filepair *combined_pair(struct combine_diff_path *p,
1277 pair->two->path = p->path;
1278 pair->two->mode = p->mode;
1279 oidcpy(&pair->two->oid, &p->oid);
1280 - pair->two->sha1_valid = !is_null_oid(&p->oid);
1280 + pair->two->oid_valid = !is_null_oid(&p->oid);
1281 return pair;
1282 }
1283
diff.c
+14 -14
@@ -1933,7 +1933,7 @@ static void show_dirstat(struct diff_options *options)
1933
1934 name = p->two->path ? p->two->path : p->one->path;
1935
1936 - if (p->one->sha1_valid && p->two->sha1_valid)
1936 + if (p->one->oid_valid && p->two->oid_valid)
1937 content_changed = oidcmp(&p->one->oid, &p->two->oid);
1938 else
1939 content_changed = 1;
@@ -2640,7 +2640,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
2640 if (mode) {
2641 spec->mode = canon_mode(mode);
2642 hashcpy(spec->oid.hash, sha1);
2643 - spec->sha1_valid = sha1_valid;
2643 + spec->oid_valid = sha1_valid;
2644 }
2645 }
2646
@@ -2766,7 +2766,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
2766 if (S_ISGITLINK(s->mode))
2767 return diff_populate_gitlink(s, size_only);
2768
2769 - if (!s->sha1_valid ||
2769 + if (!s->oid_valid ||
2770 reuse_worktree_file(s->path, s->oid.hash, 0)) {
2771 struct strbuf buf = STRBUF_INIT;
2772 struct stat st;
@@ -2915,7 +2915,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
2915 }
2916
2917 if (!S_ISGITLINK(one->mode) &&
2918 - (!one->sha1_valid ||
2918 + (!one->oid_valid ||
2919 reuse_worktree_file(name, one->oid.hash, 1))) {
2920 struct stat st;
2921 if (lstat(name, &st) < 0) {
@@ -2928,16 +2928,16 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
2928 if (strbuf_readlink(&sb, name, st.st_size) < 0)
2929 die_errno("readlink(%s)", name);
2930 prep_temp_blob(name, temp, sb.buf, sb.len,
2931 - (one->sha1_valid ?
2931 + (one->oid_valid ?
2932 one->oid.hash : null_sha1),
2933 - (one->sha1_valid ?
2933 + (one->oid_valid ?
2934 one->mode : S_IFLNK));
2935 strbuf_release(&sb);
2936 }
2937 else {
2938 /* we can borrow from the file in the work tree */
2939 temp->name = name;
2940 - if (!one->sha1_valid)
2940 + if (!one->oid_valid)
2941 sha1_to_hex_r(temp->hex, null_sha1);
2942 else
2943 sha1_to_hex_r(temp->hex, one->oid.hash);
@@ -3134,7 +3134,7 @@ static void run_diff_cmd(const char *pgm,
3134 static void diff_fill_sha1_info(struct diff_filespec *one)
3135 {
3136 if (DIFF_FILE_VALID(one)) {
3137 - if (!one->sha1_valid) {
3137 + if (!one->oid_valid) {
3138 struct stat st;
3139 if (one->is_stdin) {
3140 oidclr(&one->oid);
@@ -4172,11 +4172,11 @@ int diff_unmodified_pair(struct diff_filepair *p)
4172 /* both are valid and point at the same path. that is, we are
4173 * dealing with a change.
4174 */
4175 - if (one->sha1_valid && two->sha1_valid &&
4175 + if (one->oid_valid && two->oid_valid &&
4176 !oidcmp(&one->oid, &two->oid) &&
4177 !one->dirty_submodule && !two->dirty_submodule)
4178 return 1; /* no change */
4179 - if (!one->sha1_valid && !two->sha1_valid)
4179 + if (!one->oid_valid && !two->oid_valid)
4180 return 1; /* both look at the same file on the filesystem. */
4181 return 0;
4182 }
@@ -4237,7 +4237,7 @@ void diff_debug_filespec(struct diff_filespec *s, int x, const char *one)
4237 s->path,
4238 DIFF_FILE_VALID(s) ? "valid" : "invalid",
4239 s->mode,
4240 - s->sha1_valid ? oid_to_hex(&s->oid) : "");
4240 + s->oid_valid ? oid_to_hex(&s->oid) : "");
4241 fprintf(stderr, "queue[%d] %s size %lu\n",
4242 x, one ? one : "",
4243 s->size);
@@ -4822,7 +4822,7 @@ static int diff_filespec_check_stat_unmatch(struct diff_filepair *p)
4822 */
4823 if (!DIFF_FILE_VALID(p->one) || /* (1) */
4824 !DIFF_FILE_VALID(p->two) ||
4825 - (p->one->sha1_valid && p->two->sha1_valid) ||
4825 + (p->one->oid_valid && p->two->oid_valid) ||
4826 (p->one->mode != p->two->mode) ||
4827 diff_populate_filespec(p->one, CHECK_SIZE_ONLY) ||
4828 diff_populate_filespec(p->two, CHECK_SIZE_ONLY) ||
@@ -5118,7 +5118,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
5118 if (!driver->textconv)
5119 die("BUG: fill_textconv called with non-textconv driver");
5120
5121 - if (driver->textconv_cache && df->sha1_valid) {
5121 + if (driver->textconv_cache && df->oid_valid) {
5122 *outbuf = notes_cache_get(driver->textconv_cache,
5123 df->oid.hash,
5124 &size);
@@ -5130,7 +5130,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
5130 if (!*outbuf)
5131 die("unable to read files to diff");
5132
5133 - if (driver->textconv_cache && df->sha1_valid) {
5133 + if (driver->textconv_cache && df->oid_valid) {
5134 /* ignore errors, as we might be in a readonly repository */
5135 notes_cache_put(driver->textconv_cache, df->oid.hash, *outbuf,
5136 size);
diffcore-break.c
+1 -1
@@ -57,7 +57,7 @@ static int should_break(struct diff_filespec *src,
57 return 1; /* even their types are different */
58 }
59
60 - if (src->sha1_valid && dst->sha1_valid &&
60 + if (src->oid_valid && dst->oid_valid &&
61 !oidcmp(&src->oid, &dst->oid))
62 return 0; /* they are the same */
63
diffcore-rename.c
+2 -2
@@ -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->sha1_valid,
63 + fill_filespec(rename_dst[first].two, two->oid.hash, two->oid_valid,
64 two->mode);
65 rename_dst[first].pair = NULL;
66 return 0;
@@ -261,7 +261,7 @@ struct file_similarity {
261
262 static unsigned int hash_filespec(struct diff_filespec *filespec)
263 {
264 - if (!filespec->sha1_valid) {
264 + if (!filespec->oid_valid) {
265 if (diff_populate_filespec(filespec, 0))
266 return 0;
267 hash_sha1_file(filespec->data, filespec->size, "blob",
diffcore.h
+1 -1
@@ -33,7 +33,7 @@ struct diff_filespec {
33 int count; /* Reference count */
34 int rename_used; /* Count of rename users */
35 unsigned short mode; /* file mode */
36 - unsigned sha1_valid : 1; /* if true, use sha1 and trust mode;
36 + unsigned oid_valid : 1; /* if true, use oid and trust mode;
37 * if false, use the name and read from
38 * the filesystem.
39 */
line-log.c
+5 -5
@@ -894,14 +894,14 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang
894 if (!pair || !diff)
895 return;
896
897 - if (pair->one->sha1_valid)
897 + if (pair->one->oid_valid)
898 fill_line_ends(pair->one, &p_lines, &p_ends);
899 fill_line_ends(pair->two, &t_lines, &t_ends);
900
901 printf("%s%sdiff --git a/%s b/%s%s\n", prefix, c_meta, pair->one->path, pair->two->path, c_reset);
902 printf("%s%s--- %s%s%s\n", prefix, c_meta,
903 - pair->one->sha1_valid ? "a/" : "",
904 - pair->one->sha1_valid ? pair->one->path : "/dev/null",
903 + pair->one->oid_valid ? "a/" : "",
904 + pair->one->oid_valid ? pair->one->path : "/dev/null",
905 c_reset);
906 printf("%s%s+++ b/%s%s\n", prefix, c_meta, pair->two->path, c_reset);
907 for (i = 0; i < range->ranges.nr; i++) {
@@ -1011,12 +1011,12 @@ static int process_diff_filepair(struct rev_info *rev,
1011 if (rg->ranges.nr == 0)
1012 return 0;
1013
1014 - assert(pair->two->sha1_valid);
1014 + assert(pair->two->oid_valid);
1015 diff_populate_filespec(pair->two, 0);
1016 file_target.ptr = pair->two->data;
1017 file_target.size = pair->two->size;
1018
1019 - if (pair->one->sha1_valid) {
1019 + if (pair->one->oid_valid) {
1020 diff_populate_filespec(pair->one, 0);
1021 file_parent.ptr = pair->one->data;
1022 file_parent.size = pair->one->size;