aboutsummaryrefslogtreecommitdiffstats
path: root/repository/git.go
diff options
context:
space:
mode:
authorSebastien Devaux <sebastien.devaux@laposte.net>2019-08-28 21:11:29 +0200
committerSebastien Devaux <sebastien.devaux@laposte.net>2019-08-28 21:11:29 +0200
commit1dc106279a883ca4aac2b1489ef8d4a441284899 (patch)
treeee24594bdd1ec14577c45bd0e3500dbe69c12582 /repository/git.go
parentddcbd8d022af0451ff87734fb443b27f98a490dd (diff)
downloadgit-bug-1dc106279a883ca4aac2b1489ef8d4a441284899.tar.gz
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.
Diffstat (limited to 'repository/git.go')
-rw-r--r--repository/git.go13
1 files changed, 11 insertions, 2 deletions
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