Skip to content
Open
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
12 changes: 12 additions & 0 deletions src/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public enum EditorType
public bool RaiseError { get; set; } = true;
public Models.ICommandLog Log { get; set; } = null;

internal static string GetRepositoryConfigArguments(string repo)
{
if (!OperatingSystem.IsWindows())
return string.Empty;

return ViewModels.Preferences.Instance.IgnoresFileMode(repo)
? "-c core.longpaths=true -c core.filemode=false "
: "-c core.longpaths=true ";
}

public async Task<bool> ExecAsync()
{
Log?.AppendLine($"$ git {Args}\n");
Expand Down Expand Up @@ -165,6 +175,8 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)
if (useSetSid)
builder.Append(Native.OS.GitExecutable.Quoted()).Append(' ');

builder.Append(GetRepositoryConfigArguments(WorkingDirectory));

builder
.Append("--no-pager -c core.quotepath=off -c credential.helper=")
.Append(Native.OS.CredentialHelper)
Expand Down
3 changes: 3 additions & 0 deletions src/Commands/Discard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public static async Task AllAsync(string repo, bool includeModified, bool includ
{
// Untracked paths that contains `.git` file (detached submodule) must be removed manually.
var changes = await new QueryLocalChanges(repo).GetResultAsync().ConfigureAwait(false);
if (changes == null)
return;

try
{
foreach (var c in changes)
Expand Down
36 changes: 24 additions & 12 deletions src/Commands/QueryLocalChanges.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -40,17 +41,15 @@ public QueryLocalChanges(string repo, bool includeUntracked = true, bool noOptio
proc.StartInfo = CreateGitStartInfo(true);
proc.Start();

if (CancellationToken.CanBeCanceled)
using var registration = CancellationToken.Register(() =>
{
CancellationToken.Register(() =>
lock (capturedLock)
{
lock (capturedLock)
{
if (captured is { Process: { HasExited: false } proc })
Native.OS.TerminateProcess(proc);
}
});
}
if (captured is { Process: { HasExited: false } running })
Native.OS.TerminateProcess(running);
}
});
var errorTask = proc.StandardError.ReadToEndAsync();

while (await proc.StandardOutput.ReadLineAsync().ConfigureAwait(false) is { } line)
{
Expand Down Expand Up @@ -181,14 +180,27 @@ public QueryLocalChanges(string repo, bool includeUntracked = true, bool noOptio
outs.Add(change);
}

await proc.WaitForExitAsync().ConfigureAwait(false);
var error = await errorTask.ConfigureAwait(false);
lock (capturedLock)
{
captured.Process = null;
}

if (CancellationToken.IsCancellationRequested)
return null;

if (proc.ExitCode != 0)
{
RaiseException(string.IsNullOrWhiteSpace(error) ? "Failed to query local changes." : error.Trim());
return null;
}
}
catch
catch (Exception e)
{
// Ignore exceptions.
if (!CancellationToken.IsCancellationRequested)
RaiseException($"Failed to query local changes: {e.Message}");
return null;
}

return outs;
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/SaveChangesAsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static async Task<bool> ProcessSingleChangeAsync(string repo, Models.Dif
var starter = new ProcessStartInfo();
starter.WorkingDirectory = repo;
starter.FileName = Native.OS.GitExecutable;
starter.Arguments = $"diff --no-color --no-ext-diff --ignore-cr-at-eol --unified=4 {opt}";
starter.Arguments = $"{Command.GetRepositoryConfigArguments(repo)}diff --no-color --no-ext-diff --ignore-cr-at-eol --unified=4 {opt}";
starter.UseShellExecute = false;
starter.CreateNoWindow = true;
starter.WindowStyle = ProcessWindowStyle.Hidden;
Expand Down
2 changes: 2 additions & 0 deletions src/Models/DiffResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public class EmptyFile

public class NoOrEOLChange;

public class FileModeOnlyChange : NoOrEOLChange;

public class SubmoduleDiff
{
public string FullPath { get; set; } = string.Empty;
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/ca_ES.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Adreça de correu electrònic</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">Pregunta abans d'actualitzar automàticament els submòduls</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows" xml:space="preserve">Ignore executable permission changes in this repository (Windows)</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows.Tip" xml:space="preserve">Applies only to this SourceGit installation on Windows. Staged permission changes remain visible.</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Obtén els remots automàticament</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Minut(s)</x:String>
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">Tipus de comissió convencionals</x:String>
Expand Down Expand Up @@ -387,6 +389,7 @@
<x:String x:Key="Text.Diff.New" xml:space="preserve">NOU</x:String>
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Diferència següent</x:String>
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">SENSE CANVIS O NOMÉS CANVIS DE FI DE LÍNIA</x:String>
<x:String x:Key="Text.Diff.FileModeChange" xml:space="preserve">File permissions changed; other differences may be hidden.</x:String>
<x:String x:Key="Text.Diff.Old" xml:space="preserve">ANTIC</x:String>
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Diferència anterior</x:String>
<x:String x:Key="Text.Diff.SaveAsPatch" xml:space="preserve">Desa com a pedaç</x:String>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/de_DE.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ $1, $2, … Werte der Eingabe-Steuerelemente</x:String>
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">E-Mail-Adresse</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">Vor dem Auto-Aktualisieren von Submodulen fragen</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows" xml:space="preserve">Ignore executable permission changes in this repository (Windows)</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows.Tip" xml:space="preserve">Applies only to this SourceGit installation on Windows. Staged permission changes remain visible.</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Remotes automatisch fetchen</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Minute(n)</x:String>
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">Konventionelle Commit-Typen</x:String>
Expand Down Expand Up @@ -373,6 +375,7 @@ $1, $2, … Werte der Eingabe-Steuerelemente</x:String>
<x:String x:Key="Text.Diff.New" xml:space="preserve">NEU</x:String>
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Nächster Unterschied</x:String>
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">KEINE ÄNDERUNG ODER NUR ZEILENENDE-ÄNDERUNGEN</x:String>
<x:String x:Key="Text.Diff.FileModeChange" xml:space="preserve">File permissions changed; other differences may be hidden.</x:String>
<x:String x:Key="Text.Diff.Old" xml:space="preserve">ALT</x:String>
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Vorheriger Unterschied</x:String>
<x:String x:Key="Text.Diff.SaveAsPatch" xml:space="preserve">Als Patch speichern</x:String>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/el_GR.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Διεύθυνση email</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">Ερώτηση πριν την αυτόματη ενημέρωση υπομονάδων</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows" xml:space="preserve">Ignore executable permission changes in this repository (Windows)</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows.Tip" xml:space="preserve">Applies only to this SourceGit installation on Windows. Staged permission changes remain visible.</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Αυτόματο fetch από τα απομακρυσμένα</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Λεπτό(-ά)</x:String>
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">Τύποι Conventional Commit</x:String>
Expand Down Expand Up @@ -373,6 +375,7 @@
<x:String x:Key="Text.Diff.New" xml:space="preserve">ΝΕΟ</x:String>
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Επόμενη διαφορά</x:String>
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">ΚΑΜΙΑ ΑΛΛΑΓΗ Ή ΜΟΝΟ ΑΛΛΑΓΕΣ EOL</x:String>
<x:String x:Key="Text.Diff.FileModeChange" xml:space="preserve">File permissions changed; other differences may be hidden.</x:String>
<x:String x:Key="Text.Diff.Old" xml:space="preserve">ΠΑΛΙΟ</x:String>
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Προηγούμενη διαφορά</x:String>
<x:String x:Key="Text.Diff.SaveAsPatch" xml:space="preserve">Αποθήκευση ως Patch</x:String>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/en_US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Email address</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">Ask before auto-updating submodules</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows" xml:space="preserve">Ignore executable permission changes in this repository (Windows)</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows.Tip" xml:space="preserve">Applies only to this SourceGit installation on Windows. Staged permission changes remain visible.</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Fetch remotes automatically</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Minute(s)</x:String>
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">Conventional Commit Types</x:String>
Expand Down Expand Up @@ -384,6 +386,7 @@
<x:String x:Key="Text.Diff.New" xml:space="preserve">NEW</x:String>
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Next Difference</x:String>
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">NO CHANGES OR ONLY EOL CHANGES</x:String>
<x:String x:Key="Text.Diff.FileModeChange" xml:space="preserve">File permissions changed; other differences may be hidden.</x:String>
<x:String x:Key="Text.Diff.Old" xml:space="preserve">OLD</x:String>
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Previous Difference</x:String>
<x:String x:Key="Text.Diff.SaveAsPatch" xml:space="preserve">Save as Patch</x:String>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/es_ES.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Dirección de email</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">Preguntar antes de actualizar automáticamente los submódulos</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows" xml:space="preserve">Ignore executable permission changes in this repository (Windows)</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows.Tip" xml:space="preserve">Applies only to this SourceGit installation on Windows. Staged permission changes remain visible.</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Fetch remotos automáticamente</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Minuto(s)</x:String>
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">Tipos de Commit Convencionales</x:String>
Expand Down Expand Up @@ -388,6 +390,7 @@
<x:String x:Key="Text.Diff.New" xml:space="preserve">NUEVO</x:String>
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Siguiente Diferencia</x:String>
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">SIN CAMBIOS O SOLO CAMBIOS DE EOL</x:String>
<x:String x:Key="Text.Diff.FileModeChange" xml:space="preserve">File permissions changed; other differences may be hidden.</x:String>
<x:String x:Key="Text.Diff.Old" xml:space="preserve">VIEJO</x:String>
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Diferencia Anterior</x:String>
<x:String x:Key="Text.Diff.SaveAsPatch" xml:space="preserve">Guardar como Parche</x:String>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/fr_FR.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Adresse e-mail</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">Demander avant mise à jour automatique des sous-modules</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows" xml:space="preserve">Ignore executable permission changes in this repository (Windows)</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows.Tip" xml:space="preserve">Applies only to this SourceGit installation on Windows. Staged permission changes remain visible.</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Fetch les dépôts distants automatiquement</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">minute(s)</x:String>
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">Types de commit conventionnels</x:String>
Expand Down Expand Up @@ -359,6 +361,7 @@
<x:String x:Key="Text.Diff.New" xml:space="preserve">NOUVEAU</x:String>
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Différence suivante</x:String>
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">PAS DE CHANGEMENT OU SEULEMENT EN FIN DE LIGNE</x:String>
<x:String x:Key="Text.Diff.FileModeChange" xml:space="preserve">File permissions changed; other differences may be hidden.</x:String>
<x:String x:Key="Text.Diff.Old" xml:space="preserve">ANCIEN</x:String>
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Différence précédente</x:String>
<x:String x:Key="Text.Diff.SaveAsPatch" xml:space="preserve">Enregistrer en tant que patch</x:String>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/he_IL.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">כתובת דוא"ל</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">לבקש אישור לפני עדכון אוטומטי של submodules</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows" xml:space="preserve">Ignore executable permission changes in this repository (Windows)</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows.Tip" xml:space="preserve">Applies only to this SourceGit installation on Windows. Staged permission changes remain visible.</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Fetch אוטומטי מ־remotes</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">דקות</x:String>
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">סוגי Conventional Commit</x:String>
Expand Down Expand Up @@ -359,6 +361,7 @@
<x:String x:Key="Text.Diff.New" xml:space="preserve">חדש</x:String>
<x:String x:Key="Text.Diff.Next" xml:space="preserve">ההבדל הבא</x:String>
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">אין שינויים או רק שינויי EOL</x:String>
<x:String x:Key="Text.Diff.FileModeChange" xml:space="preserve">File permissions changed; other differences may be hidden.</x:String>
<x:String x:Key="Text.Diff.Old" xml:space="preserve">ישן</x:String>
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">ההבדל הקודם</x:String>
<x:String x:Key="Text.Diff.SaveAsPatch" xml:space="preserve">שמור כ־Patch</x:String>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/Locales/id_ID.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Alamat email</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">Tanyakan sebelum memperbarui submodule secara otomatis</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows" xml:space="preserve">Ignore executable permission changes in this repository (Windows)</x:String>
<x:String x:Key="Text.Configure.Git.IgnoreFileModeOnWindows.Tip" xml:space="preserve">Applies only to this SourceGit installation on Windows. Staged permission changes remain visible.</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Fetch remote secara otomatis</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Menit</x:String>
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">Tipe Conventional Commit</x:String>
Expand Down Expand Up @@ -373,6 +375,7 @@
<x:String x:Key="Text.Diff.New" xml:space="preserve">BARU</x:String>
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Perbedaan Berikutnya</x:String>
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">TIDAK ADA PERUBAHAN ATAU HANYA PERUBAHAN EOL</x:String>
<x:String x:Key="Text.Diff.FileModeChange" xml:space="preserve">File permissions changed; other differences may be hidden.</x:String>
<x:String x:Key="Text.Diff.Old" xml:space="preserve">LAMA</x:String>
<x:String x:Key="Text.Diff.Prev" xml:space="preserve">Perbedaan Sebelumnya</x:String>
<x:String x:Key="Text.Diff.SaveAsPatch" xml:space="preserve">Simpan sebagai Patch</x:String>
Expand Down
Loading