private string GetFetchArgs(string remote, string remoteBranch, string localBranch, bool? fetchTags, bool isUnshallow)
{
remote = remote.ToPosixPath();
//Remove spaces...
if (remoteBranch != null)
remoteBranch = remoteBranch.Replace(" ", "");
if (localBranch != null)
localBranch = localBranch.Replace(" ", "");
string remoteBranchArguments;
if (string.IsNullOrEmpty(remoteBranch))
remoteBranchArguments = "";
else
{
if (remoteBranch.StartsWith("+"))
remoteBranch = remoteBranch.Remove(0, 1);
remoteBranchArguments = "+" + FormatBranchName(remoteBranch);
}
string localBranchArguments;
var remoteUrl = GetPathSetting(string.Format(SettingKeyString.RemoteUrl, remote));
if (PathIsUrl(remote) && !string.IsNullOrEmpty(localBranch) && string.IsNullOrEmpty(remoteUrl))
localBranchArguments = ":" + GitCommandHelpers.GetFullBranchName(localBranch);
else if (string.IsNullOrEmpty(localBranch) || PathIsUrl(remote) || string.IsNullOrEmpty(remoteUrl))
localBranchArguments = "";
else
localBranchArguments = ":" + "refs/remotes/" + remote.Trim() + "/" + localBranch;
string arguments = fetchTags == true ? " --tags" : fetchTags == false ? " --no-tags" : "";
if (isUnshallow)
arguments += " --unshallow";
return "\"" + remote.Trim() + "\" " + remoteBranchArguments + localBranchArguments + arguments;
}