1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-07 22:02:56 +03:00

support general git config calls

This commit is contained in:
Jesse Duffield
2022-01-07 20:17:23 +11:00
parent 610e503296
commit e8229f0ee0
5 changed files with 56 additions and 15 deletions

View File

@@ -35,11 +35,8 @@ import (
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
func getGitConfigValue(key string) (string, error) {
// allowing caller to say that key is '--local mykey' so that they can add extra flags.
gitArgs := append([]string{"config", "--get", "--null"}, strings.Split(key, " ")...)
func runGitConfigCmd(cmd *exec.Cmd) (string, error) {
var stdout bytes.Buffer
cmd := secureexec.Command("git", gitArgs...)
cmd.Stdout = &stdout
cmd.Stderr = ioutil.Discard
@@ -55,3 +52,13 @@ func getGitConfigValue(key string) (string, error) {
return strings.TrimRight(stdout.String(), "\000"), nil
}
func getGitConfigCmd(key string) *exec.Cmd {
gitArgs := []string{"config", "--get", "--null", key}
return secureexec.Command("git", gitArgs...)
}
func getGitConfigGeneralCmd(args string) *exec.Cmd {
gitArgs := append([]string{"config"}, strings.Split(args, " ")...)
return secureexec.Command("git", gitArgs...)
}