From 23173cfd661831a2479a2bf801b29d051b0a4ebf Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Thu, 1 Jun 2017 16:20:26 -0600 Subject: [PATCH] git: teach opt.WorkingDir to *git.RevListScanner --- git/rev_list_scanner.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/git/rev_list_scanner.go b/git/rev_list_scanner.go index 51233f40..ad4cd407 100644 --- a/git/rev_list_scanner.go +++ b/git/rev_list_scanner.go @@ -91,6 +91,10 @@ type ScanRefsOptions struct { // return only commits, or all objects in range by performing a // traversal of the graph. By default, false: show all objects. CommitsOnly bool + // WorkingDir specifies the working directory in which to run + // git-rev-list(1). If this is an empty string, (has len(WorkingDir) == + // 0), it is equivalent to running in os.Getwd(). + WorkingDir string // SkippedRefs provides a list of refs to ignore. SkippedRefs []string @@ -167,6 +171,9 @@ func NewRevListScanner(left, right string, opt *ScanRefsOptions) (*RevListScanne } cmd := exec.Command("git", args...) + if len(opt.WorkingDir) > 0 { + cmd.Dir = opt.WorkingDir + } cmd.Stdin = stdin stdout, err := cmd.StdoutPipe()