@@ -163,31 +163,42 @@ pub fn apply_merge(
163163 }
164164
165165 MergeAction :: Conflict => {
166- // Write a .rej file with the diff
166+ // Write a .rej file with diff3-style output showing all three versions
167167 let new_path = new_snapshot_dir. join ( & result. rel_path ) ;
168168
169169 let user_content = std:: fs:: read_to_string ( & proj_path) . unwrap_or_default ( ) ;
170170 let new_content = std:: fs:: read_to_string ( & new_path) . unwrap_or_default ( ) ;
171171
172- // If the file existed in old snapshot, also include context
173172 let old_path = old_snapshot_dir. join ( & result. rel_path ) ;
174173 let rej_content = if old_path. exists ( ) {
175174 let old_content = std:: fs:: read_to_string ( & old_path) . unwrap_or_default ( ) ;
176175 format ! (
177- "# Conflict in {}\n \
178- # Your file differs from both the old and new template versions.\n \n \
179- ## Template changes (old -> new):\n {}\n \n \
180- ## Your version vs new template:\n {}\n ",
181- result. rel_path. display( ) ,
182- diff:: unified_diff( & old_content, & new_content, & result. rel_path) ,
183- diff:: unified_diff( & user_content, & new_content, & result. rel_path) ,
176+ "# Conflict in {path}\n \
177+ # Three-way diff: base (old template) vs yours vs new template\n \n \
178+ ## Base version (old template):\n {base}\n \n \
179+ ## Your version:\n {user}\n \n \
180+ ## New template version:\n {new}\n \n \
181+ ## Diff: base -> new template:\n {diff_old_new}\n \n \
182+ ## Diff: your version -> new template:\n {diff_user_new}\n ",
183+ path = result. rel_path. display( ) ,
184+ base = old_content,
185+ user = user_content,
186+ new = new_content,
187+ diff_old_new =
188+ diff:: unified_diff( & old_content, & new_content, & result. rel_path) ,
189+ diff_user_new =
190+ diff:: unified_diff( & user_content, & new_content, & result. rel_path) ,
184191 )
185192 } else {
186193 format ! (
187194 "# Conflict in {}\n \
188195 # Both you and the template created/modified this file differently.\n \n \
189- ## Diff (your version vs template):\n {}\n ",
196+ ## Your version:\n {}\n \n \
197+ ## New template version:\n {}\n \n \
198+ ## Diff (yours -> template):\n {}\n ",
190199 result. rel_path. display( ) ,
200+ user_content,
201+ new_content,
191202 diff:: unified_diff( & user_content, & new_content, & result. rel_path) ,
192203 )
193204 } ;
0 commit comments