Skip to content

Commit 41c9560

Browse files
bk2204gitster
authored andcommitted
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>
1 parent a0d12c4 commit 41c9560

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

combine-diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,15 +1269,15 @@ static struct diff_filepair *combined_pair(struct combine_diff_path *p,
12691269
pair->one[i].path = p->path;
12701270
pair->one[i].mode = p->parent[i].mode;
12711271
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);
12731273
pair->one[i].has_more_entries = 1;
12741274
}
12751275
pair->one[num_parent - 1].has_more_entries = 0;
12761276

12771277
pair->two->path = p->path;
12781278
pair->two->mode = p->mode;
12791279
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);
12811281
return pair;
12821282
}
12831283

diff.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ static void show_dirstat(struct diff_options *options)
19331933

19341934
name = p->two->path ? p->two->path : p->one->path;
19351935

1936-
if (p->one->sha1_valid && p->two->sha1_valid)
1936+
if (p->one->oid_valid && p->two->oid_valid)
19371937
content_changed = oidcmp(&p->one->oid, &p->two->oid);
19381938
else
19391939
content_changed = 1;
@@ -2640,7 +2640,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
26402640
if (mode) {
26412641
spec->mode = canon_mode(mode);
26422642
hashcpy(spec->oid.hash, sha1);
2643-
spec->sha1_valid = sha1_valid;
2643+
spec->oid_valid = sha1_valid;
26442644
}
26452645
}
26462646

@@ -2766,7 +2766,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
27662766
if (S_ISGITLINK(s->mode))
27672767
return diff_populate_gitlink(s, size_only);
27682768

2769-
if (!s->sha1_valid ||
2769+
if (!s->oid_valid ||
27702770
reuse_worktree_file(s->path, s->oid.hash, 0)) {
27712771
struct strbuf buf = STRBUF_INIT;
27722772
struct stat st;
@@ -2915,7 +2915,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
29152915
}
29162916

29172917
if (!S_ISGITLINK(one->mode) &&
2918-
(!one->sha1_valid ||
2918+
(!one->oid_valid ||
29192919
reuse_worktree_file(name, one->oid.hash, 1))) {
29202920
struct stat st;
29212921
if (lstat(name, &st) < 0) {
@@ -2928,16 +2928,16 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
29282928
if (strbuf_readlink(&sb, name, st.st_size) < 0)
29292929
die_errno("readlink(%s)", name);
29302930
prep_temp_blob(name, temp, sb.buf, sb.len,
2931-
(one->sha1_valid ?
2931+
(one->oid_valid ?
29322932
one->oid.hash : null_sha1),
2933-
(one->sha1_valid ?
2933+
(one->oid_valid ?
29342934
one->mode : S_IFLNK));
29352935
strbuf_release(&sb);
29362936
}
29372937
else {
29382938
/* we can borrow from the file in the work tree */
29392939
temp->name = name;
2940-
if (!one->sha1_valid)
2940+
if (!one->oid_valid)
29412941
sha1_to_hex_r(temp->hex, null_sha1);
29422942
else
29432943
sha1_to_hex_r(temp->hex, one->oid.hash);
@@ -3134,7 +3134,7 @@ static void run_diff_cmd(const char *pgm,
31343134
static void diff_fill_sha1_info(struct diff_filespec *one)
31353135
{
31363136
if (DIFF_FILE_VALID(one)) {
3137-
if (!one->sha1_valid) {
3137+
if (!one->oid_valid) {
31383138
struct stat st;
31393139
if (one->is_stdin) {
31403140
oidclr(&one->oid);
@@ -4172,11 +4172,11 @@ int diff_unmodified_pair(struct diff_filepair *p)
41724172
/* both are valid and point at the same path. that is, we are
41734173
* dealing with a change.
41744174
*/
4175-
if (one->sha1_valid && two->sha1_valid &&
4175+
if (one->oid_valid && two->oid_valid &&
41764176
!oidcmp(&one->oid, &two->oid) &&
41774177
!one->dirty_submodule && !two->dirty_submodule)
41784178
return 1; /* no change */
4179-
if (!one->sha1_valid && !two->sha1_valid)
4179+
if (!one->oid_valid && !two->oid_valid)
41804180
return 1; /* both look at the same file on the filesystem. */
41814181
return 0;
41824182
}
@@ -4237,7 +4237,7 @@ void diff_debug_filespec(struct diff_filespec *s, int x, const char *one)
42374237
s->path,
42384238
DIFF_FILE_VALID(s) ? "valid" : "invalid",
42394239
s->mode,
4240-
s->sha1_valid ? oid_to_hex(&s->oid) : "");
4240+
s->oid_valid ? oid_to_hex(&s->oid) : "");
42414241
fprintf(stderr, "queue[%d] %s size %lu\n",
42424242
x, one ? one : "",
42434243
s->size);
@@ -4822,7 +4822,7 @@ static int diff_filespec_check_stat_unmatch(struct diff_filepair *p)
48224822
*/
48234823
if (!DIFF_FILE_VALID(p->one) || /* (1) */
48244824
!DIFF_FILE_VALID(p->two) ||
4825-
(p->one->sha1_valid && p->two->sha1_valid) ||
4825+
(p->one->oid_valid && p->two->oid_valid) ||
48264826
(p->one->mode != p->two->mode) ||
48274827
diff_populate_filespec(p->one, CHECK_SIZE_ONLY) ||
48284828
diff_populate_filespec(p->two, CHECK_SIZE_ONLY) ||
@@ -5118,7 +5118,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
51185118
if (!driver->textconv)
51195119
die("BUG: fill_textconv called with non-textconv driver");
51205120

5121-
if (driver->textconv_cache && df->sha1_valid) {
5121+
if (driver->textconv_cache && df->oid_valid) {
51225122
*outbuf = notes_cache_get(driver->textconv_cache,
51235123
df->oid.hash,
51245124
&size);
@@ -5130,7 +5130,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
51305130
if (!*outbuf)
51315131
die("unable to read files to diff");
51325132

5133-
if (driver->textconv_cache && df->sha1_valid) {
5133+
if (driver->textconv_cache && df->oid_valid) {
51345134
/* ignore errors, as we might be in a readonly repository */
51355135
notes_cache_put(driver->textconv_cache, df->oid.hash, *outbuf,
51365136
size);

diffcore-break.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static int should_break(struct diff_filespec *src,
5757
return 1; /* even their types are different */
5858
}
5959

60-
if (src->sha1_valid && dst->sha1_valid &&
60+
if (src->oid_valid && dst->oid_valid &&
6161
!oidcmp(&src->oid, &dst->oid))
6262
return 0; /* they are the same */
6363

diffcore-rename.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static int add_rename_dst(struct diff_filespec *two)
6060
memmove(rename_dst + first + 1, rename_dst + first,
6161
(rename_dst_nr - first - 1) * sizeof(*rename_dst));
6262
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,
6464
two->mode);
6565
rename_dst[first].pair = NULL;
6666
return 0;
@@ -261,7 +261,7 @@ struct file_similarity {
261261

262262
static unsigned int hash_filespec(struct diff_filespec *filespec)
263263
{
264-
if (!filespec->sha1_valid) {
264+
if (!filespec->oid_valid) {
265265
if (diff_populate_filespec(filespec, 0))
266266
return 0;
267267
hash_sha1_file(filespec->data, filespec->size, "blob",

diffcore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct diff_filespec {
3333
int count; /* Reference count */
3434
int rename_used; /* Count of rename users */
3535
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;
3737
* if false, use the name and read from
3838
* the filesystem.
3939
*/

line-log.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -894,14 +894,14 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang
894894
if (!pair || !diff)
895895
return;
896896

897-
if (pair->one->sha1_valid)
897+
if (pair->one->oid_valid)
898898
fill_line_ends(pair->one, &p_lines, &p_ends);
899899
fill_line_ends(pair->two, &t_lines, &t_ends);
900900

901901
printf("%s%sdiff --git a/%s b/%s%s\n", prefix, c_meta, pair->one->path, pair->two->path, c_reset);
902902
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",
905905
c_reset);
906906
printf("%s%s+++ b/%s%s\n", prefix, c_meta, pair->two->path, c_reset);
907907
for (i = 0; i < range->ranges.nr; i++) {
@@ -1011,12 +1011,12 @@ static int process_diff_filepair(struct rev_info *rev,
10111011
if (rg->ranges.nr == 0)
10121012
return 0;
10131013

1014-
assert(pair->two->sha1_valid);
1014+
assert(pair->two->oid_valid);
10151015
diff_populate_filespec(pair->two, 0);
10161016
file_target.ptr = pair->two->data;
10171017
file_target.size = pair->two->size;
10181018

1019-
if (pair->one->sha1_valid) {
1019+
if (pair->one->oid_valid) {
10201020
diff_populate_filespec(pair->one, 0);
10211021
file_parent.ptr = pair->one->data;
10221022
file_parent.size = pair->one->size;

0 commit comments

Comments
 (0)