diff --git a/src/Models/CommitGraph.cs b/src/Models/CommitGraph.cs index 6f371594..718d19c1 100644 --- a/src/Models/CommitGraph.cs +++ b/src/Models/CommitGraph.cs @@ -128,7 +128,7 @@ namespace SourceGit.Models _penCount = colors.Count; } - public static CommitGraph Parse(List commits) + public static CommitGraph Parse(List commits, bool firstParentOnlyEnabled) { double UNIT_WIDTH = 12; double HALF_WIDTH = 6; @@ -215,34 +215,37 @@ namespace SourceGit.Models temp.Dots.Add(new Dot() { Center = position, Color = 0 }); } - // Deal with parents - for (int j = 1; j < commit.Parents.Count; j++) + // Deal with other parents (the first parent has been processed) + if (!firstParentOnlyEnabled) { - var parent = commit.Parents[j]; - if (mapUnsolved.TryGetValue(parent, out var value)) + for (int j = 1; j < commit.Parents.Count; j++) { - // Try to change the merge state of linked graph - var l = value; - if (isMerged) - l.IsMerged = true; + var parent = commit.Parents[j]; + if (mapUnsolved.TryGetValue(parent, out var value)) + { + // Try to change the merge state of linked graph + var l = value; + if (isMerged) + l.IsMerged = true; - var link = new Link(); - link.Start = position; - link.End = new Point(l.LastX, offsetY + HALF_HEIGHT); - link.Control = new Point(link.End.X, link.Start.Y); - link.Color = l.Path.Color; + var link = new Link(); + link.Start = position; + link.End = new Point(l.LastX, offsetY + HALF_HEIGHT); + link.Control = new Point(link.End.X, link.Start.Y); + link.Color = l.Path.Color; - temp.Links.Add(link); - } - else - { - offsetX += UNIT_WIDTH; + temp.Links.Add(link); + } + else + { + offsetX += UNIT_WIDTH; - // Create new curve for parent commit that not includes before - var l = new PathHelper(commit.Parents[j], isMerged, colorIdx, position, new Point(offsetX, position.Y + HALF_HEIGHT)); - unsolved.Add(l); - temp.Paths.Add(l.Path); - colorIdx = (colorIdx + 1) % _penCount; + // Create new curve for parent commit that not includes before + var l = new PathHelper(parent, isMerged, colorIdx, position, new Point(offsetX, position.Y + HALF_HEIGHT)); + unsolved.Add(l); + temp.Paths.Add(l.Path); + colorIdx = (colorIdx + 1) % _penCount; + } } } diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index db5496a3..06e60a87 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -70,12 +70,6 @@ namespace SourceGit.Models set; } = false; - public bool FirstParentFilterEnabled - { - get; - set; - } = false; - public AvaloniaList Filters { get; diff --git a/src/Resources/Icons.axaml b/src/Resources/Icons.axaml index 6e16802a..7345d2d2 100644 --- a/src/Resources/Icons.axaml +++ b/src/Resources/Icons.axaml @@ -38,7 +38,7 @@ M416 832H128V128h384v192C512 355 541 384 576 384L768 384v32c0 19 13 32 32 32S832 435 832 416v-64c0-6 0-19-6-25l-256-256c-6-6-19-6-25-6H128A64 64 0 0064 128v704C64 867 93 896 129 896h288c19 0 32-13 32-32S435 832 416 832zM576 172 722 320H576V172zM736 512C614 512 512 614 512 736S614 960 736 960s224-102 224-224S858 512 736 512zM576 736C576 646 646 576 736 576c32 0 58 6 83 26l-218 218c-19-26-26-51-26-83zm160 160c-32 0-64-13-96-32l224-224c19 26 32 58 32 96 0 90-70 160-160 160z M896 320c0-19-6-32-19-45l-192-192c-13-13-26-19-45-19H192c-38 0-64 26-64 64v768c0 38 26 64 64 64h640c38 0 64-26 64-64V320zm-256 384H384c-19 0-32-13-32-32s13-32 32-32h256c19 0 32 13 32 32s-13 32-32 32zm166-384H640V128l192 192h-26z M599 425 599 657 425 832 425 425 192 192 832 192Z - M599 425 599 657 425 832 425 425 192 192 832 192Z + m211 611a142 142 0 00-90-4v-190a142 142 0 0090-4v198zm0 262v150h-90v-146a142 142 0 0090-4zm0-723a142 142 0 00-90-4v-146h90zm-51 246a115 115 0 11115-115 115 115 0 01-115 115zm0 461a115 115 0 11115-115 115 115 0 01-115 115zm256-691h563v90h-563zm0 461h563v90h-563zm0-282h422v90h-422zm0 474h422v90h-422z M853 267H514c-4 0-6-2-9-4l-38-66c-13-21-38-36-64-36H171c-41 0-75 34-75 75v555c0 41 34 75 75 75h683c41 0 75-34 75-75V341c0-41-34-75-75-75zm-683-43h233c4 0 6 2 9 4l38 66c13 21 38 36 64 36H853c6 0 11 4 11 11v75h-704V235c0-6 4-11 11-11zm683 576H171c-6 0-11-4-11-11V480h704V789c0 6-4 11-11 11z M1088 227H609L453 78a11 11 0 00-7-3H107a43 43 0 00-43 43v789a43 43 0 0043 43h981a43 43 0 0043-43V270a43 43 0 00-43-43zM757 599c0 5-5 9-10 9h-113v113c0 5-4 9-9 9h-56c-5 0-9-4-9-9V608h-113c-5 0-10-4-10-9V543c0-5 5-9 10-9h113V420c0-5 4-9 9-9h56c5 0 9 4 9 9V533h113c5 0 10 4 10 9v56z M922 450c-6-9-15-13-26-13h-11V341c0-41-34-75-75-75H514c-4 0-6-2-9-4l-38-66c-13-21-38-36-64-36H171c-41 0-75 34-75 75v597c0 6 2 13 6 19 6 9 15 13 26 13h640c13 0 26-9 30-21l128-363c4-11 2-21-4-30zM171 224h233c4 0 6 2 9 4l38 66c13 21 38 36 64 36H811c6 0 11 4 11 11v96H256c-13 0-26 9-30 21l-66 186V235c0-6 4-11 11-11zm574 576H173l105-299h572l-105 299z diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 58d54ea6..2fe1ef9d 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -478,7 +478,7 @@ FILTERED BY: LOCAL BRANCHES Navigate To HEAD - First Parent Filter + Enable '--first-parent' Option Create Branch Open In {0} Open In External Tools diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index d30c35b5..6c61b41f 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -480,7 +480,7 @@ 过滤规则 : 本地分支 定位HEAD - 首个父节点过滤器 + 启用 --first-parent 过滤选项 新建分支 在 {0} 中打开 使用外部工具打开 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 655020bc..84f7bd25 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -480,7 +480,7 @@ 過濾規則 : 本地分支 定位HEAD - 首個父節點過濾器 + 启用 -first-parent 过滤选项 新建分支 在 {0} 中開啟 使用外部工具開啟 diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 4496ff71..30e46dc2 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -73,6 +73,16 @@ namespace SourceGit.ViewModels set => SetProperty(ref _selectedView, value); } + public bool EnableFirstParentInHistories + { + get => _enableFirstParentInHistories; + set + { + if (SetProperty(ref _enableFirstParentInHistories, value)) + Task.Run(RefreshCommits); + } + } + public string SearchBranchFilter { get => _searchBranchFilter; @@ -284,19 +294,6 @@ namespace SourceGit.ViewModels set => SetProperty(ref _isWorktreeGroupExpanded, value); } - public bool FirstParentFilterToggled - { - get => _firstParentFilterToggled; - set - { - if (SetProperty(ref _firstParentFilterToggled, value)) - { - _settings.FirstParentFilterEnabled = value; - Task.Run(RefreshCommits); - } - } - } - public InProgressContext InProgressContext { get => _inProgressContext; @@ -737,6 +734,9 @@ namespace SourceGit.ViewModels Dispatcher.UIThread.Invoke(() => _histories.IsLoading = true); var limits = $"-{Preference.Instance.MaxHistoryCommits} "; + if (_enableFirstParentInHistories) + limits += "--first-parent "; + var validFilters = new List(); foreach (var filter in _settings.Filters) { @@ -765,17 +765,13 @@ namespace SourceGit.ViewModels }); } } - else if (_settings.FirstParentFilterEnabled) - { - limits += "--first-parent "; - } else { - limits += "--exclude=refs/stash --all "; + limits += "--exclude=refs/stash --all"; } var commits = new Commands.QueryCommits(_fullpath, limits).Result(); - var graph = Models.CommitGraph.Parse(commits); + var graph = Models.CommitGraph.Parse(commits, _enableFirstParentInHistories); Dispatcher.UIThread.Invoke(() => { @@ -1974,7 +1970,7 @@ namespace SourceGit.ViewModels private bool _isSearchLoadingVisible = false; private bool _isSearchCommitSuggestionOpen = false; private int _searchCommitFilterType = 0; - private bool _firstParentFilterToggled = false; + private bool _enableFirstParentInHistories = false; private string _searchCommitFilter = string.Empty; private List _searchedCommits = new List(); private List _revisionFiles = new List(); diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 7bd24f91..15819142 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -76,7 +76,7 @@ - + + + + diff --git a/src/Views/RepositoryToolbar.axaml b/src/Views/RepositoryToolbar.axaml index 02a90d31..b76cfd63 100644 --- a/src/Views/RepositoryToolbar.axaml +++ b/src/Views/RepositoryToolbar.axaml @@ -125,10 +125,6 @@ - - - -