@@ -291,7 +291,7 @@ const handle_new_file_patch = async (
291291) : Promise < {
292292 success : boolean
293293 original_states ?: OriginalFileState [ ]
294- diff_fallback_method ?: 'recount' | 'search_and_replace'
294+ diff_application_method ?: 'recount' | 'search_and_replace'
295295} > => {
296296 const file_paths = extract_file_paths_from_patch ( patch_content )
297297 if ( file_paths . length != 1 ) {
@@ -366,7 +366,7 @@ const handle_deleted_file_patch = async (
366366) : Promise < {
367367 success : boolean
368368 original_states ?: OriginalFileState [ ]
369- diff_fallback_method ?: 'recount' | 'search_and_replace'
369+ diff_application_method ?: 'recount' | 'search_and_replace'
370370} > => {
371371 const file_paths = extract_file_paths_from_patch ( patch_content )
372372 if ( file_paths . length != 1 ) {
@@ -435,7 +435,7 @@ export const apply_git_patch = async (
435435) : Promise < {
436436 success : boolean
437437 original_states ?: OriginalFileState [ ]
438- diff_fallback_method ?: 'recount' | 'search_and_replace'
438+ diff_application_method ?: 'recount' | 'search_and_replace'
439439} > => {
440440 const patch_info = parse_patch_header ( patch_content , workspace_path )
441441
@@ -474,55 +474,33 @@ export const apply_git_patch = async (
474474
475475 let last_error : any = null
476476 let success = false
477- let diff_fallback_method : 'recount' | 'search_and_replace' | undefined =
477+ let diff_application_method : 'recount' | 'search_and_replace' | undefined =
478478 undefined
479479
480480 if ( patch_info . is_renaming ) {
481481 // Skip git apply and fallbacks, renaming here is a base case where no content is changing, just paths. File is already copied.
482482 success = true
483483 }
484484
485- // Attempt 1: Standard git apply
485+ // Attempt 1: git apply with --recount
486486 if ( ! success ) {
487- try {
488- await execAsync (
489- `git apply --whitespace=fix --ignore-whitespace "${ temp_file } "` ,
490- { cwd : workspace_path }
491- )
492- success = true
493- Logger . info ( {
494- function_name : 'apply_git_patch' ,
495- message : 'Patch applied successfully with standard git apply.'
496- } )
497- } catch ( error ) {
498- last_error = error
499- }
500- }
501-
502- // Attempt 2: git apply with --recount
503- if ( ! success ) {
504- Logger . warn ( {
505- function_name : 'apply_git_patch' ,
506- message : 'Standard git apply failed, trying with --recount.' ,
507- data : { error : last_error }
508- } )
509487 try {
510488 await execAsync (
511489 `git apply --whitespace=fix --ignore-whitespace --recount "${ temp_file } "` ,
512490 { cwd : workspace_path }
513491 )
514492 success = true
515- diff_fallback_method = 'recount'
493+ diff_application_method = 'recount'
516494 Logger . info ( {
517495 function_name : 'apply_git_patch' ,
518- message : 'Patch applied successfully with --recount fallback .'
496+ message : 'Patch applied successfully with --recount.'
519497 } )
520498 } catch ( error ) {
521499 last_error = error
522500 }
523501 }
524502
525- // Attempt 3 : Custom diff processor
503+ // Attempt 2 : Custom diff processor
526504 if ( ! success ) {
527505 Logger . warn ( {
528506 function_name : 'apply_git_patch' ,
@@ -538,7 +516,7 @@ export const apply_git_patch = async (
538516 diff_path_patch : temp_file
539517 } )
540518 success = true
541- diff_fallback_method = 'search_and_replace'
519+ diff_application_method = 'search_and_replace'
542520 Logger . info ( {
543521 function_name : 'apply_git_patch' ,
544522 message : 'Patch applied successfully with custom processor fallback.'
@@ -555,7 +533,7 @@ export const apply_git_patch = async (
555533 return {
556534 success : true ,
557535 original_states : original_states ,
558- diff_fallback_method
536+ diff_application_method
559537 }
560538 } else {
561539 // All methods failed, throw the last logged error to be handled by the outer catch
0 commit comments