File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -501,8 +501,10 @@ mod tests {
501501 File { path: "tzu" . into( ) , meta: None } ,
502502 ) ) ;
503503
504+ // note: the trailing tab after lao is intentional and significant here
505+ // see https://github.com/uniphil/patch-rs/commit/364897dae8599cdb758c00fdc8dacd1645959070
504506 let sample2b = "\
505- --- lao
507+ --- lao
506508+++ tzu \n " ;
507509 test_parser ! ( headers( sample2b) -> (
508510 File { path: "lao" . into( ) , meta: None } ,
Original file line number Diff line number Diff line change 1+ # Tell editors to allow whitespace violations in source
2+ [parse_patch.rs ]
3+ trim_trailing_whitespace = false
4+
5+ # This shouldn't be needed
6+ [* .{diff,patch} ]
7+ trim_trailing_whitespace = false
Original file line number Diff line number Diff line change @@ -416,3 +416,37 @@ rename to new-path.rs
416416 assert_eq ! ( patches[ 0 ] . new. path, "new-path.rs" ) ;
417417 assert ! ( patches[ 0 ] . hunks. is_empty( ) ) ;
418418}
419+
420+ #[ test]
421+ fn binary_diff_interspersed_with_text_diff ( ) {
422+ let sample = "\
423+ --- before.py
424+ +++ after.py
425+ @@ -1,4 +1,4 @@
426+ -bacon
427+ -eggs
428+ -ham
429+ +python
430+ +eggy
431+ +hamster
432+ guido
433+ Binary files old.bin and new.bin differ
434+ --- before2.py
435+ +++ after2.py
436+ @@ -1,4 +1,4 @@
437+ -bacon
438+ -eggs
439+ -ham
440+ +python
441+ +eggy
442+ +hamster
443+ guido
444+ Binary files old2.bin and new2.bin differ
445+ " ;
446+ let patches = Patch :: from_multiple ( sample) . unwrap ( ) ;
447+ assert_eq ! ( patches. len( ) , 4 ) ;
448+ assert_eq ! ( patches[ 0 ] . old. path, "before.py" ) ;
449+ assert_eq ! ( patches[ 1 ] . old. path, "old.bin" ) ;
450+ assert_eq ! ( patches[ 2 ] . new. path, "after2.py" ) ;
451+ assert_eq ! ( patches[ 3 ] . new. path, "new2.bin" ) ;
452+ }
You can’t perform that action at this time.
0 commit comments