@matheusbsbs / matheus-bagliano / commits / 5a75361340
Fork 0

merge-recur: Convert variable names to lower_case

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Jul 27, 2006 at 19:12 UTC 5a753613406286962df514db21094afc99525989
1 file changed +189 -191
merge-recursive.c
+189 -191
@@ -122,8 +122,8 @@ struct stage_data
122 unsigned processed:1;
123 };
124
125 -static struct path_list currentFileSet = {NULL, 0, 0, 1};
126 -static struct path_list currentDirectorySet = {NULL, 0, 0, 1};
125 +static struct path_list current_file_set = {NULL, 0, 0, 1};
126 +static struct path_list current_directory_set = {NULL, 0, 0, 1};
127
128 static int output_indent = 0;
129
@@ -335,9 +335,9 @@ static int save_files_dirs(const unsigned char *sha1,
335 newpath[baselen + len] = '\0';
336
337 if (S_ISDIR(mode))
338 - path_list_insert(newpath, &currentDirectorySet);
338 + path_list_insert(newpath, &current_directory_set);
339 else
340 - path_list_insert(newpath, &currentFileSet);
340 + path_list_insert(newpath, &current_file_set);
341 free(newpath);
342
343 return READ_TREE_RECURSIVE;
@@ -351,7 +351,7 @@ static int get_files_dirs(struct tree *tree)
351 debug(" get_files_dirs done (0)\n");
352 return 0;
353 }
354 - n = currentFileSet.nr + currentDirectorySet.nr;
354 + n = current_file_set.nr + current_directory_set.nr;
355 debug(" get_files_dirs done (%d)\n", n);
356 return n;
357 }
@@ -378,7 +378,7 @@ static struct stage_data *insert_stage_data(const char *path,
378 }
379
380 /*
381 - * Create a dictionary mapping file names to CacheEntry objects. The
381 + * Create a dictionary mapping file names to stage_data objects. The
382 * dictionary contains one entry for every path with a non-zero stage entry.
383 */
384 static struct path_list *get_unmerged(void)
@@ -420,15 +420,15 @@ struct rename
420 };
421
422 /*
423 - * Get information of all renames which occured between 'oTree' and
424 - * 'tree'. We need the three trees in the merge ('oTree', 'aTree' and
425 - * 'bTree') to be able to associate the correct cache entries with
426 - * the rename information. 'tree' is always equal to either aTree or bTree.
423 + * Get information of all renames which occured between 'o_tree' and
424 + * 'tree'. We need the three trees in the merge ('o_tree', 'a_tree' and
425 + * 'b_tree') to be able to associate the correct cache entries with
426 + * the rename information. 'tree' is always equal to either a_tree or b_tree.
427 */
428 static struct path_list *get_renames(struct tree *tree,
429 - struct tree *oTree,
430 - struct tree *aTree,
431 - struct tree *bTree,
429 + struct tree *o_tree,
430 + struct tree *a_tree,
431 + struct tree *b_tree,
432 struct path_list *entries)
433 {
434 int i;
@@ -437,7 +437,7 @@ static struct path_list *get_renames(struct tree *tree,
437 #ifdef DEBUG
438 time_t t = time(0);
439
440 - debug("getRenames ...\n");
440 + debug("get_renames ...\n");
441 #endif
442
443 renames = xcalloc(1, sizeof(struct path_list));
@@ -447,7 +447,7 @@ static struct path_list *get_renames(struct tree *tree,
447 opts.output_format = DIFF_FORMAT_NO_OUTPUT;
448 if (diff_setup_done(&opts) < 0)
449 die("diff setup failed");
450 - diff_tree_sha1(oTree->object.sha1, tree->object.sha1, "", &opts);
450 + diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts);
451 diffcore_std(&opts);
452 for (i = 0; i < diff_queued_diff.nr; ++i) {
453 struct path_list_item *item;
@@ -463,14 +463,14 @@ static struct path_list *get_renames(struct tree *tree,
463 item = path_list_lookup(re->pair->one->path, entries);
464 if (!item)
465 re->src_entry = insert_stage_data(re->pair->one->path,
466 - oTree, aTree, bTree, entries);
466 + o_tree, a_tree, b_tree, entries);
467 else
468 re->src_entry = item->util;
469
470 item = path_list_lookup(re->pair->two->path, entries);
471 if (!item)
472 re->dst_entry = insert_stage_data(re->pair->two->path,
473 - oTree, aTree, bTree, entries);
473 + o_tree, a_tree, b_tree, entries);
474 else
475 re->dst_entry = item->util;
476 item = path_list_insert(pair->one->path, renames);
@@ -480,7 +480,7 @@ static struct path_list *get_renames(struct tree *tree,
480 diff_queued_diff.nr = 0;
481 diff_flush(&opts);
482 #ifdef DEBUG
483 - debug(" getRenames done in %ld\n", time(0)-t);
483 + debug(" get_renames done in %ld\n", time(0)-t);
484 #endif
485 return renames;
486 }
@@ -526,25 +526,23 @@ static int remove_path(const char *name)
526 return ret;
527 }
528
529 -/* General TODO: unC99ify the code: no declaration after code */
530 -/* General TODO: no javaIfiCation: rename updateCache to update_cache */
529 /*
530 * TODO: once we no longer call external programs, we'd probably be better off
531 * not setting / getting the environment variable GIT_INDEX_FILE all the time.
532 */
533 int remove_file(int clean, const char *path)
534 {
537 - int updateCache = index_only || clean;
538 - int updateWd = !index_only;
535 + int update_cache = index_only || clean;
536 + int update_working_directory = !index_only;
537
540 - if (updateCache) {
538 + if (update_cache) {
539 if (!cache_dirty)
540 read_cache_from(getenv("GIT_INDEX_FILE"));
541 cache_dirty++;
542 if (remove_file_from_cache(path))
543 return -1;
544 }
547 - if (updateWd)
545 + if (update_working_directory)
546 {
547 unlink(path);
548 if (errno != ENOENT || errno != EISDIR)
@@ -566,12 +564,12 @@ static char *unique_path(const char *path, const char *branch)
564 for (; *p; ++p)
565 if ('/' == *p)
566 *p = '_';
569 - while (path_list_has_path(&currentFileSet, newpath) ||
570 - path_list_has_path(&currentDirectorySet, newpath) ||
567 + while (path_list_has_path(&current_file_set, newpath) ||
568 + path_list_has_path(&current_directory_set, newpath) ||
569 lstat(newpath, &st) == 0)
570 sprintf(p, "_%d", suffix++);
571
574 - path_list_insert(newpath, &currentFileSet);
572 + path_list_insert(newpath, &current_file_set);
573 return newpath;
574 }
575
@@ -784,22 +782,22 @@ static void conflict_rename_rename(struct rename *ren1,
782 int delp = 0;
783 const char *ren1_dst = ren1->pair->two->path;
784 const char *ren2_dst = ren2->pair->two->path;
787 - const char *dstName1 = ren1_dst;
788 - const char *dstName2 = ren2_dst;
789 - if (path_list_has_path(&currentDirectorySet, ren1_dst)) {
790 - dstName1 = del[delp++] = unique_path(ren1_dst, branch1);
785 + const char *dst_name1 = ren1_dst;
786 + const char *dst_name2 = ren2_dst;
787 + if (path_list_has_path(&current_directory_set, ren1_dst)) {
788 + dst_name1 = del[delp++] = unique_path(ren1_dst, branch1);
789 output("%s is a directory in %s adding as %s instead",
792 - ren1_dst, branch2, dstName1);
790 + ren1_dst, branch2, dst_name1);
791 remove_file(0, ren1_dst);
792 }
795 - if (path_list_has_path(&currentDirectorySet, ren2_dst)) {
796 - dstName2 = del[delp++] = unique_path(ren2_dst, branch2);
793 + if (path_list_has_path(&current_directory_set, ren2_dst)) {
794 + dst_name2 = del[delp++] = unique_path(ren2_dst, branch2);
795 output("%s is a directory in %s adding as %s instead",
798 - ren2_dst, branch1, dstName2);
796 + ren2_dst, branch1, dst_name2);
797 remove_file(0, ren2_dst);
798 }
801 - update_stages(dstName1, NULL, ren1->pair->two, NULL, 1);
802 - update_stages(dstName2, NULL, NULL, ren2->pair->two, 1);
799 + update_stages(dst_name1, NULL, ren1->pair->two, NULL, 1);
800 + update_stages(dst_name2, NULL, NULL, ren2->pair->two, 1);
801 while (delp--)
802 free(del[delp]);
803 }
@@ -807,11 +805,11 @@ static void conflict_rename_rename(struct rename *ren1,
805 static void conflict_rename_dir(struct rename *ren1,
806 const char *branch1)
807 {
810 - char *newPath = unique_path(ren1->pair->two->path, branch1);
811 - output("Renaming %s to %s instead", ren1->pair->one->path, newPath);
808 + char *new_path = unique_path(ren1->pair->two->path, branch1);
809 + output("Renaming %s to %s instead", ren1->pair->one->path, new_path);
810 remove_file(0, ren1->pair->two->path);
813 - update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, newPath);
814 - free(newPath);
811 + update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, new_path);
812 + free(new_path);
813 }
814
815 static void conflict_rename_rename_2(struct rename *ren1,
@@ -819,74 +817,74 @@ static void conflict_rename_rename_2(struct rename *ren1,
817 struct rename *ren2,
818 const char *branch2)
819 {
822 - char *newPath1 = unique_path(ren1->pair->two->path, branch1);
823 - char *newPath2 = unique_path(ren2->pair->two->path, branch2);
820 + char *new_path1 = unique_path(ren1->pair->two->path, branch1);
821 + char *new_path2 = unique_path(ren2->pair->two->path, branch2);
822 output("Renaming %s to %s and %s to %s instead",
825 - ren1->pair->one->path, newPath1,
826 - ren2->pair->one->path, newPath2);
823 + ren1->pair->one->path, new_path1,
824 + ren2->pair->one->path, new_path2);
825 remove_file(0, ren1->pair->two->path);
828 - update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, newPath1);
829 - update_file(0, ren2->pair->two->sha1, ren2->pair->two->mode, newPath2);
830 - free(newPath2);
831 - free(newPath1);
826 + update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, new_path1);
827 + update_file(0, ren2->pair->two->sha1, ren2->pair->two->mode, new_path2);
828 + free(new_path2);
829 + free(new_path1);
830 }
831
832 /* General TODO: get rid of all the debug messages */
835 -static int process_renames(struct path_list *renamesA,
836 - struct path_list *renamesB,
837 - const char *branchNameA,
838 - const char *branchNameB)
833 +static int process_renames(struct path_list *a_renames,
834 + struct path_list *b_renames,
835 + const char *a_branch,
836 + const char *b_branch)
837 {
840 - int cleanMerge = 1, i, j;
841 - struct path_list byDstA = {NULL, 0, 0, 0}, byDstB = {NULL, 0, 0, 0};
838 + int clean_merge = 1, i, j;
839 + struct path_list a_by_dst = {NULL, 0, 0, 0}, b_by_dst = {NULL, 0, 0, 0};
840 const struct rename *sre;
841
844 - for (i = 0; i < renamesA->nr; i++) {
845 - sre = renamesA->items[i].util;
846 - path_list_insert(sre->pair->two->path, &byDstA)->util
842 + for (i = 0; i < a_renames->nr; i++) {
843 + sre = a_renames->items[i].util;
844 + path_list_insert(sre->pair->two->path, &a_by_dst)->util
845 = sre->dst_entry;
846 }
849 - for (i = 0; i < renamesB->nr; i++) {
850 - sre = renamesB->items[i].util;
851 - path_list_insert(sre->pair->two->path, &byDstB)->util
847 + for (i = 0; i < b_renames->nr; i++) {
848 + sre = b_renames->items[i].util;
849 + path_list_insert(sre->pair->two->path, &b_by_dst)->util
850 = sre->dst_entry;
851 }
852
855 - for (i = 0, j = 0; i < renamesA->nr || j < renamesB->nr;) {
853 + for (i = 0, j = 0; i < a_renames->nr || j < b_renames->nr;) {
854 int compare;
855 char *src;
856 struct path_list *renames1, *renames2, *renames2Dst;
857 struct rename *ren1 = NULL, *ren2 = NULL;
860 - const char *branchName1, *branchName2;
858 + const char *branch1, *branch2;
859 const char *ren1_src, *ren1_dst;
860
863 - if (i >= renamesA->nr) {
861 + if (i >= a_renames->nr) {
862 compare = 1;
865 - ren2 = renamesB->items[j++].util;
866 - } else if (j >= renamesB->nr) {
863 + ren2 = b_renames->items[j++].util;
864 + } else if (j >= b_renames->nr) {
865 compare = -1;
868 - ren1 = renamesA->items[i++].util;
866 + ren1 = a_renames->items[i++].util;
867 } else {
870 - compare = strcmp(renamesA->items[i].path,
871 - renamesB->items[j].path);
872 - ren1 = renamesA->items[i++].util;
873 - ren2 = renamesB->items[j++].util;
868 + compare = strcmp(a_renames->items[i].path,
869 + b_renames->items[j].path);
870 + ren1 = a_renames->items[i++].util;
871 + ren2 = b_renames->items[j++].util;
872 }
873
874 /* TODO: refactor, so that 1/2 are not needed */
875 if (ren1) {
878 - renames1 = renamesA;
879 - renames2 = renamesB;
880 - renames2Dst = &byDstB;
881 - branchName1 = branchNameA;
882 - branchName2 = branchNameB;
876 + renames1 = a_renames;
877 + renames2 = b_renames;
878 + renames2Dst = &b_by_dst;
879 + branch1 = a_branch;
880 + branch2 = b_branch;
881 } else {
882 struct rename *tmp;
885 - renames1 = renamesB;
886 - renames2 = renamesA;
887 - renames2Dst = &byDstA;
888 - branchName1 = branchNameB;
889 - branchName2 = branchNameA;
883 + renames1 = b_renames;
884 + renames2 = a_renames;
885 + renames2Dst = &a_by_dst;
886 + branch1 = b_branch;
887 + branch2 = a_branch;
888 tmp = ren2;
889 ren2 = ren1;
890 ren1 = tmp;
@@ -912,21 +910,21 @@ static int process_renames(struct path_list *renamesA,
910 ren2->dst_entry->processed = 1;
911 ren2->processed = 1;
912 if (strcmp(ren1_dst, ren2_dst) != 0) {
915 - cleanMerge = 0;
913 + clean_merge = 0;
914 output("CONFLICT (rename/rename): "
915 "Rename %s->%s in branch %s "
916 "rename %s->%s in %s",
919 - src, ren1_dst, branchName1,
920 - src, ren2_dst, branchName2);
921 - conflict_rename_rename(ren1, branchName1, ren2, branchName2);
917 + src, ren1_dst, branch1,
918 + src, ren2_dst, branch2);
919 + conflict_rename_rename(ren1, branch1, ren2, branch2);
920 } else {
923 - remove_file(1, ren1_src);
921 struct merge_file_info mfi;
922 + remove_file(1, ren1_src);
923 mfi = merge_file(ren1->pair->one,
924 ren1->pair->two,
925 ren2->pair->two,
928 - branchName1,
929 - branchName2);
926 + branch1,
927 + branch2);
928 if (mfi.merge || !mfi.clean)
929 output("Renaming %s->%s", src, ren1_dst);
930
@@ -936,7 +934,7 @@ static int process_renames(struct path_list *renamesA,
934 if (!mfi.clean) {
935 output("CONFLICT (content): merge conflict in %s",
936 ren1_dst);
939 - cleanMerge = 0;
937 + clean_merge = 0;
938
939 if (!index_only)
940 update_stages(ren1_dst,
@@ -952,7 +950,7 @@ static int process_renames(struct path_list *renamesA,
950 struct path_list_item *item;
951 /* we only use sha1 and mode of these */
952 struct diff_filespec src_other, dst_other;
955 - int tryMerge, stage = renamesA == renames1 ? 3: 2;
953 + int try_merge, stage = a_renames == renames1 ? 3: 2;
954
955 remove_file(1, ren1_src);
956
@@ -963,52 +961,52 @@ static int process_renames(struct path_list *renamesA,
961 ren1->dst_entry->stages[stage].sha, 20);
962 dst_other.mode = ren1->dst_entry->stages[stage].mode;
963
966 - tryMerge = 0;
964 + try_merge = 0;
965
968 - if (path_list_has_path(&currentDirectorySet, ren1_dst)) {
969 - cleanMerge = 0;
966 + if (path_list_has_path(&current_directory_set, ren1_dst)) {
967 + clean_merge = 0;
968 output("CONFLICT (rename/directory): Rename %s->%s in %s "
969 " directory %s added in %s",
972 - ren1_src, ren1_dst, branchName1,
973 - ren1_dst, branchName2);
974 - conflict_rename_dir(ren1, branchName1);
970 + ren1_src, ren1_dst, branch1,
971 + ren1_dst, branch2);
972 + conflict_rename_dir(ren1, branch1);
973 } else if (sha_eq(src_other.sha1, null_sha1)) {
976 - cleanMerge = 0;
974 + clean_merge = 0;
975 output("CONFLICT (rename/delete): Rename %s->%s in %s "
976 "and deleted in %s",
979 - ren1_src, ren1_dst, branchName1,
980 - branchName2);
977 + ren1_src, ren1_dst, branch1,
978 + branch2);
979 update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
980 } else if (!sha_eq(dst_other.sha1, null_sha1)) {
983 - const char *newPath;
984 - cleanMerge = 0;
985 - tryMerge = 1;
981 + const char *new_path;
982 + clean_merge = 0;
983 + try_merge = 1;
984 output("CONFLICT (rename/add): Rename %s->%s in %s. "
985 "%s added in %s",
988 - ren1_src, ren1_dst, branchName1,
989 - ren1_dst, branchName2);
990 - newPath = unique_path(ren1_dst, branchName2);
991 - output("Adding as %s instead", newPath);
992 - update_file(0, dst_other.sha1, dst_other.mode, newPath);
986 + ren1_src, ren1_dst, branch1,
987 + ren1_dst, branch2);
988 + new_path = unique_path(ren1_dst, branch2);
989 + output("Adding as %s instead", new_path);
990 + update_file(0, dst_other.sha1, dst_other.mode, new_path);
991 } else if ((item = path_list_lookup(ren1_dst, renames2Dst))) {
992 ren2 = item->util;
995 - cleanMerge = 0;
993 + clean_merge = 0;
994 ren2->processed = 1;
995 output("CONFLICT (rename/rename): Rename %s->%s in %s. "
996 "Rename %s->%s in %s",
999 - ren1_src, ren1_dst, branchName1,
1000 - ren2->pair->one->path, ren2->pair->two->path, branchName2);
1001 - conflict_rename_rename_2(ren1, branchName1, ren2, branchName2);
997 + ren1_src, ren1_dst, branch1,
998 + ren2->pair->one->path, ren2->pair->two->path, branch2);
999 + conflict_rename_rename_2(ren1, branch1, ren2, branch2);
1000 } else
1003 - tryMerge = 1;
1001 + try_merge = 1;
1002
1005 - if (tryMerge) {
1003 + if (try_merge) {
1004 struct diff_filespec *o, *a, *b;
1005 struct merge_file_info mfi;
1006 src_other.path = (char *)ren1_src;
1007
1008 o = ren1->pair->one;
1011 - if (renamesA == renames1) {
1009 + if (a_renames == renames1) {
1010 a = ren1->pair->two;
1011 b = &src_other;
1012 } else {
@@ -1016,7 +1014,7 @@ static int process_renames(struct path_list *renamesA,
1014 a = &src_other;
1015 }
1016 mfi = merge_file(o, a, b,
1019 - branchNameA, branchNameB);
1017 + a_branch, b_branch);
1018
1019 if (mfi.merge || !mfi.clean)
1020 output("Renaming %s => %s", ren1_src, ren1_dst);
@@ -1025,7 +1023,7 @@ static int process_renames(struct path_list *renamesA,
1023 if (!mfi.clean) {
1024 output("CONFLICT (rename/modify): Merge conflict in %s",
1025 ren1_dst);
1028 - cleanMerge = 0;
1026 + clean_merge = 0;
1027
1028 if (!index_only)
1029 update_stages(ren1_dst,
@@ -1035,12 +1033,12 @@ static int process_renames(struct path_list *renamesA,
1033 }
1034 }
1035 }
1038 - path_list_clear(&byDstA, 0);
1039 - path_list_clear(&byDstB, 0);
1036 + path_list_clear(&a_by_dst, 0);
1037 + path_list_clear(&b_by_dst, 0);
1038
1039 if (cache_dirty)
1040 flush_cache();
1043 - return cleanMerge;
1041 + return clean_merge;
1042 }
1043
1044 static unsigned char *has_sha(const unsigned char *sha)
@@ -1057,116 +1055,116 @@ static int process_entry(const char *path, struct stage_data *entry,
1055 printf("processing entry, clean cache: %s\n", index_only ? "yes": "no");
1056 print_index_entry("\tpath: ", entry);
1057 */
1060 - int cleanMerge = 1;
1061 - unsigned char *oSha = has_sha(entry->stages[1].sha);
1062 - unsigned char *aSha = has_sha(entry->stages[2].sha);
1063 - unsigned char *bSha = has_sha(entry->stages[3].sha);
1064 - unsigned oMode = entry->stages[1].mode;
1065 - unsigned aMode = entry->stages[2].mode;
1066 - unsigned bMode = entry->stages[3].mode;
1067 -
1068 - if (oSha && (!aSha || !bSha)) {
1058 + int clean_merge = 1;
1059 + unsigned char *o_sha = has_sha(entry->stages[1].sha);
1060 + unsigned char *a_sha = has_sha(entry->stages[2].sha);
1061 + unsigned char *b_sha = has_sha(entry->stages[3].sha);
1062 + unsigned o_mode = entry->stages[1].mode;
1063 + unsigned a_mode = entry->stages[2].mode;
1064 + unsigned b_mode = entry->stages[3].mode;
1065 +
1066 + if (o_sha && (!a_sha || !b_sha)) {
1067 /* Case A: Deleted in one */
1070 - if ((!aSha && !bSha) ||
1071 - (sha_eq(aSha, oSha) && !bSha) ||
1072 - (!aSha && sha_eq(bSha, oSha))) {
1068 + if ((!a_sha && !b_sha) ||
1069 + (sha_eq(a_sha, o_sha) && !b_sha) ||
1070 + (!a_sha && sha_eq(b_sha, o_sha))) {
1071 /* Deleted in both or deleted in one and
1072 * unchanged in the other */
1075 - if (aSha)
1073 + if (a_sha)
1074 output("Removing %s", path);
1075 remove_file(1, path);
1076 } else {
1077 /* Deleted in one and changed in the other */
1080 - cleanMerge = 0;
1081 - if (!aSha) {
1078 + clean_merge = 0;
1079 + if (!a_sha) {
1080 output("CONFLICT (delete/modify): %s deleted in %s "
1081 "and modified in %s. Version %s of %s left in tree.",
1082 path, branch1Name,
1083 branch2Name, branch2Name, path);
1086 - update_file(0, bSha, bMode, path);
1084 + update_file(0, b_sha, b_mode, path);
1085 } else {
1086 output("CONFLICT (delete/modify): %s deleted in %s "
1087 "and modified in %s. Version %s of %s left in tree.",
1088 path, branch2Name,
1089 branch1Name, branch1Name, path);
1092 - update_file(0, aSha, aMode, path);
1090 + update_file(0, a_sha, a_mode, path);
1091 }
1092 }
1093
1096 - } else if ((!oSha && aSha && !bSha) ||
1097 - (!oSha && !aSha && bSha)) {
1094 + } else if ((!o_sha && a_sha && !b_sha) ||
1095 + (!o_sha && !a_sha && b_sha)) {
1096 /* Case B: Added in one. */
1099 - const char *addBranch;
1100 - const char *otherBranch;
1097 + const char *add_branch;
1098 + const char *other_branch;
1099 unsigned mode;
1100 const unsigned char *sha;
1101 const char *conf;
1102
1105 - if (aSha) {
1106 - addBranch = branch1Name;
1107 - otherBranch = branch2Name;
1108 - mode = aMode;
1109 - sha = aSha;
1103 + if (a_sha) {
1104 + add_branch = branch1Name;
1105 + other_branch = branch2Name;
1106 + mode = a_mode;
1107 + sha = a_sha;
1108 conf = "file/directory";
1109 } else {
1112 - addBranch = branch2Name;
1113 - otherBranch = branch1Name;
1114 - mode = bMode;
1115 - sha = bSha;
1110 + add_branch = branch2Name;
1111 + other_branch = branch1Name;
1112 + mode = b_mode;
1113 + sha = b_sha;
1114 conf = "directory/file";
1115 }
1118 - if (path_list_has_path(&currentDirectorySet, path)) {
1119 - const char *newPath = unique_path(path, addBranch);
1120 - cleanMerge = 0;
1116 + if (path_list_has_path(&current_directory_set, path)) {
1117 + const char *new_path = unique_path(path, add_branch);
1118 + clean_merge = 0;
1119 output("CONFLICT (%s): There is a directory with name %s in %s. "
1120 "Adding %s as %s",
1123 - conf, path, otherBranch, path, newPath);
1121 + conf, path, other_branch, path, new_path);
1122 remove_file(0, path);
1125 - update_file(0, sha, mode, newPath);
1123 + update_file(0, sha, mode, new_path);
1124 } else {
1125 output("Adding %s", path);
1126 update_file(1, sha, mode, path);
1127 }
1130 - } else if (!oSha && aSha && bSha) {
1128 + } else if (!o_sha && a_sha && b_sha) {
1129 /* Case C: Added in both (check for same permissions). */
1132 - if (sha_eq(aSha, bSha)) {
1133 - if (aMode != bMode) {
1134 - cleanMerge = 0;
1130 + if (sha_eq(a_sha, b_sha)) {
1131 + if (a_mode != b_mode) {
1132 + clean_merge = 0;
1133 output("CONFLICT: File %s added identically in both branches, "
1134 "but permissions conflict %06o->%06o",
1137 - path, aMode, bMode);
1138 - output("CONFLICT: adding with permission: %06o", aMode);
1139 - update_file(0, aSha, aMode, path);
1135 + path, a_mode, b_mode);
1136 + output("CONFLICT: adding with permission: %06o", a_mode);
1137 + update_file(0, a_sha, a_mode, path);
1138 } else {
1139 /* This case is handled by git-read-tree */
1140 assert(0 && "This case must be handled by git-read-tree");
1141 }
1142 } else {
1145 - const char *newPath1, *newPath2;
1146 - cleanMerge = 0;
1147 - newPath1 = unique_path(path, branch1Name);
1148 - newPath2 = unique_path(path, branch2Name);
1143 + const char *new_path1, *new_path2;
1144 + clean_merge = 0;
1145 + new_path1 = unique_path(path, branch1Name);
1146 + new_path2 = unique_path(path, branch2Name);
1147 output("CONFLICT (add/add): File %s added non-identically "
1148 "in both branches. Adding as %s and %s instead.",
1151 - path, newPath1, newPath2);
1149 + path, new_path1, new_path2);
1150 remove_file(0, path);
1153 - update_file(0, aSha, aMode, newPath1);
1154 - update_file(0, bSha, bMode, newPath2);
1151 + update_file(0, a_sha, a_mode, new_path1);
1152 + update_file(0, b_sha, b_mode, new_path2);
1153 }
1154
1157 - } else if (oSha && aSha && bSha) {
1155 + } else if (o_sha && a_sha && b_sha) {
1156 /* case D: Modified in both, but differently. */
1157 struct merge_file_info mfi;
1158 struct diff_filespec o, a, b;
1159
1160 output("Auto-merging %s", path);
1161 o.path = a.path = b.path = (char *)path;
1164 - memcpy(o.sha1, oSha, 20);
1165 - o.mode = oMode;
1166 - memcpy(a.sha1, aSha, 20);
1167 - a.mode = aMode;
1168 - memcpy(b.sha1, bSha, 20);
1169 - b.mode = bMode;
1162 + memcpy(o.sha1, o_sha, 20);
1163 + o.mode = o_mode;
1164 + memcpy(a.sha1, a_sha, 20);
1165 + a.mode = a_mode;
1166 + memcpy(b.sha1, b_sha, 20);
1167 + b.mode = b_mode;
1168
1169 mfi = merge_file(&o, &a, &b,
1170 branch1Name, branch2Name);
@@ -1174,14 +1172,14 @@ static int process_entry(const char *path, struct stage_data *entry,
1172 if (mfi.clean)
1173 update_file(1, mfi.sha, mfi.mode, path);
1174 else {
1177 - cleanMerge = 0;
1175 + clean_merge = 0;
1176 output("CONFLICT (content): Merge conflict in %s", path);
1177
1178 if (index_only)
1179 update_file(0, mfi.sha, mfi.mode, path);
1180 else
1181 update_file_flags(mfi.sha, mfi.mode, path,
1184 - 0 /* updateCache */, 1 /* updateWd */);
1182 + 0 /* update_cache */, 1 /* update_working_directory */);
1183 }
1184 } else
1185 die("Fatal merge failure, shouldn't happen.");
@@ -1189,7 +1187,7 @@ static int process_entry(const char *path, struct stage_data *entry,
1187 if (cache_dirty)
1188 flush_cache();
1189
1192 - return cleanMerge;
1190 + return clean_merge;
1191 }
1192
1193 static int merge_trees(struct tree *head,
@@ -1218,8 +1216,8 @@ static int merge_trees(struct tree *head,
1216 if (!*result) {
1217 struct path_list *entries, *re_head, *re_merge;
1218 int i;
1221 - path_list_clear(&currentFileSet, 1);
1222 - path_list_clear(&currentDirectorySet, 1);
1219 + path_list_clear(&current_file_set, 1);
1220 + path_list_clear(&current_directory_set, 1);
1221 get_files_dirs(head);
1222 get_files_dirs(merge);
1223
@@ -1265,12 +1263,12 @@ int merge(struct commit *h1,
1263 struct commit *h2,
1264 const char *branch1Name,
1265 const char *branch2Name,
1268 - int callDepth /* =0 */,
1266 + int call_depth /* =0 */,
1267 struct commit *ancestor /* =None */,
1268 struct commit **result)
1269 {
1270 struct commit_list *ca = NULL, *iter;
1273 - struct commit *mergedCA;
1271 + struct commit *merged_common_ancestors;
1272 struct tree *mrtree;
1273 int clean;
1274
@@ -1287,10 +1285,10 @@ int merge(struct commit *h1,
1285 for (iter = ca; iter; iter = iter->next)
1286 output_commit_title(iter->item);
1287
1290 - mergedCA = pop_commit(&ca);
1288 + merged_common_ancestors = pop_commit(&ca);
1289
1290 for (iter = ca; iter; iter = iter->next) {
1293 - output_indent = callDepth + 1;
1291 + output_indent = call_depth + 1;
1292 /*
1293 * When the merge fails, the result contains files
1294 * with conflict markers. The cleanness flag is
@@ -1298,19 +1296,19 @@ int merge(struct commit *h1,
1296 * merge_trees has always overwritten it: the commited
1297 * "conflicts" were already resolved.
1298 */
1301 - merge(mergedCA, iter->item,
1299 + merge(merged_common_ancestors, iter->item,
1300 "Temporary merge branch 1",
1301 "Temporary merge branch 2",
1304 - callDepth + 1,
1302 + call_depth + 1,
1303 NULL,
1306 - &mergedCA);
1307 - output_indent = callDepth;
1304 + &merged_common_ancestors);
1305 + output_indent = call_depth;
1306
1309 - if (!mergedCA)
1307 + if (!merged_common_ancestors)
1308 die("merge returned no commit");
1309 }
1310
1313 - if (callDepth == 0) {
1311 + if (call_depth == 0) {
1312 setup_index(0 /* $GIT_DIR/index */);
1313 index_only = 0;
1314 } else {
@@ -1319,7 +1317,7 @@ int merge(struct commit *h1,
1317 index_only = 1;
1318 }
1319
1322 - clean = merge_trees(h1->tree, h2->tree, mergedCA->tree,
1320 + clean = merge_trees(h1->tree, h2->tree, merged_common_ancestors->tree,
1321 branch1Name, branch2Name, &mrtree);
1322
1323 if (!ancestor && (clean || index_only)) {