Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)

// If an SSH private key was provided, sets the environment.
if (!start.Environment.ContainsKey("GIT_SSH_COMMAND") && !string.IsNullOrEmpty(SSHKey))
start.Environment.Add("GIT_SSH_COMMAND", $"ssh -i '{SSHKey}' -F '/dev/null'");
start.Environment.Add("GIT_SSH_COMMAND", $"ssh -i '{SSHKey}' -F '{Native.OS.NullDevice}'");

// Force using en_US.UTF-8 locale
if (OperatingSystem.IsLinux())
Expand Down
2 changes: 1 addition & 1 deletion src/Models/DiffOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public DiffOption(Change change, bool isUnstaged)
case ChangeState.Added:
case ChangeState.Untracked:
_extra = "--no-index";
_orgPath = "/dev/null";
_orgPath = Native.OS.NullDevice;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/DiffResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void GenerateNewPatchFromSelection(Change change, string fileBlobGuid, Te
if (!revert && !isTracked)
writer.WriteLine("new file mode 100644");
writer.WriteLine($"index 00000000...{fileGuid}");
writer.WriteLine($"--- {(revert || isTracked ? $"a/{change.Path}" : "/dev/null")}");
writer.WriteLine($"--- {(revert || isTracked ? $"a/{change.Path}" : Native.OS.NullDevice)}");
writer.WriteLine($"+++ b/{change.Path}");

var additions = selection.EndLine - selection.StartLine;
Expand Down
8 changes: 8 additions & 0 deletions src/Native/OS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public interface IBackend
void OpenWithDefaultEditor(string file);
}

public static readonly string NullDevice = OperatingSystem.IsWindows() ? "NUL" : "/dev/null";

public static bool IsNullDevice(string path)
{
return path.Equals("/dev/null", StringComparison.Ordinal) ||
path.Equals("NUL", StringComparison.OrdinalIgnoreCase);
}

public static string DataDir
{
get;
Expand Down
4 changes: 2 additions & 2 deletions src/ViewModels/DiffContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public DiffContext(string repo, Models.DiffOption option, DiffContext previous =
_info = previous._info;
}

if (string.IsNullOrEmpty(_option.OrgPath) || _option.OrgPath == "/dev/null")
if (string.IsNullOrEmpty(_option.OrgPath) || Native.OS.IsNullDevice(_option.OrgPath))
Title = _option.Path;
else
Title = $"{_option.OrgPath} → {_option.Path}";
Expand Down Expand Up @@ -216,7 +216,7 @@ private void LoadContent()
}
else
{
if (!oldPath.Equals("/dev/null", StringComparison.Ordinal))
if (!Native.OS.IsNullDevice(oldPath))
{
var oldImage = await ImageSource.FromRevisionAsync(_repo, "HEAD", oldPath, imgDecoder).ConfigureAwait(false);
imgDiff.Old = oldImage.Bitmap;
Expand Down