aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/vcs
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-11-06 17:59:11 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-11-07 11:07:03 +0100
commit30cb7f98cd1aba45565123caf4cbd73772bb8b58 (patch)
treed43386f633ef60f4314d9d8ae2b02b0dea4af370 /pkg/vcs
parentf15876118387bb9e4c079f29d06394b36e393180 (diff)
pkg/bisect: detect wrong bisections
Detect bisection to merge commits and to commits that don't affect kernel binary (comments, other arches, whitespaces, etc). Such bisections are not reported in emails (but shown on web). Update #1271
Diffstat (limited to 'pkg/vcs')
-rw-r--r--pkg/vcs/git.go8
-rw-r--r--pkg/vcs/git_repo_test.go5
-rw-r--r--pkg/vcs/vcs.go1
3 files changed, 11 insertions, 3 deletions
diff --git a/pkg/vcs/git.go b/pkg/vcs/git.go
index 359c3d68e..5a6de4b3f 100644
--- a/pkg/vcs/git.go
+++ b/pkg/vcs/git.go
@@ -153,7 +153,7 @@ func (git *git) HeadCommit() (*Commit, error) {
}
func (git *git) getCommit(commit string) (*Commit, error) {
- output, err := git.git("log", "--format=%H%n%s%n%ae%n%an%n%ad%n%b", "-n", "1", commit)
+ output, err := git.git("log", "--format=%H%n%s%n%ae%n%an%n%ad%n%P%n%b", "-n", "1", commit)
if err != nil {
return nil, err
}
@@ -182,7 +182,7 @@ func gitParseCommit(output, user, domain []byte, ignoreCC map[string]bool) (*Com
cc := make(map[string]bool)
cc[strings.ToLower(string(lines[2]))] = true
var tags []string
- bodyLines := lines[5:]
+ bodyLines := lines[6:]
if isEmpty(bodyLines) {
// Body is empty, use summary instead.
bodyLines = [][]byte{lines[1]}
@@ -231,11 +231,13 @@ func gitParseCommit(output, user, domain []byte, ignoreCC map[string]bool) (*Com
sortedCC = append(sortedCC, addr)
}
sort.Strings(sortedCC)
+ parents := strings.Split(string(lines[5]), " ")
com := &Commit{
Hash: string(lines[0]),
Title: string(lines[1]),
Author: string(lines[2]),
AuthorName: string(lines[3]),
+ Parents: parents,
CC: sortedCC,
Tags: tags,
Date: date,
@@ -303,7 +305,7 @@ func (git *git) ExtractFixTagsFromCommits(baseCommit, email string) ([]*Commit,
func (git *git) fetchCommits(since, base, user, domain string, greps []string, fixedStrings bool) ([]*Commit, error) {
const commitSeparator = "---===syzkaller-commit-separator===---"
- args := []string{"log", "--since", since, "--format=%H%n%s%n%ae%n%an%n%ad%n%b%n" + commitSeparator}
+ args := []string{"log", "--since", since, "--format=%H%n%s%n%ae%n%an%n%ad%n%P%n%b%n" + commitSeparator}
if fixedStrings {
args = append(args, "--fixed-strings")
}
diff --git a/pkg/vcs/git_repo_test.go b/pkg/vcs/git_repo_test.go
index 227834b71..e1d317ea2 100644
--- a/pkg/vcs/git_repo_test.go
+++ b/pkg/vcs/git_repo_test.go
@@ -116,6 +116,7 @@ func TestMetadata(t *testing.T) {
}
defer os.RemoveAll(repoDir)
repo := MakeTestRepo(t, repoDir)
+ prevHash := ""
for i, test := range metadataTests {
repo.CommitChange(test.description)
com, err := repo.repo.HeadCommit()
@@ -123,6 +124,10 @@ func TestMetadata(t *testing.T) {
t.Fatal(err)
}
checkCommit(t, i, test, com, false)
+ if len(com.Parents) != 1 || com.Parents[0] != prevHash {
+ t.Fatalf("bad parents: %+q, expect %q", com.Parents, prevHash)
+ }
+ prevHash = com.Hash
}
commits, err := repo.repo.ExtractFixTagsFromCommits("HEAD", extractFixTagsEmail)
if err != nil {
diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go
index 12130d594..777f0f7e7 100644
--- a/pkg/vcs/vcs.go
+++ b/pkg/vcs/vcs.go
@@ -74,6 +74,7 @@ type Commit struct {
AuthorName string
CC []string
Tags []string
+ Parents []string
Date time.Time
}