diff --git a/Git/Project.cs b/Git/Project.cs index 1acda0c..0e9437e 100644 --- a/Git/Project.cs +++ b/Git/Project.cs @@ -21,7 +21,7 @@ public void Init(string repository) if (!Directory.Exists(GitPath)) Directory.CreateDirectory(GitPath); if (!File.Exists(Path.Join(GitPath, ".git", "config"))) RunCommand($"init"); - RunCommand($"config remove-section remote.origin"); + RunCommandIgnoreErrors($"config remove-section remote.origin"); RunCommand($"remote add origin --mirror=fetch {repository}"); } @@ -137,6 +137,18 @@ public void SetBranchRef(string branch, string reference) RunCommand($"branch -f {branch} {reference}"); } + void RunCommandIgnoreErrors(string arguments) + { + try + { + RunCommand(arguments); + } + catch (ApplicationException) + { + // We are deliberately ignoring errors; RunCommand will have already printed them + } + } + void RunCommand(string arguments) { foreach (var line in GetCommandOutput(arguments, true))