@@ -357,18 +357,20 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine, loc
357357
358358// DiffFile represents a file diff.
359359type DiffFile struct {
360- Name string
361- NameHash string
362- OldName string
363- Index int
364- Addition , Deletion int
365- Type DiffFileType
366- IsCreated bool
367- IsDeleted bool
368- IsBin bool
369- IsLFSFile bool
370- IsRenamed bool
371- IsAmbiguous bool
360+ Name string
361+ NameHash string
362+ OldName string
363+ Addition , Deletion int
364+ Type DiffFileType
365+ IsCreated bool
366+ IsDeleted bool
367+ IsBin bool
368+ IsLFSFile bool
369+ IsRenamed bool
370+
371+ // only used internally to parse Ambiguous filenames
372+ isAmbiguous bool
373+
372374 Sections []* DiffSection
373375 IsIncomplete bool
374376 IsIncompleteLineTooLong bool
@@ -645,28 +647,28 @@ parsingLoop:
645647 case strings .HasPrefix (line , "rename from " ):
646648 curFile .IsRenamed = true
647649 curFile .Type = DiffFileRename
648- if curFile .IsAmbiguous {
650+ if curFile .isAmbiguous {
649651 curFile .OldName = prepareValue (line , "rename from " )
650652 }
651653 case strings .HasPrefix (line , "rename to " ):
652654 curFile .IsRenamed = true
653655 curFile .Type = DiffFileRename
654- if curFile .IsAmbiguous {
656+ if curFile .isAmbiguous {
655657 curFile .Name = prepareValue (line , "rename to " )
656- curFile .IsAmbiguous = false
658+ curFile .isAmbiguous = false
657659 }
658660 case strings .HasPrefix (line , "copy from " ):
659661 curFile .IsRenamed = true
660662 curFile .Type = DiffFileCopy
661- if curFile .IsAmbiguous {
663+ if curFile .isAmbiguous {
662664 curFile .OldName = prepareValue (line , "copy from " )
663665 }
664666 case strings .HasPrefix (line , "copy to " ):
665667 curFile .IsRenamed = true
666668 curFile .Type = DiffFileCopy
667- if curFile .IsAmbiguous {
669+ if curFile .isAmbiguous {
668670 curFile .Name = prepareValue (line , "copy to " )
669- curFile .IsAmbiguous = false
671+ curFile .isAmbiguous = false
670672 }
671673 case strings .HasPrefix (line , "new file" ):
672674 curFile .Type = DiffFileAdd
@@ -693,7 +695,7 @@ parsingLoop:
693695 curFile .IsBin = true
694696 case strings .HasPrefix (line , "--- " ):
695697 // Handle ambiguous filenames
696- if curFile .IsAmbiguous {
698+ if curFile .isAmbiguous {
697699 // The shortest string that can end up here is:
698700 // "--- a\t\n" without the quotes.
699701 // This line has a len() of 7 but doesn't contain a oldName.
@@ -711,7 +713,7 @@ parsingLoop:
711713 // Otherwise do nothing with this line
712714 case strings .HasPrefix (line , "+++ " ):
713715 // Handle ambiguous filenames
714- if curFile .IsAmbiguous {
716+ if curFile .isAmbiguous {
715717 if len (line ) > 6 && line [4 ] == 'b' {
716718 curFile .Name = line [6 : len (line )- 1 ]
717719 if line [len (line )- 2 ] == '\t' {
@@ -723,7 +725,7 @@ parsingLoop:
723725 } else {
724726 curFile .Name = curFile .OldName
725727 }
726- curFile .IsAmbiguous = false
728+ curFile .isAmbiguous = false
727729 }
728730 // Otherwise do nothing with this line, but now switch to parsing hunks
729731 lineBytes , isFragment , err := parseHunks (ctx , curFile , maxLines , maxLineCharacters , input )
@@ -1047,12 +1049,11 @@ func createDiffFile(diff *Diff, line string) *DiffFile {
10471049 //
10481050 // Path names are quoted if necessary.
10491051 //
1050- // This means that you should always be able to determine the file name even when there
1052+ // This means that you should always be able to determine the file name even when
10511053 // there is potential ambiguity...
10521054 //
10531055 // but we can be simpler with our heuristics by just forcing git to prefix things nicely
10541056 curFile := & DiffFile {
1055- Index : len (diff .Files ) + 1 ,
10561057 Type : DiffFileChange ,
10571058 Sections : make ([]* DiffSection , 0 , 10 ),
10581059 }
@@ -1064,7 +1065,7 @@ func createDiffFile(diff *Diff, line string) *DiffFile {
10641065 curFile .OldName , oldNameAmbiguity = readFileName (rd )
10651066 curFile .Name , newNameAmbiguity = readFileName (rd )
10661067 if oldNameAmbiguity && newNameAmbiguity {
1067- curFile .IsAmbiguous = true
1068+ curFile .isAmbiguous = true
10681069 // OK we should bet that the oldName and the newName are the same if they can be made to be same
10691070 // So we need to start again ...
10701071 if (len (line )- len (cmdDiffHead )- 1 )% 2 == 0 {
0 commit comments