Skip to content
Merged
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
26 changes: 26 additions & 0 deletions src/Commands/QueryGitCommonDir.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.IO;

namespace SourceGit.Commands
{
public class QueryGitCommonDir : Command
{
public QueryGitCommonDir(string workDir)
{
WorkingDirectory = workDir;
Args = "rev-parse --git-common-dir";
RaiseError = false;
}

public string Result()
{
var rs = ReadToEnd().StdOut;
if (string.IsNullOrEmpty(rs))
return null;

rs = rs.Trim();
if (Path.IsPathRooted(rs))
return rs;
return Path.GetFullPath(Path.Combine(WorkingDirectory, rs));
}
}
}
1 change: 1 addition & 0 deletions src/Models/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public interface IRepository
{
string FullPath { get; set; }
string GitDir { get; set; }
string GitCommonDir { get; set; }

void RefreshBranches();
void RefreshWorktrees();
Expand Down
6 changes: 1 addition & 5 deletions src/Models/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ public Watcher(IRepository repo)
_wcWatcher.EnableRaisingEvents = true;

// If this repository is a worktree repository, just watch the main repository's gitdir.
var gitDirNormalized = _repo.GitDir.Replace("\\", "/");
var worktreeIdx = gitDirNormalized.IndexOf(".git/worktrees/", StringComparison.Ordinal);
var repoWatchDir = _repo.GitDir;
if (worktreeIdx > 0)
repoWatchDir = _repo.GitDir.Substring(0, worktreeIdx + 4);
var repoWatchDir = _repo.GitCommonDir.Replace("\\", "/");

_repoWatcher = new FileSystemWatcher();
_repoWatcher.Path = repoWatchDir;
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/de_DE.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">Remote löschen</x:String>
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">Ziel:</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">Worktrees löschen</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Worktree Informationen in `$GIT_DIR/worktrees` löschen</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Worktree Informationen in `$GIT_COMMON_DIR/worktrees` löschen</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">Pull</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Remote-Branch:</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">Alle Branches fetchen</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/en_US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">Prune Remote</x:String>
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">Target:</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">Prune Worktrees</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Prune worktree information in `$GIT_DIR/worktrees`</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Prune worktree information in `$GIT_COMMON_DIR/worktrees`</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">Pull</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Remote Branch:</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">Fetch all branches</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/es_ES.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">Podar Remoto</x:String>
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">Destino:</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">Podar Worktrees</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Podar información de worktree en `$GIT_DIR/worktrees`</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Podar información de worktree en `$GIT_COMMON_DIR/worktrees`</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">Pull</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Rama Remota:</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">Fetch todas las ramas</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/fr_FR.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">Élaguer une branche distant</x:String> <!-- If it is indeed about a branch -->
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">Cible :</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">Élaguer les Worktrees</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve"> Élaguer les information de worktree dans `$GIT_DIR/worktrees`</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve"> Élaguer les information de worktree dans `$GIT_COMMON_DIR/worktrees`</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">Pull</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Branche distante :</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">Fetch toutes les branches</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/it_IT.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">Potatura Remota</x:String>
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">Destinazione:</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">Potatura Worktrees</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Potatura delle informazioni di worktree in `$GIT_DIR/worktrees`</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Potatura delle informazioni di worktree in `$GIT_COMMON_DIR/worktrees`</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">Scarica</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Branch Remoto:</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">Recupera tutti i branch</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/pt_BR.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">Prunar Remoto</x:String>
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">Alvo:</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">Podar Worktrees</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Podar informações de worktree em `$GIT_DIR/worktrees`</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Podar informações de worktree em `$GIT_COMMON_DIR/worktrees`</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">Puxar</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Branch Remoto:</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">Buscar todos os branches</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/ru_RU.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">Удалить внешний репозиторий</x:String>
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">Цель:</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">Удалить рабочий каталог</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Информация об обрезке рабочего каталога в «$GIT_DIR/worktrees»</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Информация об обрезке рабочего каталога в «$GIT_COMMON_DIR/worktrees»</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">Забрать</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Ветка внешнего репозитория:</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">Извлечь все ветки</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/zh_CN.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">清理远程已删除分支</x:String>
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">目标 :</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">清理工作树</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">清理在`$GIT_DIR/worktrees`中的无效工作树信息</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">清理在`$GIT_COMMON_DIR/worktrees`中的无效工作树信息</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">拉回(pull)</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">拉取分支 :</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">拉取远程中的所有分支变更</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Locales/zh_TW.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
<x:String x:Key="Text.PruneRemote" xml:space="preserve">清理遠端已刪除分支</x:String>
<x:String x:Key="Text.PruneRemote.Target" xml:space="preserve">目標:</x:String>
<x:String x:Key="Text.PruneWorktrees" xml:space="preserve">清理工作區</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">清理在 `$GIT_DIR/worktrees` 中的無效工作區資訊</x:String>
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">清理在 `$GIT_COMMON_DIR/worktrees` 中的無效工作區資訊</x:String>
<x:String x:Key="Text.Pull" xml:space="preserve">拉取 (pull)</x:String>
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">拉取分支:</x:String>
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">拉取遠端中的所有分支</x:String>
Expand Down
6 changes: 5 additions & 1 deletion src/ViewModels/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public void OpenRepositoryInTab(RepositoryNode node, LauncherPage page)

var isBare = new Commands.IsBareRepository(node.Id).Result();
var gitDir = node.Id;
var gitCommonDir = gitDir;
if (!isBare)
{
gitDir = new Commands.QueryGitDir(node.Id).Result();
Expand All @@ -291,9 +292,12 @@ public void OpenRepositoryInTab(RepositoryNode node, LauncherPage page)
App.RaiseException(ctx, "Given path is not a valid git repository!");
return;
}
gitCommonDir = new Commands.QueryGitCommonDir(node.Id).Result();
if (string.IsNullOrEmpty(gitCommonDir))
gitCommonDir = gitDir;
}

var repo = new Repository(isBare, node.Id, gitDir);
var repo = new Repository(isBare, node.Id, gitDir, gitCommonDir);
repo.Open();

if (page == null)
Expand Down
10 changes: 9 additions & 1 deletion src/ViewModels/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public string GitDir
set => SetProperty(ref _gitDir, value);
}

public string GitCommonDir
{
get => _gitCommonDir;
set => SetProperty(ref _gitCommonDir, value);
}

public Models.RepositorySettings Settings
{
get => _settings;
Expand Down Expand Up @@ -429,11 +435,12 @@ public int CommitDetailActivePageIndex
set;
} = 0;

public Repository(bool isBare, string path, string gitDir)
public Repository(bool isBare, string path, string gitDir, string gitCommonDir)
{
IsBare = isBare;
FullPath = path;
GitDir = gitDir;
GitCommonDir = gitCommonDir;
}

public void Open()
Expand Down Expand Up @@ -2437,6 +2444,7 @@ private void AutoFetchImpl(object sender)

private string _fullpath = string.Empty;
private string _gitDir = string.Empty;
private string _gitCommonDir = string.Empty;
private Models.RepositorySettings _settings = null;
private Models.FilterMode _historiesFilterMode = Models.FilterMode.None;
private bool _hasAllowedSignersFile = false;
Expand Down