@@ -2727,7 +2727,7 @@ static int handle_modify_delete(struct merge_options *o,
2727
2727
2728
2728
static int merge_content (struct merge_options * o ,
2729
2729
const char * path ,
2730
- int file_in_way ,
2730
+ int is_dirty ,
2731
2731
struct object_id * o_oid , int o_mode ,
2732
2732
struct object_id * a_oid , int a_mode ,
2733
2733
struct object_id * b_oid , int b_mode ,
@@ -2803,7 +2803,7 @@ static int merge_content(struct merge_options *o,
2803
2803
return -1 ;
2804
2804
}
2805
2805
2806
- if (df_conflict_remains || file_in_way ) {
2806
+ if (df_conflict_remains || is_dirty ) {
2807
2807
char * new_path ;
2808
2808
if (o -> call_depth ) {
2809
2809
remove_file_from_cache (path );
@@ -2825,6 +2825,10 @@ static int merge_content(struct merge_options *o,
2825
2825
2826
2826
}
2827
2827
new_path = unique_path (o , path , rename_conflict_info -> branch1 );
2828
+ if (is_dirty ) {
2829
+ output (o , 1 , _ ("Refusing to lose dirty file at %s" ),
2830
+ path );
2831
+ }
2828
2832
output (o , 1 , _ ("Adding as %s instead" ), new_path );
2829
2833
if (update_file (o , 0 , & mfi .oid , mfi .mode , new_path )) {
2830
2834
free (new_path );
@@ -2834,7 +2838,7 @@ static int merge_content(struct merge_options *o,
2834
2838
mfi .clean = 0 ;
2835
2839
} else if (update_file (o , mfi .clean , & mfi .oid , mfi .mode , path ))
2836
2840
return -1 ;
2837
- return mfi .clean ;
2841
+ return ! is_dirty && mfi .clean ;
2838
2842
}
2839
2843
2840
2844
static int conflict_rename_normal (struct merge_options * o ,
@@ -2844,21 +2848,10 @@ static int conflict_rename_normal(struct merge_options *o,
2844
2848
struct object_id * b_oid , unsigned int b_mode ,
2845
2849
struct rename_conflict_info * ci )
2846
2850
{
2847
- int clean_merge ;
2848
- int file_in_the_way = 0 ;
2849
-
2850
- if (was_dirty (o , path )) {
2851
- file_in_the_way = 1 ;
2852
- output (o , 1 , _ ("Refusing to lose dirty file at %s" ), path );
2853
- }
2854
-
2855
2851
/* Merge the content and write it out */
2856
- clean_merge = merge_content (o , path , file_in_the_way ,
2857
- o_oid , o_mode , a_oid , a_mode , b_oid , b_mode ,
2858
- ci );
2859
- if (clean_merge > 0 && file_in_the_way )
2860
- clean_merge = 0 ;
2861
- return clean_merge ;
2852
+ return merge_content (o , path , was_dirty (o , path ),
2853
+ o_oid , o_mode , a_oid , a_mode , b_oid , b_mode ,
2854
+ ci );
2862
2855
}
2863
2856
2864
2857
/* Per entry merge function */
@@ -2981,7 +2974,8 @@ static int process_entry(struct merge_options *o,
2981
2974
} else if (a_oid && b_oid ) {
2982
2975
/* Case C: Added in both (check for same permissions) and */
2983
2976
/* case D: Modified in both, but differently. */
2984
- clean_merge = merge_content (o , path , 0 /* file_in_way */ ,
2977
+ int is_dirty = 0 ; /* unpack_trees would have bailed if dirty */
2978
+ clean_merge = merge_content (o , path , is_dirty ,
2985
2979
o_oid , o_mode , a_oid , a_mode , b_oid , b_mode ,
2986
2980
NULL );
2987
2981
} else if (!o_oid && !a_oid && !b_oid ) {
0 commit comments