From 3991f4a11ed88bd2682d6250fac7b93fbf77a7e2 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Wed, 13 Jun 2018 22:16:20 -0500 Subject: [PATCH] Fixes #415 - branch names mangled by color escapes - add "-c color.branch=never" option to git branch commands, definitively disabling color branch output .# Discussion Branch names are mis-parsed if `git branch` output is colored (eg, when git is configured with "config.branch=always"). Using the base "-c color.branch=never" option overrides any user configuration, displaying git branch output as uncolored in all cases and fixing the issue. Notably, option ordering is important in this instance. The "-c ..." option is a git base option, not a git branch subcommand option. So, as done here, it must be inserted before the "branch" subcommand. ref: Issue #415 --- src/git/git.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/git/git.ts b/src/git/git.ts index d7b518d..a3b3caf 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -325,7 +325,7 @@ export class Git { } static branch(repoPath: string, options: { all: boolean } = { all: false }) { - const params = ['branch', '-vv']; + const params = ['-c', 'color.branch=never', 'branch', '-vv']; if (options.all) { params.push('-a'); } @@ -334,7 +334,7 @@ export class Git { } static branch_contains(repoPath: string, ref: string, options: { remote: boolean } = { remote: false }) { - const params = ['branch', '--contains']; + const params = ['-c', 'color.branch=never', 'branch', '--contains']; if (options.remote) { params.push('-r'); }