New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #415 - branch names mangled by color escapes #416
Conversation
- 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 gitkraken#415
Thanks for your contribution! I'm surprised setting Here is the relevant code And if |
Yes, I was surprised that "color.ui=false" doesn't turn off all color output, as well. It may well be that it actually does turn off all color, but then is reversed by more specific overrides (such as "color.branch=always") at other configuration levels. I, personally, have "color.branch=always", "color.diff=always", and "color.status=always" set at the global level, so that I can, by default, get colored output even for redirections (eg, to Although this is the only issue that I'm encountering here, I do think that, ultimately, for robustness, all the verb specific color settings (branch, diff, interactive, status) should be set to "false" or "never" when parsing the Notably, the config setting disabling color (eg, "-c color.branch=never") can be reversed by a later setting within the same command line turning it back on (eg, "-c color.branch=always"). So, being a bit more DRY and disabling them all centrally would be fine even if you want to receive colored output for some specific commands. I don't know if there would be any performance penalty, but I doubt it given that most I can refactor this PR to be more general and centrally place all of those config settings if you'd prefer. |
While I'm slightly on the fence about centralizing them vs not. I think it might be better to keep them separate (i.e. associated with the specific command they apply to), just to keep the length of the command line down. So if you wouldn't mind adding the other settings to the relevant places I would be very grateful 😄. Also please set them to Thank you! |
Done. I found three uses of 'diff' and two uses of 'status', and I modified the config options of all of them. All are using "false". But, FYI, I only looked for uses within "src/git/git.ts". It appeared that that was where everything was localized. Let me know if there are other areas to change. The final result is working correctly for me. |
Looks great! Thank you! |
.# Discussion
Branch names are mis-parsed if
git branch
output is colored (eg, when git is configuredwith "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