File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed
Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -646,6 +646,74 @@ mod tests {
646646 ) ;
647647 }
648648
649+ #[ test]
650+ fn test_diff_header_with_mode_change_in_last_hunk ( ) {
651+ let input = "\
652+ diff --git a/a.txt b/a.txt
653+ index 44371ed..e69de29 100644
654+ --- a/a.txt
655+ +++ b/a.txt
656+ @@ -1 +0,0 @@
657+ -A-content
658+ diff --git a/b.txt b/b.txt
659+ old mode 100644
660+ new mode 100755
661+ " ;
662+
663+ let result = DeltaTest :: with_args ( & [ ] ) . with_input ( input) ;
664+
665+ assert_snapshot ! ( result. output, @r"
666+ a.txt
667+ ───────────────────────────────────────────
668+
669+ ───┐
670+ 0: │
671+ ───┘
672+ A-content
673+
674+ b.txt (mode +x)
675+ ───────────────────────────────────────────
676+ " ) ;
677+ }
678+
679+ #[ test]
680+ fn test_diff_header_with_2x_mode_change ( ) {
681+ let input = "\
682+ diff --git a/a.txt b/a.txt
683+ index 44371ed..e69de29 100644
684+ --- a/a.txt
685+ +++ b/a.txt
686+ @@ -1 +0,0 @@
687+ -A-content
688+ diff --git a/b.txt b/b.txt
689+ old mode 100644
690+ new mode 100755
691+ --- a/b.txt
692+ +++ b/b.txt
693+ diff --git a/c.txt b/c.txt
694+ old mode 100644
695+ new mode 100755
696+ " ;
697+
698+ let result = DeltaTest :: with_args ( & [ ] ) . with_input ( input) ;
699+
700+ assert_snapshot ! ( result. output, @r"
701+ a.txt
702+ ───────────────────────────────────────────
703+
704+ ───┐
705+ 0: │
706+ ───┘
707+ A-content
708+
709+ b.txt (mode +x)
710+ ───────────────────────────────────────────
711+
712+ c.txt (mode +x)
713+ ───────────────────────────────────────────
714+ " ) ;
715+ }
716+
649717 pub const BIN_AND_TXT_FILE_ADDED : & str = "\
650718 diff --git a/BIN b/BIN
651719new file mode 100644
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ impl StateMachine<'_> {
1313 return Ok ( false ) ;
1414 }
1515 self . painter . paint_buffered_minus_and_plus_lines ( ) ;
16+ self . painter . emit ( ) ?;
1617 self . state =
1718 if self . line . starts_with ( "diff --cc " ) || self . line . starts_with ( "diff --combined " ) {
1819 // We will determine the number of parents when we see the hunk header.
You can’t perform that action at this time.
0 commit comments