merge-recursive: Consolidate different update_stages functions
We are only calling update_stages_options() one way really, so we can consolidate the slightly different variants into one and remove some parameters whose values are always the same. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Aug 11, 2011 at 23:19 UTC
650467cf89e61815cfa1c942544a3659eda88aeb
1 file changed
+9
-18
merge-recursive.c
+9
-18
@@ -459,11 +459,12 @@ static struct string_list *get_renames(struct merge_options *o,
459
return renames;
460
}
461
462
-static int update_stages_options(const char *path, const struct diff_filespec *o,
463
- const struct diff_filespec *a,
464
- const struct diff_filespec *b,
465
- int clear, int options)
462
+static int update_stages(const char *path, const struct diff_filespec *o,
463
+ const struct diff_filespec *a,
464
+ const struct diff_filespec *b)
465
{
466
+ int clear = 1;
467
+ int options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_SKIP_DFCHECK;
468
if (clear)
469
if (remove_file_from_cache(path))
470
return -1;
@@ -479,14 +480,6 @@ static int update_stages_options(const char *path, const struct diff_filespec *o
480
return 0;
481
}
482
482
-static int update_stages(const char *path, struct diff_filespec *o,
483
- struct diff_filespec *a, struct diff_filespec *b,
484
- int clear)
485
-{
486
- int options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE;
487
- return update_stages_options(path, o, a, b, clear, options);
488
-}
489
-
483
static int update_stages_and_entry(const char *path,
484
struct stage_data *entry,
485
struct diff_filespec *o,
@@ -503,8 +496,7 @@ static int update_stages_and_entry(const char *path,
496
hashcpy(entry->stages[1].sha, o->sha1);
497
hashcpy(entry->stages[2].sha, a->sha1);
498
hashcpy(entry->stages[3].sha, b->sha1);
506
- options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_SKIP_DFCHECK;
507
- return update_stages_options(path, o, a, b, clear, options);
499
+ return update_stages(path, o, a, b);
500
}
501
502
static int remove_file(struct merge_options *o, int clean,
@@ -860,8 +852,7 @@ static void conflict_rename_delete(struct merge_options *o,
852
if (!o->call_depth)
853
update_stages(dest_name, NULL,
854
rename_branch == o->branch1 ? pair->two : NULL,
863
- rename_branch == o->branch1 ? NULL : pair->two,
864
- 1);
855
+ rename_branch == o->branch1 ? NULL : pair->two);
856
if (lstat(dest_name, &st) == 0 && S_ISDIR(st.st_mode)) {
857
dest_name = unique_path(o, dest_name, rename_branch);
858
df_conflict = 1;
@@ -905,8 +896,8 @@ static void conflict_rename_rename_1to2(struct merge_options *o,
896
* update_file(o, 0, pair2->two->sha1, pair2->two->mode, dst_name2);
897
*/
898
} else {
908
- update_stages(ren1_dst, NULL, pair1->two, NULL, 1);
909
- update_stages(ren2_dst, NULL, NULL, pair2->two, 1);
899
+ update_stages(ren1_dst, NULL, pair1->two, NULL);
900
+ update_stages(ren2_dst, NULL, NULL, pair2->two);
901
902
update_file(o, 0, pair1->two->sha1, pair1->two->mode, dst_name1);
903
update_file(o, 0, pair2->two->sha1, pair2->two->mode, dst_name2);