unsigned a_mode,
int renormalize, const char *path)
{
- struct strbuf o = STRBUF_INIT;
- struct strbuf a = STRBUF_INIT;
+ struct strbuf obuf = STRBUF_INIT;
+ struct strbuf abuf = STRBUF_INIT;
int ret = 0; /* assume changed for safety */
+ const struct index_state *idx = opt->repo->index;
if (a_mode != o_mode)
return 0;
return 0;
assert(o_oid && a_oid);
- if (read_oid_strbuf(opt, o_oid, &o) || read_oid_strbuf(opt, a_oid, &a))
+ if (read_oid_strbuf(opt, o_oid, &obuf) ||
+ read_oid_strbuf(opt, a_oid, &abuf))
goto error_return;
/*
* Note: binary | is used so that both renormalizations are
* performed. Comparison can be skipped if both files are
* unchanged since their sha1s have already been compared.
*/
- if (renormalize_buffer(opt->repo->index, path, o.buf, o.len, &o) |
- renormalize_buffer(opt->repo->index, path, a.buf, a.len, &a))
- ret = (o.len == a.len && !memcmp(o.buf, a.buf, o.len));
+ if (renormalize_buffer(idx, path, obuf.buf, obuf.len, &obuf) |
+ renormalize_buffer(idx, path, abuf.buf, abuf.len, &abuf))
+ ret = (obuf.len == abuf.len && !memcmp(obuf.buf, abuf.buf, obuf.len));
error_return:
- strbuf_release(&o);
- strbuf_release(&a);
+ strbuf_release(&obuf);
+ strbuf_release(&abuf);
return ret;
}
struct object_id *o_oid, int o_mode,
struct object_id *a_oid, int a_mode,
struct object_id *b_oid, int b_mode,
- struct rename_conflict_info *rename_conflict_info)
+ struct rename_conflict_info *ci)
{
const char *reason = _("content");
const char *path1 = NULL, *path2 = NULL;
oidcpy(&b.oid, b_oid);
b.mode = b_mode;
- if (rename_conflict_info) {
- struct diff_filepair *pair1 = rename_conflict_info->pair1;
+ if (ci) {
+ struct diff_filepair *pair1 = ci->pair1;
- path1 = (opt->branch1 == rename_conflict_info->branch1) ?
+ path1 = (opt->branch1 == ci->branch1) ?
pair1->two->path : pair1->one->path;
- /* If rename_conflict_info->pair2 != NULL, we are in
+ /* If ci->pair2 != NULL, we are in
* RENAME_ONE_FILE_TO_ONE case. Otherwise, we have a
* normal rename.
*/
- path2 = (rename_conflict_info->pair2 ||
- opt->branch2 == rename_conflict_info->branch1) ?
+ path2 = (ci->pair2 ||
+ opt->branch2 == ci->branch1) ?
pair1->two->path : pair1->one->path;
one.path = pair1->one->path;
a.path = (char *)path1;
reason = _("submodule");
output(opt, 1, _("CONFLICT (%s): Merge conflict in %s"),
reason, path);
- if (rename_conflict_info && !df_conflict_remains)
+ if (ci && !df_conflict_remains)
if (update_stages(opt, path, &one, &a, &b))
return -1;
}
}
}
- new_path = unique_path(opt, path, rename_conflict_info->branch1);
+ new_path = unique_path(opt, path, ci->branch1);
if (is_dirty) {
output(opt, 1, _("Refusing to lose dirty file at %s"),
path);
entry->processed = 1;
if (entry->rename_conflict_info) {
- struct rename_conflict_info *conflict_info = entry->rename_conflict_info;
- switch (conflict_info->rename_type) {
+ struct rename_conflict_info *ci = entry->rename_conflict_info;
+ switch (ci->rename_type) {
case RENAME_NORMAL:
case RENAME_ONE_FILE_TO_ONE:
clean_merge = handle_rename_normal(opt,
o_oid, o_mode,
a_oid, a_mode,
b_oid, b_mode,
- conflict_info);
+ ci);
break;
case RENAME_VIA_DIR:
clean_merge = 1;
- if (handle_rename_via_dir(opt,
- conflict_info->pair1,
- conflict_info->branch1))
+ if (handle_rename_via_dir(opt, ci->pair1, ci->branch1))
clean_merge = -1;
break;
case RENAME_ADD:
* two-way merged cleanly with the added file, I
* guess it's a clean merge?
*/
- clean_merge = handle_rename_add(opt, conflict_info);
+ clean_merge = handle_rename_add(opt, ci);
break;
case RENAME_DELETE:
clean_merge = 0;
- if (handle_rename_delete(opt,
- conflict_info->pair1,
- conflict_info->branch1,
- conflict_info->branch2))
+ if (handle_rename_delete(opt, ci->pair1,
+ ci->branch1, ci->branch2))
clean_merge = -1;
break;
case RENAME_ONE_FILE_TO_TWO:
clean_merge = 0;
- if (handle_rename_rename_1to2(opt, conflict_info))
+ if (handle_rename_rename_1to2(opt, ci))
clean_merge = -1;
break;
case RENAME_TWO_FILES_TO_ONE:
* can then be two-way merged cleanly, I guess it's
* a clean merge?
*/
- clean_merge = handle_rename_rename_2to1(opt,
- conflict_info);
+ clean_merge = handle_rename_rename_2to1(opt, ci);
break;
default:
entry->processed = 0;