merge-recursive: convert struct stage_data to use object_id

Convert the anonymous struct within struct stage_data to use struct
object_id.  The following Coccinelle semantic patch was used to
implement this, followed by the transformations in object_id.cocci:

@@
struct stage_data o;
expression E1;
@@
- o.stages[E1].sha
+ o.stages[E1].oid.hash

@@
struct stage_data *p;
expression E1;
@@
- p->stages[E1].sha
+ p->stages[E1].oid.hash

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
brian m. carlson 2016-06-24 23:09:25 +00:00 committed by Junio C Hamano
parent 41c9560ee5
commit fd429e986d
1 changed files with 18 additions and 20 deletions

View File

@ -90,7 +90,7 @@ struct rename_conflict_info {
struct stage_data { struct stage_data {
struct { struct {
unsigned mode; unsigned mode;
unsigned char sha[20]; struct object_id oid;
} stages[4]; } stages[4];
struct rename_conflict_info *rename_conflict_info; struct rename_conflict_info *rename_conflict_info;
unsigned processed:1; unsigned processed:1;
@ -134,13 +134,11 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
int ostage2 = ostage1 ^ 1; int ostage2 = ostage1 ^ 1;


ci->ren1_other.path = pair1->one->path; ci->ren1_other.path = pair1->one->path;
hashcpy(ci->ren1_other.oid.hash, oidcpy(&ci->ren1_other.oid, &src_entry1->stages[ostage1].oid);
src_entry1->stages[ostage1].sha);
ci->ren1_other.mode = src_entry1->stages[ostage1].mode; ci->ren1_other.mode = src_entry1->stages[ostage1].mode;


ci->ren2_other.path = pair2->one->path; ci->ren2_other.path = pair2->one->path;
hashcpy(ci->ren2_other.oid.hash, oidcpy(&ci->ren2_other.oid, &src_entry2->stages[ostage2].oid);
src_entry2->stages[ostage2].sha);
ci->ren2_other.mode = src_entry2->stages[ostage2].mode; ci->ren2_other.mode = src_entry2->stages[ostage2].mode;
} }
} }
@ -316,11 +314,11 @@ static struct stage_data *insert_stage_data(const char *path,
struct string_list_item *item; struct string_list_item *item;
struct stage_data *e = xcalloc(1, sizeof(struct stage_data)); struct stage_data *e = xcalloc(1, sizeof(struct stage_data));
get_tree_entry(o->object.oid.hash, path, get_tree_entry(o->object.oid.hash, path,
e->stages[1].sha, &e->stages[1].mode); e->stages[1].oid.hash, &e->stages[1].mode);
get_tree_entry(a->object.oid.hash, path, get_tree_entry(a->object.oid.hash, path,
e->stages[2].sha, &e->stages[2].mode); e->stages[2].oid.hash, &e->stages[2].mode);
get_tree_entry(b->object.oid.hash, path, get_tree_entry(b->object.oid.hash, path,
e->stages[3].sha, &e->stages[3].mode); e->stages[3].oid.hash, &e->stages[3].mode);
item = string_list_insert(entries, path); item = string_list_insert(entries, path);
item->util = e; item->util = e;
return e; return e;
@ -351,7 +349,7 @@ static struct string_list *get_unmerged(void)
} }
e = item->util; e = item->util;
e->stages[ce_stage(ce)].mode = ce->ce_mode; e->stages[ce_stage(ce)].mode = ce->ce_mode;
hashcpy(e->stages[ce_stage(ce)].sha, ce->sha1); hashcpy(e->stages[ce_stage(ce)].oid.hash, ce->sha1);
} }


return unmerged; return unmerged;
@ -574,9 +572,9 @@ static void update_entry(struct stage_data *entry,
entry->stages[1].mode = o->mode; entry->stages[1].mode = o->mode;
entry->stages[2].mode = a->mode; entry->stages[2].mode = a->mode;
entry->stages[3].mode = b->mode; entry->stages[3].mode = b->mode;
hashcpy(entry->stages[1].sha, o->oid.hash); oidcpy(&entry->stages[1].oid, &o->oid);
hashcpy(entry->stages[2].sha, a->oid.hash); oidcpy(&entry->stages[2].oid, &a->oid);
hashcpy(entry->stages[3].sha, b->oid.hash); oidcpy(&entry->stages[3].oid, &b->oid);
} }


static int remove_file(struct merge_options *o, int clean, static int remove_file(struct merge_options *o, int clean,
@ -1111,7 +1109,7 @@ static struct diff_filespec *filespec_from_entry(struct diff_filespec *target,
struct stage_data *entry, struct stage_data *entry,
int stage) int stage)
{ {
unsigned char *sha = entry->stages[stage].sha; unsigned char *sha = entry->stages[stage].oid.hash;
unsigned mode = entry->stages[stage].mode; unsigned mode = entry->stages[stage].mode;
if (mode == 0 || is_null_sha1(sha)) if (mode == 0 || is_null_sha1(sha))
return NULL; return NULL;
@ -1425,11 +1423,11 @@ static int process_renames(struct merge_options *o,
remove_file(o, 1, ren1_src, remove_file(o, 1, ren1_src,
renamed_stage == 2 || !was_tracked(ren1_src)); renamed_stage == 2 || !was_tracked(ren1_src));


hashcpy(src_other.oid.hash, oidcpy(&src_other.oid,
ren1->src_entry->stages[other_stage].sha); &ren1->src_entry->stages[other_stage].oid);
src_other.mode = ren1->src_entry->stages[other_stage].mode; src_other.mode = ren1->src_entry->stages[other_stage].mode;
hashcpy(dst_other.oid.hash, oidcpy(&dst_other.oid,
ren1->dst_entry->stages[other_stage].sha); &ren1->dst_entry->stages[other_stage].oid);
dst_other.mode = ren1->dst_entry->stages[other_stage].mode; dst_other.mode = ren1->dst_entry->stages[other_stage].mode;
try_merge = 0; try_merge = 0;


@ -1703,9 +1701,9 @@ static int process_entry(struct merge_options *o,
unsigned o_mode = entry->stages[1].mode; unsigned o_mode = entry->stages[1].mode;
unsigned a_mode = entry->stages[2].mode; unsigned a_mode = entry->stages[2].mode;
unsigned b_mode = entry->stages[3].mode; unsigned b_mode = entry->stages[3].mode;
unsigned char *o_sha = stage_sha(entry->stages[1].sha, o_mode); unsigned char *o_sha = stage_sha(entry->stages[1].oid.hash, o_mode);
unsigned char *a_sha = stage_sha(entry->stages[2].sha, a_mode); unsigned char *a_sha = stage_sha(entry->stages[2].oid.hash, a_mode);
unsigned char *b_sha = stage_sha(entry->stages[3].sha, b_mode); unsigned char *b_sha = stage_sha(entry->stages[3].oid.hash, b_mode);


entry->processed = 1; entry->processed = 1;
if (entry->rename_conflict_info) { if (entry->rename_conflict_info) {