diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-06-28 15:00:32 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-06-28 15:00:32 +0800 |
commit | a357cda9575b482004329e81f0add6e4c32ab02a (patch) | |
tree | db7d7508a039cfd4dd6cedad236e720bcfe1396c /models/git_diff.go | |
parent | 165e3e8f18bb7d38722d0c836ddbf8c95023cf67 (diff) | |
parent | 6e448b07145fbb090e0da6deb97f244c2bfd7ba7 (diff) |
Merge branch 'dev' of github.com:gogits/gogs into dev
Diffstat (limited to 'models/git_diff.go')
-rw-r--r-- | models/git_diff.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/models/git_diff.go b/models/git_diff.go index 5b5a46a1..ed114b75 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -6,6 +6,7 @@ package models import ( "bufio" + "fmt" "io" "os" "os/exec" @@ -15,6 +16,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" + "github.com/gogits/gogs/modules/process" ) // Diff line types. @@ -67,7 +69,7 @@ func (diff *Diff) NumFiles() int { const DIFF_HEAD = "diff --git " -func ParsePatch(cmd *exec.Cmd, reader io.Reader) (*Diff, error) { +func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { scanner := bufio.NewScanner(reader) var ( curFile *DiffFile @@ -169,11 +171,8 @@ func ParsePatch(cmd *exec.Cmd, reader io.Reader) (*Diff, error) { } // In case process became zombie. - if !cmd.ProcessState.Exited() { - log.Debug("git_diff.ParsePatch: process doesn't exit and now will be killed") - if err := cmd.Process.Kill(); err != nil { - log.Error("git_diff.ParsePatch: fail to kill zombie process: %v", err) - } + if err := process.Kill(pid); err != nil { + log.Error("git_diff.ParsePatch(Kill): %v", err) } return diff, nil } @@ -207,5 +206,5 @@ func GetDiff(repoPath, commitid string) (*Diff, error) { wr.Close() }() defer rd.Close() - return ParsePatch(cmd, rd) + return ParsePatch(process.Add(fmt.Sprintf("GetDiff(%s)", repoPath), cmd), cmd, rd) } |