aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Devaux <sebastien.devaux@laposte.net>2019-08-24 22:42:25 +0200
committerSebastien Devaux <sebastien.devaux@laposte.net>2019-08-24 22:42:25 +0200
commit7e123fbfcae76e3ad188cfa5e98c27adcde8d6d7 (patch)
tree8dab22f51e01ebf286ba9a9c0cc61244a313586f
parent91f563da5f508cfcc5dfe6418e2f6333e247ec6e (diff)
downloadgit-bug-7e123fbfcae76e3ad188cfa5e98c27adcde8d6d7.tar.gz
issue 178: fetch the repo dir with rev-parse --git-dir
Since is returns the .git dir directly, it is not more needed to concatenate .git.
-rw-r--r--cache/repo_cache.go6
-rw-r--r--commands/select/select.go2
-rw-r--r--input/input.go6
-rw-r--r--repository/git.go11
4 files changed, 13 insertions, 12 deletions
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index 107a4876..bc095856 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -350,11 +350,11 @@ func (c *RepoCache) writeIdentityCache() error {
}
func bugCacheFilePath(repo repository.Repo) string {
- return path.Join(repo.GetPath(), ".git", "git-bug", bugCacheFile)
+ return path.Join(repo.GetPath(), "git-bug", bugCacheFile)
}
func identityCacheFilePath(repo repository.Repo) string {
- return path.Join(repo.GetPath(), ".git", "git-bug", identityCacheFile)
+ return path.Join(repo.GetPath(), "git-bug", identityCacheFile)
}
func (c *RepoCache) buildCache() error {
@@ -706,7 +706,7 @@ func (c *RepoCache) Pull(remote string) error {
}
func repoLockFilePath(repo repository.Repo) string {
- return path.Join(repo.GetPath(), ".git", "git-bug", lockfile)
+ return path.Join(repo.GetPath(), "git-bug", lockfile)
}
// repoIsAvailable check is the given repository is locked by a Cache.
diff --git a/commands/select/select.go b/commands/select/select.go
index fdc87154..cf861fcc 100644
--- a/commands/select/select.go
+++ b/commands/select/select.go
@@ -137,5 +137,5 @@ func selected(repo *cache.RepoCache) (*cache.BugCache, error) {
}
func selectFilePath(repo repository.RepoCommon) string {
- return path.Join(repo.GetPath(), ".git", "git-bug", selectFile)
+ return path.Join(repo.GetPath(), "git-bug", selectFile)
}
diff --git a/input/input.go b/input/input.go
index 789373b0..ca787ceb 100644
--- a/input/input.go
+++ b/input/input.go
@@ -239,7 +239,7 @@ func QueryEditorInput(repo repository.RepoCommon, preQuery string) (string, erro
// launchEditorWithTemplate will launch an editor as launchEditor do, but with a
// provided template.
func launchEditorWithTemplate(repo repository.RepoCommon, fileName string, template string) (string, error) {
- path := fmt.Sprintf("%s/.git/%s", repo.GetPath(), fileName)
+ path := fmt.Sprintf("%s/%s", repo.GetPath(), fileName)
err := ioutil.WriteFile(path, []byte(template), 0644)
@@ -254,13 +254,13 @@ func launchEditorWithTemplate(repo repository.RepoCommon, fileName string, templ
// method blocks until the editor command has returned.
//
// The specified filename should be a temporary file and provided as a relative path
-// from the repo (e.g. "FILENAME" will be converted to ".git/FILENAME"). This file
+// from the repo (e.g. "FILENAME" will be converted to "[<reporoot>/].git/FILENAME"). This file
// will be deleted after the editor is closed and its contents have been read.
//
// This method returns the text that was read from the temporary file, or
// an error if any step in the process failed.
func launchEditor(repo repository.RepoCommon, fileName string) (string, error) {
- path := fmt.Sprintf("%s/.git/%s", repo.GetPath(), fileName)
+ path := fmt.Sprintf("%s/%s", repo.GetPath(), fileName)
defer os.Remove(path)
editor, err := repo.GetCoreEditor()
diff --git a/repository/git.go b/repository/git.go
index 9ec7905a..c03cf979 100644
--- a/repository/git.go
+++ b/repository/git.go
@@ -17,8 +17,8 @@ import (
"github.com/MichaelMure/git-bug/util/lamport"
)
-const createClockFile = "/.git/git-bug/create-clock"
-const editClockFile = "/.git/git-bug/edit-clock"
+const createClockFile = "/git-bug/create-clock"
+const editClockFile = "/git-bug/edit-clock"
// ErrNotARepo is the error returned when the git repo root wan't be found
var ErrNotARepo = errors.New("not a git repository")
@@ -76,10 +76,11 @@ func NewGitRepo(path string, witnesser Witnesser) (*GitRepo, error) {
repo := &GitRepo{Path: path}
// Check the repo and retrieve the root path
- stdout, err := repo.runGitCommand("rev-parse", "--show-toplevel")
+ stdout, err := repo.runGitCommand("rev-parse", "--git-dir")
- // for some reason, "git rev-parse --show-toplevel" return nothing
- // and no error when inside a ".git" dir
+ // Now dir is fetched with "git rev-parse --git-dir". May be it can
+ // still return nothing in some cases. Then empty stdout check is
+ // kept.
if err != nil || stdout == "" {
return nil, ErrNotARepo
}