Skip to content

Commit 860f521

Browse files
authored
fix: Force English locale in branch query command. (#1078)
1 parent b4fbc23 commit 860f521

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Commands/Command.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public enum EditorType
3737
public string Args { get; set; } = string.Empty;
3838
public bool RaiseError { get; set; } = true;
3939
public bool TraitErrorAsOutput { get; set; } = false;
40+
protected bool ForceEnglishLocale { get; set; } = false;
4041

4142
public bool Exec()
4243
{
@@ -193,8 +194,11 @@ private ProcessStartInfo CreateGitStartInfo()
193194
start.Environment.Add("GIT_SSH_COMMAND", $"ssh -i '{SSHKey}'");
194195

195196
// Force using en_US.UTF-8 locale to avoid GCM crash
196-
if (OperatingSystem.IsLinux())
197-
start.Environment.Add("LANG", "en_US.UTF-8");
197+
if (ForceEnglishLocale || OperatingSystem.IsLinux())
198+
{
199+
start.Environment.Add("LANG", "C");
200+
start.Environment.Add("LC_ALL", "C");
201+
}
198202

199203
// Fix macOS `PATH` env
200204
if (OperatingSystem.IsMacOS() && !string.IsNullOrEmpty(Native.OS.CustomPathEnv))

src/Commands/ExecuteCustomAction.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ public static void Run(string repo, string file, string args)
1919

2020
// Force using en_US.UTF-8 locale to avoid GCM crash
2121
if (OperatingSystem.IsLinux())
22-
start.Environment.Add("LANG", "en_US.UTF-8");
22+
{
23+
start.Environment.Add("LANG", "C");
24+
start.Environment.Add("LC_ALL", "C");
25+
}
2326

2427
// Fix macOS `PATH` env
2528
if (OperatingSystem.IsMacOS() && !string.IsNullOrEmpty(Native.OS.CustomPathEnv))
@@ -50,7 +53,10 @@ public static void RunAndWait(string repo, string file, string args, Action<stri
5053

5154
// Force using en_US.UTF-8 locale to avoid GCM crash
5255
if (OperatingSystem.IsLinux())
53-
start.Environment.Add("LANG", "en_US.UTF-8");
56+
{
57+
start.Environment.Add("LANG", "C");
58+
start.Environment.Add("LC_ALL", "C");
59+
}
5460

5561
// Fix macOS `PATH` env
5662
if (OperatingSystem.IsMacOS() && !string.IsNullOrEmpty(Native.OS.CustomPathEnv))

src/Commands/QueryBranches.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public QueryBranches(string repo)
1414
{
1515
WorkingDirectory = repo;
1616
Context = repo;
17+
ForceEnglishLocale = true;
1718
Args = "branch -l --all -v --format=\"%(refname)%00%(objectname)%00%(HEAD)%00%(upstream)%00%(upstream:trackshort)\"";
1819
}
1920

0 commit comments

Comments
 (0)