Skip to content

Commit eccb5a5

Browse files
bk2204gitster
authored andcommitted
apply: rename new_sha1_prefix and old_sha1_prefix
Rename these structure members to "new_oid_prefix" and "old_oid_prefix". Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 93eb00f commit eccb5a5

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

apply.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ struct patch {
223223
struct fragment *fragments;
224224
char *result;
225225
size_t resultsize;
226-
char old_sha1_prefix[GIT_MAX_HEXSZ + 1];
227-
char new_sha1_prefix[GIT_MAX_HEXSZ + 1];
226+
char old_oid_prefix[GIT_MAX_HEXSZ + 1];
227+
char new_oid_prefix[GIT_MAX_HEXSZ + 1];
228228
struct patch *next;
229229

230230
/* three-way fallback result */
@@ -1099,8 +1099,8 @@ static int gitdiff_index(struct apply_state *state,
10991099
if (!ptr || ptr[1] != '.' || hexsz < ptr - line)
11001100
return 0;
11011101
len = ptr - line;
1102-
memcpy(patch->old_sha1_prefix, line, len);
1103-
patch->old_sha1_prefix[len] = 0;
1102+
memcpy(patch->old_oid_prefix, line, len);
1103+
patch->old_oid_prefix[len] = 0;
11041104

11051105
line = ptr + 2;
11061106
ptr = strchr(line, ' ');
@@ -1112,8 +1112,8 @@ static int gitdiff_index(struct apply_state *state,
11121112

11131113
if (hexsz < len)
11141114
return 0;
1115-
memcpy(patch->new_sha1_prefix, line, len);
1116-
patch->new_sha1_prefix[len] = 0;
1115+
memcpy(patch->new_oid_prefix, line, len);
1116+
patch->new_oid_prefix[len] = 0;
11171117
if (*ptr == ' ')
11181118
return gitdiff_oldmode(state, ptr + 1, patch);
11191119
return 0;
@@ -2205,7 +2205,7 @@ static void reverse_patches(struct patch *p)
22052205
SWAP(p->new_mode, p->old_mode);
22062206
SWAP(p->is_new, p->is_delete);
22072207
SWAP(p->lines_added, p->lines_deleted);
2208-
SWAP(p->old_sha1_prefix, p->new_sha1_prefix);
2208+
SWAP(p->old_oid_prefix, p->new_oid_prefix);
22092209

22102210
for (; frag; frag = frag->next) {
22112211
SWAP(frag->newpos, frag->oldpos);
@@ -3149,10 +3149,10 @@ static int apply_binary(struct apply_state *state,
31493149
* For safety, we require patch index line to contain
31503150
* full hex textual object ID for old and new, at least for now.
31513151
*/
3152-
if (strlen(patch->old_sha1_prefix) != hexsz ||
3153-
strlen(patch->new_sha1_prefix) != hexsz ||
3154-
get_oid_hex(patch->old_sha1_prefix, &oid) ||
3155-
get_oid_hex(patch->new_sha1_prefix, &oid))
3152+
if (strlen(patch->old_oid_prefix) != hexsz ||
3153+
strlen(patch->new_oid_prefix) != hexsz ||
3154+
get_oid_hex(patch->old_oid_prefix, &oid) ||
3155+
get_oid_hex(patch->new_oid_prefix, &oid))
31563156
return error(_("cannot apply binary patch to '%s' "
31573157
"without full index line"), name);
31583158

@@ -3162,7 +3162,7 @@ static int apply_binary(struct apply_state *state,
31623162
* applies to.
31633163
*/
31643164
hash_object_file(img->buf, img->len, blob_type, &oid);
3165-
if (strcmp(oid_to_hex(&oid), patch->old_sha1_prefix))
3165+
if (strcmp(oid_to_hex(&oid), patch->old_oid_prefix))
31663166
return error(_("the patch applies to '%s' (%s), "
31673167
"which does not match the "
31683168
"current contents."),
@@ -3175,7 +3175,7 @@ static int apply_binary(struct apply_state *state,
31753175
"'%s' but it is not empty"), name);
31763176
}
31773177

3178-
get_oid_hex(patch->new_sha1_prefix, &oid);
3178+
get_oid_hex(patch->new_oid_prefix, &oid);
31793179
if (is_null_oid(&oid)) {
31803180
clear_image(img);
31813181
return 0; /* deletion patch */
@@ -3191,7 +3191,7 @@ static int apply_binary(struct apply_state *state,
31913191
if (!result)
31923192
return error(_("the necessary postimage %s for "
31933193
"'%s' cannot be read"),
3194-
patch->new_sha1_prefix, name);
3194+
patch->new_oid_prefix, name);
31953195
clear_image(img);
31963196
img->buf = result;
31973197
img->len = size;
@@ -3207,9 +3207,9 @@ static int apply_binary(struct apply_state *state,
32073207

32083208
/* verify that the result matches */
32093209
hash_object_file(img->buf, img->len, blob_type, &oid);
3210-
if (strcmp(oid_to_hex(&oid), patch->new_sha1_prefix))
3210+
if (strcmp(oid_to_hex(&oid), patch->new_oid_prefix))
32113211
return error(_("binary patch to '%s' creates incorrect result (expecting %s, got %s)"),
3212-
name, patch->new_sha1_prefix, oid_to_hex(&oid));
3212+
name, patch->new_oid_prefix, oid_to_hex(&oid));
32133213
}
32143214

32153215
return 0;
@@ -3565,7 +3565,7 @@ static int try_threeway(struct apply_state *state,
35653565
/* Preimage the patch was prepared for */
35663566
if (patch->is_new)
35673567
write_object_file("", 0, blob_type, &pre_oid);
3568-
else if (get_oid(patch->old_sha1_prefix, &pre_oid) ||
3568+
else if (get_oid(patch->old_oid_prefix, &pre_oid) ||
35693569
read_blob_object(&buf, &pre_oid, patch->old_mode))
35703570
return error(_("repository lacks the necessary blob to fall back on 3-way merge."));
35713571

@@ -4059,11 +4059,11 @@ static int preimage_oid_in_gitlink_patch(struct patch *p, struct object_id *oid)
40594059
!get_oid_hex(preimage + sizeof(heading) - 1, oid) &&
40604060
preimage[sizeof(heading) + the_hash_algo->hexsz - 1] == '\n' &&
40614061
/* does the abbreviated name on the index line agree with it? */
4062-
starts_with(preimage + sizeof(heading) - 1, p->old_sha1_prefix))
4062+
starts_with(preimage + sizeof(heading) - 1, p->old_oid_prefix))
40634063
return 0; /* it all looks fine */
40644064

40654065
/* we may have full object name on the index line */
4066-
return get_oid_hex(p->old_sha1_prefix, oid);
4066+
return get_oid_hex(p->old_oid_prefix, oid);
40674067
}
40684068

40694069
/* Build an index that contains just the files needed for a 3way merge */
@@ -4092,7 +4092,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
40924092
else
40934093
return error(_("sha1 information is lacking or "
40944094
"useless for submodule %s"), name);
4095-
} else if (!get_oid_blob(patch->old_sha1_prefix, &oid)) {
4095+
} else if (!get_oid_blob(patch->old_oid_prefix, &oid)) {
40964096
; /* ok */
40974097
} else if (!patch->lines_added && !patch->lines_deleted) {
40984098
/* mode-only change: update the current */

0 commit comments

Comments
 (0)