From 1dc106279a883ca4aac2b1489ef8d4a441284899 Mon Sep 17 00:00:00 2001 From: Sebastien Devaux Date: Wed, 28 Aug 2019 21:11:29 +0200 Subject: issue 178: refined git command cwd setting. For unknown reason setting .git as current directory for the called git command fails when git-bug is called from a git hook (and it was observed only in this case). Forcing use of current dir when the repo path is ".git" restore the expected behavior. --- repository/git.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'repository/git.go') diff --git a/repository/git.go b/repository/git.go index d9a92c82..3c60f244 100644 --- a/repository/git.go +++ b/repository/git.go @@ -34,10 +34,19 @@ type GitRepo struct { // Run the given git command with the given I/O reader/writers, returning an error if it fails. func (repo *GitRepo) runGitCommandWithIO(stdin io.Reader, stdout, stderr io.Writer, args ...string) error { - // fmt.Printf("[%s] Running git %s\n", repo.Path, strings.Join(args, " ")) + repopath:=repo.Path + if repopath==".git" { + // seeduvax> trangely the git command sometimes fail for very unknown + // reason wihtout this replacement. + // observed with rev-list command when git-bug is called from git + // hook script, even the same command with same args runs perfectly + // when called directly from the same hook script. + repopath="" + } + // fmt.Printf("[%s] Running git %s\n", repopath, strings.Join(args, " ")) cmd := exec.Command("git", args...) - cmd.Dir = repo.Path + cmd.Dir = repopath cmd.Stdin = stdin cmd.Stdout = stdout cmd.Stderr = stderr -- cgit