From 3e783f2632fd7f283ecbb0b487806681da55f97e Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 5 Feb 2026 13:19:13 +0100 Subject: tools: add syz-base-commit tool The tool is aimed to facilitate debugging of the cases when the blob-based base commit functionality did not work as expected or to determine the missing remote trees. --- tools/syz-base-commit/main.go | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tools/syz-base-commit/main.go (limited to 'tools/syz-base-commit') diff --git a/tools/syz-base-commit/main.go b/tools/syz-base-commit/main.go new file mode 100644 index 000000000..f5af3b075 --- /dev/null +++ b/tools/syz-base-commit/main.go @@ -0,0 +1,50 @@ +// Copyright 2020 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +// syz-base-commit is a tool for debugging the blob-based base commit detection functionality. + +package main + +import ( + "flag" + "log" + "os" + + "github.com/google/syzkaller/pkg/debugtracer" + "github.com/google/syzkaller/pkg/tool" + "github.com/google/syzkaller/pkg/vcs" +) + +var ( + flagRepo = flag.String("sourcedir", "", "path to the Linux kernel repository") +) + +func main() { + defer tool.Init()() + args := flag.Args() + if *flagRepo == "" || len(args) != 1 { + tool.Failf("expected format: syz-base-commit --sourcedir ./linux-repo some-patch.diff") + } + log.Printf("note: the tool runs much faster after a `git commit-graph write --reachable`") + diff, err := os.ReadFile(args[0]) + if err != nil { + tool.Fail(err) + } + git := &vcs.Git{ + Dir: *flagRepo, + } + commits, err := git.BaseForDiff(diff, &debugtracer.GenericTracer{ + TraceWriter: os.Stderr, + }) + if err != nil { + tool.Fail(err) + } + if len(commits) == 0 { + log.Printf("no suitable commits found!") + os.Exit(0) + } + log.Printf("found %d candidates:", len(commits)) + for _, commit := range commits { + log.Printf("%+v", commit) + } +} -- cgit mrf-deployment