@@ -503,11 +503,6 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader, ski
503
503
}
504
504
return diff , err
505
505
}
506
-
507
- prepareValue := func (s , p string ) string {
508
- return strings .TrimSpace (strings .TrimPrefix (s , p ))
509
- }
510
-
511
506
parsingLoop:
512
507
for {
513
508
// 1. A patch file always begins with `diff --git ` + `a/path b/path` (possibly quoted)
@@ -592,49 +587,48 @@ parsingLoop:
592
587
}
593
588
break parsingLoop
594
589
}
595
-
596
590
switch {
597
591
case strings .HasPrefix (line , cmdDiffHead ):
598
592
break curFileLoop
599
593
case strings .HasPrefix (line , "old mode " ) ||
600
594
strings .HasPrefix (line , "new mode " ):
601
595
602
596
if strings .HasPrefix (line , "old mode " ) {
603
- curFile .OldMode = prepareValue ( line , "old mode " )
597
+ curFile .OldMode = line [ len ( "old mode " ) : len ( line ) - 1 ]
604
598
}
605
599
if strings .HasPrefix (line , "new mode " ) {
606
- curFile .Mode = prepareValue ( line , "new mode " )
600
+ curFile .Mode = line [ len ( "new mode " ) : len ( line ) - 1 ]
607
601
}
608
602
609
603
if strings .HasSuffix (line , " 160000\n " ) {
610
604
curFile .IsSubmodule = true
611
605
}
612
606
case strings .HasPrefix (line , "new file mode " ):
613
- curFile .Mode = strings . TrimPrefix ( line , "new file mode " )
607
+ curFile .Mode = line [ len ( "new file mode " ) : len ( line ) - 1 ]
614
608
case strings .HasPrefix (line , "rename from " ):
615
609
curFile .IsRenamed = true
616
610
curFile .Type = DiffFileRename
617
611
if curFile .IsAmbiguous {
618
- curFile .OldName = prepareValue ( line , "rename from " )
612
+ curFile .OldName = line [ len ( "rename from " ) : len ( line ) - 1 ]
619
613
}
620
614
case strings .HasPrefix (line , "rename to " ):
621
615
curFile .IsRenamed = true
622
616
curFile .Type = DiffFileRename
623
617
if curFile .IsAmbiguous {
624
- curFile .Name = prepareValue ( line , "rename to " )
618
+ curFile .Name = line [ len ( "rename to " ) : len ( line ) - 1 ]
625
619
curFile .IsAmbiguous = false
626
620
}
627
621
case strings .HasPrefix (line , "copy from " ):
628
622
curFile .IsRenamed = true
629
623
curFile .Type = DiffFileCopy
630
624
if curFile .IsAmbiguous {
631
- curFile .OldName = prepareValue ( line , "copy from " )
625
+ curFile .OldName = line [ len ( "copy from " ) : len ( line ) - 1 ]
632
626
}
633
627
case strings .HasPrefix (line , "copy to " ):
634
628
curFile .IsRenamed = true
635
629
curFile .Type = DiffFileCopy
636
630
if curFile .IsAmbiguous {
637
- curFile .Name = prepareValue ( line , "copy to " )
631
+ curFile .Name = line [ len ( "copy to " ) : len ( line ) - 1 ]
638
632
curFile .IsAmbiguous = false
639
633
}
640
634
case strings .HasPrefix (line , "new file" ):
0 commit comments