From 979968208551dfc1d3ab448cc8f260c20f9b9c0f Mon Sep 17 00:00:00 2001 From: Songmu Date: Mon, 13 May 2019 00:15:42 +0900 Subject: [PATCH] don't specify --path in gitutil.Config and specify --bool when getting ghq.completeUser --- gitutil/git.go | 7 ++++--- remote_repository.go | 2 +- url.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gitutil/git.go b/gitutil/git.go index 0c7cc8e7..c71b6b62 100644 --- a/gitutil/git.go +++ b/gitutil/git.go @@ -14,12 +14,13 @@ import ( // ConfigSingle fetches single git-config variable. // returns an empty string and no error if no variable is found with the given key. func ConfigSingle(key string) (string, error) { - return Config("--get", key) + // --path option expands tilde(~) + return Config("--path", "--get", key) } // ConfigAll fetches git-config variable of multiple values. func ConfigAll(key string) ([]string, error) { - value, err := Config("--get-all", key) + value, err := Config("--path", "--get-all", key) if err != nil { return nil, err } @@ -34,7 +35,7 @@ func ConfigAll(key string) ([]string, error) { // Config invokes 'git config' and handles some errors properly. func Config(args ...string) (string, error) { - gitArgs := append([]string{"config", "--path", "--null"}, args...) + gitArgs := append([]string{"config", "--null"}, args...) cmd := exec.Command("git", gitArgs...) cmd.Stderr = os.Stderr diff --git a/remote_repository.go b/remote_repository.go index e9dc4b92..03ea49ff 100644 --- a/remote_repository.go +++ b/remote_repository.go @@ -108,7 +108,7 @@ func (repo *OtherRepository) VCS() (*VCSBackend, *url.URL) { // (in gitconfig:) // [ghq "https://ghe.example.com/"] // vcs = github - vcs, err := gitutil.Config("--get-urlmatch", "ghq.vcs", repo.URL().String()) + vcs, err := gitutil.Config("--path", "--get-urlmatch", "ghq.vcs", repo.URL().String()) if err != nil { logger.Log("error", err.Error()) } diff --git a/url.go b/url.go index e4a2d3c9..a8bc6805 100644 --- a/url.go +++ b/url.go @@ -74,7 +74,7 @@ func convertGitURLHTTPToSSH(url *url.URL) (*url.URL, error) { } func fillUsernameToPath(path string) (string, error) { - completeUser, err := gitutil.ConfigSingle("ghq.completeUser") + completeUser, err := gitutil.Config("--bool", "--get", "ghq.completeUser") if err != nil { return path, err }