merge-recursive: use 'ci' for rename_conflict_info variable name
[gitweb.git] / merge-recursive.c
index 09b76d596ecfe655eb65669aae09f27cc9f0064b..ea5646debde2fb8be1ae9c389a7e3b4c135682f4 100644 (file)
@@ -1050,7 +1050,7 @@ struct merge_file_info {
 
 static int merge_3way(struct merge_options *opt,
                      mmbuffer_t *result_buf,
-                     const struct diff_filespec *one,
+                     const struct diff_filespec *o,
                      const struct diff_filespec *a,
                      const struct diff_filespec *b,
                      const char *branch1,
@@ -1084,9 +1084,9 @@ static int merge_3way(struct merge_options *opt,
        }
 
        if (strcmp(a->path, b->path) ||
-           (opt->ancestor != NULL && strcmp(a->path, one->path) != 0)) {
+           (opt->ancestor != NULL && strcmp(a->path, o->path) != 0)) {
                base_name = opt->ancestor == NULL ? NULL :
-                       mkpathdup("%s:%s", opt->ancestor, one->path);
+                       mkpathdup("%s:%s", opt->ancestor, o->path);
                name1 = mkpathdup("%s:%s", branch1, a->path);
                name2 = mkpathdup("%s:%s", branch2, b->path);
        } else {
@@ -1096,7 +1096,7 @@ static int merge_3way(struct merge_options *opt,
                name2 = mkpathdup("%s", branch2);
        }
 
-       read_mmblob(&orig, &one->oid);
+       read_mmblob(&orig, &o->oid);
        read_mmblob(&src1, &a->oid);
        read_mmblob(&src2, &b->oid);
 
@@ -1295,7 +1295,7 @@ static int merge_submodule(struct merge_options *opt,
 }
 
 static int merge_mode_and_contents(struct merge_options *opt,
-                                  const struct diff_filespec *one,
+                                  const struct diff_filespec *o,
                                   const struct diff_filespec *a,
                                   const struct diff_filespec *b,
                                   const char *filename,
@@ -1310,7 +1310,7 @@ static int merge_mode_and_contents(struct merge_options *opt,
                 * side of the conflict markers and the other branch on the
                 * top.  Fix that.
                 */
-               return merge_mode_and_contents(opt, one, b, a,
+               return merge_mode_and_contents(opt, o, b, a,
                                               filename,
                                               branch2, branch1,
                                               extra_marker_size, result);
@@ -1329,31 +1329,31 @@ static int merge_mode_and_contents(struct merge_options *opt,
                        oidcpy(&result->oid, &b->oid);
                }
        } else {
-               if (!oid_eq(&a->oid, &one->oid) && !oid_eq(&b->oid, &one->oid))
+               if (!oid_eq(&a->oid, &o->oid) && !oid_eq(&b->oid, &o->oid))
                        result->merge = 1;
 
                /*
                 * Merge modes
                 */
-               if (a->mode == b->mode || a->mode == one->mode)
+               if (a->mode == b->mode || a->mode == o->mode)
                        result->mode = b->mode;
                else {
                        result->mode = a->mode;
-                       if (b->mode != one->mode) {
+                       if (b->mode != o->mode) {
                                result->clean = 0;
                                result->merge = 1;
                        }
                }
 
-               if (oid_eq(&a->oid, &b->oid) || oid_eq(&a->oid, &one->oid))
+               if (oid_eq(&a->oid, &b->oid) || oid_eq(&a->oid, &o->oid))
                        oidcpy(&result->oid, &b->oid);
-               else if (oid_eq(&b->oid, &one->oid))
+               else if (oid_eq(&b->oid, &o->oid))
                        oidcpy(&result->oid, &a->oid);
                else if (S_ISREG(a->mode)) {
                        mmbuffer_t result_buf;
                        int ret = 0, merge_status;
 
-                       merge_status = merge_3way(opt, &result_buf, one, a, b,
+                       merge_status = merge_3way(opt, &result_buf, o, a, b,
                                                  branch1, branch2,
                                                  extra_marker_size);
 
@@ -1372,8 +1372,8 @@ static int merge_mode_and_contents(struct merge_options *opt,
                        result->clean = (merge_status == 0);
                } else if (S_ISGITLINK(a->mode)) {
                        result->clean = merge_submodule(opt, &result->oid,
-                                                       one->path,
-                                                       &one->oid,
+                                                       o->path,
+                                                       &o->oid,
                                                        &a->oid,
                                                        &b->oid);
                } else if (S_ISLNK(a->mode)) {
@@ -1750,7 +1750,7 @@ static int handle_rename_rename_1to2(struct merge_options *opt,
        struct merge_file_info mfi;
        struct diff_filespec other;
        struct diff_filespec *add;
-       struct diff_filespec *one = ci->pair1->one;
+       struct diff_filespec *o = ci->pair1->one;
        struct diff_filespec *a = ci->pair1->two;
        struct diff_filespec *b = ci->pair2->two;
        char *path_desc;
@@ -1758,13 +1758,13 @@ static int handle_rename_rename_1to2(struct merge_options *opt,
        output(opt, 1, _("CONFLICT (rename/rename): "
               "Rename \"%s\"->\"%s\" in branch \"%s\" "
               "rename \"%s\"->\"%s\" in \"%s\"%s"),
-              one->path, a->path, ci->branch1,
-              one->path, b->path, ci->branch2,
+              o->path, a->path, ci->branch1,
+              o->path, b->path, ci->branch2,
               opt->call_depth ? _(" (left unresolved)") : "");
 
        path_desc = xstrfmt("%s and %s, both renamed from %s",
-                           a->path, b->path, one->path);
-       if (merge_mode_and_contents(opt, one, a, b, path_desc,
+                           a->path, b->path, o->path);
+       if (merge_mode_and_contents(opt, o, a, b, path_desc,
                                    ci->branch1, ci->branch2,
                                    opt->call_depth * 2, &mfi))
                return -1;
@@ -1777,7 +1777,7 @@ static int handle_rename_rename_1to2(struct merge_options *opt,
                 * pathname and then either rename the add-source file to that
                 * unique path, or use that unique path instead of src here.
                 */
-               if (update_file(opt, 0, &mfi.oid, mfi.mode, one->path))
+               if (update_file(opt, 0, &mfi.oid, mfi.mode, o->path))
                        return -1;
 
                /*
@@ -2863,10 +2863,10 @@ static int process_renames(struct merge_options *opt,
                        if (clean_merge < 0)
                                goto cleanup_and_return;
                        if (try_merge) {
-                               struct diff_filespec *one, *a, *b;
+                               struct diff_filespec *o, *a, *b;
                                src_other.path = (char *)ren1_src;
 
-                               one = ren1->pair->one;
+                               o = ren1->pair->one;
                                if (a_renames == renames1) {
                                        a = ren1->pair->two;
                                        b = &src_other;
@@ -2874,7 +2874,7 @@ static int process_renames(struct merge_options *opt,
                                        b = ren1->pair->two;
                                        a = &src_other;
                                }
-                               update_entry(ren1->dst_entry, one, a, b);
+                               update_entry(ren1->dst_entry, o, a, b);
                                setup_rename_conflict_info(RENAME_NORMAL,
                                                           ren1->pair,
                                                           NULL,
@@ -3031,9 +3031,10 @@ static int blob_unchanged(struct merge_options *opt,
                          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;
@@ -3043,20 +3044,21 @@ static int blob_unchanged(struct merge_options *opt,
                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;
 }
 
@@ -3096,7 +3098,7 @@ static int handle_content_merge(struct merge_options *opt,
                                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;
@@ -3116,17 +3118,17 @@ static int handle_content_merge(struct merge_options *opt,
        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;
@@ -3178,7 +3180,7 @@ static int handle_content_merge(struct merge_options *opt,
                        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;
        }
@@ -3204,7 +3206,7 @@ static int handle_content_merge(struct merge_options *opt,
                        }
 
                }
-               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);
@@ -3249,8 +3251,8 @@ static int process_entry(struct merge_options *opt,
 
        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,
@@ -3258,13 +3260,11 @@ static int process_entry(struct merge_options *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:
@@ -3274,19 +3274,17 @@ static int process_entry(struct merge_options *opt,
                         * 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:
@@ -3296,8 +3294,7 @@ static int process_entry(struct merge_options *opt,
                         * 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;