Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
merge-recursive: convert struct stage_data to use object_id
author
brian m. carlson
<sandals@crustytoothpaste.net>
Fri, 24 Jun 2016 23:09:25 +0000
(23:09 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 28 Jun 2016 18:39:02 +0000
(11:39 -0700)
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>
merge-recursive.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
41c9560
)
diff --git
a/merge-recursive.c
b/merge-recursive.c
index 1e802097c3cbf0f38fb8f0e243520b7250b6c3ca..a07050cd1fbe75576e621d78a8285fef68d5f2fe 100644
(file)
--- a/
merge-recursive.c
+++ b/
merge-recursive.c
@@
-90,7
+90,7
@@
struct rename_conflict_info {
struct stage_data {
struct {
unsigned mode;
struct stage_data {
struct {
unsigned mode;
-
unsigned char sha[20]
;
+
struct object_id oid
;
} stages[4];
struct rename_conflict_info *rename_conflict_info;
unsigned processed:1;
} stages[4];
struct rename_conflict_info *rename_conflict_info;
unsigned processed:1;
@@
-134,13
+134,11
@@
static inline void setup_rename_conflict_info(enum rename_type rename_type,
int ostage2 = ostage1 ^ 1;
ci->ren1_other.path = pair1->one->path;
int ostage2 = ostage1 ^ 1;
ci->ren1_other.path = pair1->one->path;
- hashcpy(ci->ren1_other.oid.hash,
- src_entry1->stages[ostage1].sha);
+ oidcpy(&ci->ren1_other.oid, &src_entry1->stages[ostage1].oid);
ci->ren1_other.mode = src_entry1->stages[ostage1].mode;
ci->ren2_other.path = pair2->one->path;
ci->ren1_other.mode = src_entry1->stages[ostage1].mode;
ci->ren2_other.path = pair2->one->path;
- hashcpy(ci->ren2_other.oid.hash,
- src_entry2->stages[ostage2].sha);
+ oidcpy(&ci->ren2_other.oid, &src_entry2->stages[ostage2].oid);
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 stage_data *e = xcalloc(1, sizeof(struct stage_data));
get_tree_entry(o->object.oid.hash, path,
struct string_list_item *item;
struct stage_data *e = xcalloc(1, sizeof(struct stage_data));
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->util = e;
return e;
item = string_list_insert(entries, path);
item->util = e;
return e;
@@
-351,7
+349,7
@@
static struct string_list *get_unmerged(void)
}
e = item->util;
e->stages[ce_stage(ce)].mode = ce->ce_mode;
}
e = item->util;
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[2].mode = a->mode;
entry->stages[3].mode = b->mode;
entry->stages[1].mode = o->mode;
entry->stages[2].mode = a->mode;
entry->stages[3].mode = b->mode;
-
hashcpy(entry->stages[1].sha, o->oid.hash
);
-
hashcpy(entry->stages[2].sha, a->oid.hash
);
-
hashcpy(entry->stages[3].sha, b->oid.hash
);
+
oidcpy(&entry->stages[1].oid, &o->oid
);
+
oidcpy(&entry->stages[2].oid, &a->oid
);
+
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,
int stage)
{
struct stage_data *entry,
int stage)
{
- unsigned char *sha = entry->stages[stage].
sha
;
+ unsigned char *sha = entry->stages[stage].
oid.hash
;
unsigned mode = entry->stages[stage].mode;
if (mode == 0 || is_null_sha1(sha))
return NULL;
unsigned mode = entry->stages[stage].mode;
if (mode == 0 || is_null_sha1(sha))
return NULL;
@@
-1425,11
+1423,11
@@
static int process_renames(struct merge_options *o,
remove_file(o, 1, ren1_src,
renamed_stage == 2 || !was_tracked(ren1_src));
remove_file(o, 1, ren1_src,
renamed_stage == 2 || !was_tracked(ren1_src));
-
hashcpy(src_other.oid.hash
,
-
ren1->src_entry->stages[other_stage].sha
);
+
oidcpy(&src_other.oid
,
+
&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
,
-
ren1->dst_entry->stages[other_stage].sha
);
+
oidcpy(&dst_other.oid
,
+
&ren1->dst_entry->stages[other_stage].oid
);
dst_other.mode = ren1->dst_entry->stages[other_stage].mode;
try_merge = 0;
dst_other.mode = ren1->dst_entry->stages[other_stage].mode;
try_merge = 0;
@@
-1703,9
+1701,9
@@
static int process_entry(struct merge_options *o,
unsigned o_mode = entry->stages[1].mode;
unsigned a_mode = entry->stages[2].mode;
unsigned b_mode = entry->stages[3].mode;
unsigned o_mode = entry->stages[1].mode;
unsigned a_mode = entry->stages[2].mode;
unsigned b_mode = entry->stages[3].mode;
- unsigned char *o_sha = stage_sha(entry->stages[1].
sha
, o_mode);
- unsigned char *a_sha = stage_sha(entry->stages[2].
sha
, a_mode);
- unsigned char *b_sha = stage_sha(entry->stages[3].
sha
, b_mode);
+ unsigned char *o_sha = stage_sha(entry->stages[1].
oid.hash
, o_mode);
+ unsigned char *a_sha = stage_sha(entry->stages[2].
oid.hash
, a_mode);
+ unsigned char *b_sha = stage_sha(entry->stages[3].
oid.hash
, b_mode);
entry->processed = 1;
if (entry->rename_conflict_info) {
entry->processed = 1;
if (entry->rename_conflict_info) {