* Prevent dangling GetAttribute calls It appears possible that there could be a hang due to unread data from the repo-attribute command pipes. This PR simply closes these during the defer. Signed-off-by: Andrew Thornton <art27@cantab.net> * move close into the defer Signed-off-by: Andrew Thornton <art27@cantab.net> * lets try again Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
2e36ba0a00
commit
7ebc3da7cb
3 changed files with 25 additions and 17 deletions
|
@ -190,9 +190,11 @@ var (
|
|||
codeTagSuffix = []byte(`</span>`)
|
||||
)
|
||||
|
||||
var unfinishedtagRegex = regexp.MustCompile(`<[^>]*$`)
|
||||
var trailingSpanRegex = regexp.MustCompile(`<span\s*[[:alpha:]="]*?[>]?$`)
|
||||
var entityRegex = regexp.MustCompile(`&[#]*?[0-9[:alpha:]]*$`)
|
||||
var (
|
||||
unfinishedtagRegex = regexp.MustCompile(`<[^>]*$`)
|
||||
trailingSpanRegex = regexp.MustCompile(`<span\s*[[:alpha:]="]*?[>]?$`)
|
||||
entityRegex = regexp.MustCompile(`&[#]*?[0-9[:alpha:]]*$`)
|
||||
)
|
||||
|
||||
// shouldWriteInline represents combinations where we manually write inline changes
|
||||
func shouldWriteInline(diff diffmatchpatch.Diff, lineType DiffLineType) bool {
|
||||
|
@ -206,7 +208,6 @@ func shouldWriteInline(diff diffmatchpatch.Diff, lineType DiffLineType) bool {
|
|||
}
|
||||
|
||||
func fixupBrokenSpans(diffs []diffmatchpatch.Diff) []diffmatchpatch.Diff {
|
||||
|
||||
// Create a new array to store our fixed up blocks
|
||||
fixedup := make([]diffmatchpatch.Diff, 0, len(diffs))
|
||||
|
||||
|
@ -658,10 +659,10 @@ func (diffFile *DiffFile) GetTailSection(gitRepo *git.Repository, leftCommitID,
|
|||
LastRightIdx: lastLine.RightIdx,
|
||||
LeftIdx: leftLineCount,
|
||||
RightIdx: rightLineCount,
|
||||
}}
|
||||
},
|
||||
}
|
||||
tailSection := &DiffSection{FileName: diffFile.Name, Lines: []*DiffLine{tailDiffLine}}
|
||||
return tailSection
|
||||
|
||||
}
|
||||
|
||||
func getCommitFileLineCount(commit *git.Commit, filePath string) int {
|
||||
|
@ -942,8 +943,8 @@ parsingLoop:
|
|||
// TODO: There are numerous issues with this:
|
||||
// - we might want to consider detecting encoding while parsing but...
|
||||
// - we're likely to fail to get the correct encoding here anyway as we won't have enough information
|
||||
var diffLineTypeBuffers = make(map[DiffLineType]*bytes.Buffer, 3)
|
||||
var diffLineTypeDecoders = make(map[DiffLineType]*encoding.Decoder, 3)
|
||||
diffLineTypeBuffers := make(map[DiffLineType]*bytes.Buffer, 3)
|
||||
diffLineTypeDecoders := make(map[DiffLineType]*encoding.Decoder, 3)
|
||||
diffLineTypeBuffers[DiffLinePlain] = new(bytes.Buffer)
|
||||
diffLineTypeBuffers[DiffLineAdd] = new(bytes.Buffer)
|
||||
diffLineTypeBuffers[DiffLineDel] = new(bytes.Buffer)
|
||||
|
@ -1420,6 +1421,7 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff
|
|||
}()
|
||||
}
|
||||
defer func() {
|
||||
_ = checker.Close()
|
||||
cancel()
|
||||
}()
|
||||
}
|
||||
|
@ -1539,7 +1541,8 @@ func GetWhitespaceFlag(whiteSpaceBehavior string) string {
|
|||
"ignore-all": "-w",
|
||||
"ignore-change": "-b",
|
||||
"ignore-eol": "--ignore-space-at-eol",
|
||||
"": ""}
|
||||
"": "",
|
||||
}
|
||||
|
||||
return whitespaceFlags[whiteSpaceBehavior]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue