From c898eca8e08e2854d5b2bba16ac207ea60e6b80c Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 10:12:57 +0200 Subject: [PATCH 01/10] first commit --- src/git/Config.h | 4 ++-- src/ui/CMakeLists.txt | 3 ++- src/ui/CommitList.cpp | 13 ++++++----- src/ui/CommitList.h | 5 +++++ src/ui/CommitToolBar.cpp | 45 +++++++++++++++++++------------------- src/ui/ConfigKeys.cpp | 9 ++++++++ src/ui/ConfigKeys.h | 13 +++++++++++ src/ui/ReferenceWidget.cpp | 5 +++-- 8 files changed, 64 insertions(+), 33 deletions(-) create mode 100644 src/ui/ConfigKeys.cpp create mode 100644 src/ui/ConfigKeys.h diff --git a/src/git/Config.h b/src/git/Config.h index fa5ae1cc..ca0f8f19 100644 --- a/src/git/Config.h +++ b/src/git/Config.h @@ -111,13 +111,13 @@ template <> void Config::setValue(const QString &, const QString &); template T Config::value(const QString &key, const T &defaultValue) const { - static_assert(sizeof(T) == 0, "no specialization found"); + static_assert(sizeof(T) == 0, "no specialization found. Please implement specialization for this type!"); return T(); } template void Config::setValue(const QString &key, const T &value) { - static_assert(sizeof(T) == 0, "no specialization found"); + static_assert(sizeof(T) == 0, "no specialization found. Please implement specialization for this type!"); } } // namespace git diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 2e69f48e..79d96f80 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -53,7 +53,8 @@ add_library( TreeProxy.cpp TreeView.cpp TreeWidget.cpp - ViewDelegate.cpp) + ViewDelegate.cpp + ConfigKeys.cpp) target_compile_definitions(ui PRIVATE BUILD_DESCRIPTION="${BUILD_DESCRIPTION}") diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index c3222233..fc5d0dde 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -14,6 +14,7 @@ #include "ProgressIndicator.h" #include "RepoView.h" #include "Debug.h" +#include "ConfigKeys.h" #include "app/Application.h" #include "conf/Settings.h" #include "dialogs/MergeDialog.h" @@ -221,7 +222,7 @@ public: mWalker.push(mergeHead); } - if (mRefsAll) { + if (mRefsFilter == CommitList::RefsFilter::AllRefs) { foreach (const git::Reference ref, mRepo.refs()) { if (!ref.isStash()) mWalker.push(ref); @@ -237,10 +238,10 @@ public: void resetSettings(bool walk = false) { git::Config config = mRepo.appConfig(); - mRefsAll = config.value("commit.refs.all", true); - mSortDate = config.value("commit.sort.date", true); - mShowCleanStatus = config.value("commit.show.status", true); - mGraphVisible = config.value("commit.graph.visible", true); + mRefsFilter = static_cast(config.value(ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::AllRefs)); + mSortDate = config.value(ConfigKeys::kSortKey, true); + mShowCleanStatus = config.value(ConfigKeys::kStatusKey, true); + mGraphVisible = config.value(ConfigKeys::kGraphKey, true); if (walk) resetWalker(); @@ -557,7 +558,7 @@ private: // walker settings bool mSuppressResetWalker{false}; - bool mRefsAll = true; + CommitList::RefsFilter mRefsFilter{CommitList::RefsFilter::AllRefs}; bool mSortDate = true; bool mShowCleanStatus = true; bool mGraphVisible = true; diff --git a/src/ui/CommitList.h b/src/ui/CommitList.h index ac236f6a..1454d781 100644 --- a/src/ui/CommitList.h +++ b/src/ui/CommitList.h @@ -25,6 +25,11 @@ class CommitList : public QListView { public: enum Role { DiffRole = Qt::UserRole, CommitRole, GraphRole, GraphColorRole }; + enum class RefsFilter { + AllRefs, + SelectedRef, + SelectedRefIgnoreMerge, + }; CommitList(Index *index, QWidget *parent = nullptr); diff --git a/src/ui/CommitToolBar.cpp b/src/ui/CommitToolBar.cpp index a8eb3751..52a56f58 100644 --- a/src/ui/CommitToolBar.cpp +++ b/src/ui/CommitToolBar.cpp @@ -8,8 +8,10 @@ // #include "CommitToolBar.h" +#include "CommitList.h" #include "ContextMenuButton.h" #include "RepoView.h" +#include "ConfigKeys.h" #include "conf/Settings.h" #include "git/Config.h" #include @@ -22,10 +24,6 @@ namespace { -const QString kRefsKey = "commit.refs.all"; -const QString kSortKey = "commit.sort.date"; -const QString kGraphKey = "commit.graph.visible"; -const QString kStatusKey = "commit.show.status"; const QString kStyleSheet = "QToolBar {" " border: none" "}" @@ -34,17 +32,19 @@ const QString kStyleSheet = "QToolBar {" " border-radius: 4px;" " padding-right: 12px" "}"; - +template struct SettingsEntry { QString key; - bool value; + T value; }; -using SettingsMap = QMap; +template +using SettingsMap = QMap>; +template class ToolButton : public QToolButton { public: - ToolButton(const SettingsMap &map, CommitToolBar *parent) + ToolButton(const SettingsMap &map, CommitToolBar *parent, T defaultValue) : QToolButton(parent) { setPopupMode(QToolButton::InstantPopup); @@ -58,8 +58,8 @@ public: action->setCheckable(true); actions->addAction(action); - const SettingsEntry &entry = map.value(key); - if (config.value(entry.key, true) == entry.value) { + const SettingsEntry &entry = map.value(key); + if (config.value(entry.key, defaultValue) == entry.value) { action->setChecked(true); setText(action->text()); } @@ -119,15 +119,16 @@ CommitToolBar::CommitToolBar(QWidget *parent) : QToolBar(parent) { setStyleSheet(kStyleSheet); setToolButtonStyle(Qt::ToolButtonTextOnly); - SettingsMap refsMap; - refsMap.insert(tr("Show All Branches"), {kRefsKey, true}); - refsMap.insert(tr("Show Selected Branch"), {kRefsKey, false}); - addWidget(new ToolButton(refsMap, this)); + SettingsMap refsMap; + refsMap.insert(tr("Show All Branches"), {ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::AllRefs}); + refsMap.insert(tr("Show Selected Branch"), {ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::SelectedRef}); + refsMap.insert(tr("Show Selected Branch, Ignore Merge"), {ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::SelectedRefIgnoreMerge}); + addWidget(new ToolButton(refsMap, this, (int)CommitList::RefsFilter::AllRefs)); - SettingsMap sortMap; - sortMap.insert(tr("Sort by Date"), {kSortKey, true}); - sortMap.insert(tr("Sort Topologically"), {kSortKey, false}); - addWidget(new ToolButton(sortMap, this)); + SettingsMap sortMap; + sortMap.insert(tr("Sort by Date"), {ConfigKeys::kSortKey, true}); + sortMap.insert(tr("Sort Topologically"), {ConfigKeys::kSortKey, false}); + addWidget(new ToolButton(sortMap, this, true)); QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); @@ -145,20 +146,20 @@ CommitToolBar::CommitToolBar(QWidget *parent) : QToolBar(parent) { QAction *graph = menu->addAction(tr("Show Graph")); graph->setCheckable(true); - graph->setChecked(config.value(kGraphKey, true)); + graph->setChecked(config.value(ConfigKeys::kGraphKey, true)); connect(graph, &QAction::triggered, [this](bool checked) { RepoView *view = RepoView::parentView(this); git::Config config = view->repo().appConfig(); - config.setValue(kGraphKey, checked); + config.setValue(ConfigKeys::kGraphKey, checked); emit settingsChanged(); }); QAction *status = menu->addAction(tr("Show Clean Status")); status->setCheckable(true); - status->setChecked(config.value(kStatusKey, true)); + status->setChecked(config.value(ConfigKeys::kStatusKey, true)); connect(status, &QAction::triggered, [this](bool checked) { RepoView *view = RepoView::parentView(this); - view->repo().appConfig().setValue(kStatusKey, checked); + view->repo().appConfig().setValue(ConfigKeys::kStatusKey, checked); emit settingsChanged(); }); diff --git a/src/ui/ConfigKeys.cpp b/src/ui/ConfigKeys.cpp new file mode 100644 index 00000000..13e45a2d --- /dev/null +++ b/src/ui/ConfigKeys.cpp @@ -0,0 +1,9 @@ +#include +#include "ConfigKeys.h" + +namespace ConfigKeys { + const QString kRefsKey = "commit.refs.all"; + const QString kSortKey = "commit.sort.date"; + const QString kGraphKey = "commit.graph.visible"; + const QString kStatusKey = "commit.show.status"; +} diff --git a/src/ui/ConfigKeys.h b/src/ui/ConfigKeys.h new file mode 100644 index 00000000..43c88741 --- /dev/null +++ b/src/ui/ConfigKeys.h @@ -0,0 +1,13 @@ +#ifndef CONFIGKEYS_H +#define CONFIGKEYS_H + +#include + +namespace ConfigKeys { +extern const QString kRefsKey; +extern const QString kSortKey; +extern const QString kGraphKey; +extern const QString kStatusKey; +} + +#endif // CONFIGKEYS_H diff --git a/src/ui/ReferenceWidget.cpp b/src/ui/ReferenceWidget.cpp index f7f54f7d..495b029f 100644 --- a/src/ui/ReferenceWidget.cpp +++ b/src/ui/ReferenceWidget.cpp @@ -9,6 +9,7 @@ #include "ReferenceWidget.h" #include "ExpandButton.h" +#include "ConfigKeys.h" #include "git/Config.h" #include "git/Reference.h" #include "git/Repository.h" @@ -88,7 +89,7 @@ public: QItemSelectionModel::SelectionFlags command) override { QModelIndex current = index; git::Reference head = mRepo.head(); - bool all = mRepo.appConfig().value("commit.refs.all", true); + bool all = mRepo.appConfig().value(ConfigKeys::kRefsKey, true); git::Reference ref = index.data(Qt::UserRole).value(); if (all && ref && !ref.isHead() && !ref.isStash() && head.isValid()) current = findReference(model(), head); @@ -201,7 +202,7 @@ void ReferenceWidget::updateLabel(const git::Reference &ref) { git::Reference ReferenceWidget::currentReference() const { git::Reference ref = mView->currentReference(); - bool all = mRepo.appConfig().value("commit.refs.all", true); + bool all = mRepo.appConfig().value(ConfigKeys::kRefsKey, true); return (!all || (ref.isValid() && ref.isStash())) ? ref : mRepo.head(); } From 64a1c9b69895690242145e5f26ff5d51becc2c09 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 10:13:15 +0200 Subject: [PATCH 02/10] disable debug output --- src/ui/ReferenceModel.cpp | 2 +- src/ui/TreeView.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/ReferenceModel.cpp b/src/ui/ReferenceModel.cpp index 5dbd29b3..d32ae992 100644 --- a/src/ui/ReferenceModel.cpp +++ b/src/ui/ReferenceModel.cpp @@ -87,7 +87,7 @@ void ReferenceModel::update() { if (mKinds & ReferenceView::LocalBranches) { QList branches; foreach (const git::Branch &branch, mRepo.branches(GIT_BRANCH_LOCAL)) { - Debug("ReferenceView: Local branches: " << branch.name()); + //Debug("ReferenceView: Local branches: " << branch.name()); const bool branchOnCommit = !mCommit.isValid() || branch.annotatedCommit().commit() == mCommit; if ((!(mKinds & ReferenceView::ExcludeHead) || !branch.isHead()) && diff --git a/src/ui/TreeView.cpp b/src/ui/TreeView.cpp index 22a760be..bd0fd9e0 100644 --- a/src/ui/TreeView.cpp +++ b/src/ui/TreeView.cpp @@ -190,8 +190,8 @@ void TreeView::handleSelectionChange(const QItemSelection &selected, } void TreeView::setCollapseCount(int value) { - Debug("Name: " << mName << "Current Collapsed: " << mCollapseCount - << "; New Collapsed: " << value); + //Debug("Name: " << mName << "Current Collapsed: " << mCollapseCount + // << "; New Collapsed: " << value); assert(value >= 0); mCollapseCount = value; emit collapseCountChanged(mCollapseCount); From 73da07601e03e9267d970914c15ed4292e17a3f3 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 10:13:27 +0200 Subject: [PATCH 03/10] first approach --- src/ui/CommitList.cpp | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index fc5d0dde..82de1147 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -256,7 +256,9 @@ public: int i = 0; QList rows; git::Commit commit = mWalker.next(mPathspec); + QList ignoredCommits; while (commit.isValid()) { + qDebug() << "Commit: " << commit.message(); // Add root commits. bool root = false; if (indexOf(commit) < 0) { @@ -270,16 +272,32 @@ public: // Replace commit with its parents. QList replacements; + int count = 0; + bool firstCommit = false; foreach (const git::Commit &parent, commit.parents()) { + qDebug() << "\tParent commit " << count << ": " << parent.message(); // FIXME: Mark commits that point to existing parent? - if (indexOf(parent) < 0 && !contains(parent, rows)) - replacements.append(parent); + if (indexOf(parent) < 0 && !contains(parent, rows)) { + if (mRefsFilter == CommitList::RefsFilter::SelectedRefIgnoreMerge) { + // The first parent is the parent into which the other parent was merged + // To create this commit + if (firstCommit && parent.isValid()) { + ignoredCommits.append(parent); + } else { + replacements.append(parent); + } + } else { + replacements.append(parent); + } + firstCommit = true; + } + count ++; } // Set parents for next row. int index = indexOf(commit); if (index >= 0) { - Parent parent = mParents.takeAt(index); + Parent parent = mParents.takeAt(index); // This commit in the mParents List if (!replacements.isEmpty()) { git::Commit replacement = replacements.takeFirst(); mParents.insert(index, Parent(replacement, parent.color)); @@ -300,7 +318,10 @@ public: if (i++ >= 64) break; - commit = mWalker.next(mPathspec); + do { + commit = mWalker.next(mPathspec); + // TODO: child commit of this commit must also not in the ignored Commits list! + } while (ignoredCommits.contains(commit)); } // Update the model. @@ -471,7 +492,14 @@ private: QList successors; const Parent &parent = parents.at(i); if (parent.commit == commit) { - successors = parent.commit.parents(); + if (mRefsFilter == CommitList::RefsFilter::SelectedRefIgnoreMerge) { + const auto& p = parent.commit.parents(); + if (!p.isEmpty()) { + successors.append(parent.commit.parents().at(0)); + } + } else { + successors = parent.commit.parents(); + } } else { successors.append(parent.commit); } From 7ce88e500174582374e1a4f06281aee714eb1b57 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 10:13:27 +0200 Subject: [PATCH 04/10] Revert "first approach" This reverts commit 73da07601e03e9267d970914c15ed4292e17a3f3. --- src/ui/CommitList.cpp | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index 82de1147..fc5d0dde 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -256,9 +256,7 @@ public: int i = 0; QList rows; git::Commit commit = mWalker.next(mPathspec); - QList ignoredCommits; while (commit.isValid()) { - qDebug() << "Commit: " << commit.message(); // Add root commits. bool root = false; if (indexOf(commit) < 0) { @@ -272,32 +270,16 @@ public: // Replace commit with its parents. QList replacements; - int count = 0; - bool firstCommit = false; foreach (const git::Commit &parent, commit.parents()) { - qDebug() << "\tParent commit " << count << ": " << parent.message(); // FIXME: Mark commits that point to existing parent? - if (indexOf(parent) < 0 && !contains(parent, rows)) { - if (mRefsFilter == CommitList::RefsFilter::SelectedRefIgnoreMerge) { - // The first parent is the parent into which the other parent was merged - // To create this commit - if (firstCommit && parent.isValid()) { - ignoredCommits.append(parent); - } else { - replacements.append(parent); - } - } else { - replacements.append(parent); - } - firstCommit = true; - } - count ++; + if (indexOf(parent) < 0 && !contains(parent, rows)) + replacements.append(parent); } // Set parents for next row. int index = indexOf(commit); if (index >= 0) { - Parent parent = mParents.takeAt(index); // This commit in the mParents List + Parent parent = mParents.takeAt(index); if (!replacements.isEmpty()) { git::Commit replacement = replacements.takeFirst(); mParents.insert(index, Parent(replacement, parent.color)); @@ -318,10 +300,7 @@ public: if (i++ >= 64) break; - do { - commit = mWalker.next(mPathspec); - // TODO: child commit of this commit must also not in the ignored Commits list! - } while (ignoredCommits.contains(commit)); + commit = mWalker.next(mPathspec); } // Update the model. @@ -492,14 +471,7 @@ private: QList successors; const Parent &parent = parents.at(i); if (parent.commit == commit) { - if (mRefsFilter == CommitList::RefsFilter::SelectedRefIgnoreMerge) { - const auto& p = parent.commit.parents(); - if (!p.isEmpty()) { - successors.append(parent.commit.parents().at(0)); - } - } else { - successors = parent.commit.parents(); - } + successors = parent.commit.parents(); } else { successors.append(parent.commit); } From f62b5c796c3c02432563d35184f684c1f4123551 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 10:31:21 +0200 Subject: [PATCH 05/10] Implement filtering for first commit only --- src/git/Commit.cpp | 5 ++++- src/git/Commit.h | 2 +- src/git/Reference.cpp | 4 ++-- src/git/Reference.h | 2 +- src/ui/CommitList.cpp | 6 ++++-- src/ui/CommitToolBar.cpp | 23 +++++++++++++---------- src/ui/ConfigKeys.cpp | 10 +++++----- src/ui/ConfigKeys.h | 2 +- 8 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/git/Commit.cpp b/src/git/Commit.cpp index 334120c5..1cdae15f 100644 --- a/src/git/Commit.cpp +++ b/src/git/Commit.cpp @@ -200,7 +200,7 @@ QList Commit::refs() const { return refs; } -RevWalk Commit::walker(int sort) const { +RevWalk Commit::walker(int sort, bool firstCommitOnly) const { git_revwalk *revwalk = nullptr; if (git_revwalk_new(&revwalk, git_object_owner(d.data()))) return RevWalk(); @@ -209,6 +209,9 @@ RevWalk Commit::walker(int sort) const { if (git_revwalk_push(revwalk, git_object_id(d.data()))) return RevWalk(); + if (firstCommitOnly && git_revwalk_simplify_first_parent(revwalk)) + return RevWalk(); + git_revwalk_sorting(revwalk, sort); return walker; diff --git a/src/git/Commit.h b/src/git/Commit.h index 51d02be5..11c73a1c 100644 --- a/src/git/Commit.h +++ b/src/git/Commit.h @@ -56,7 +56,7 @@ public: QList refs() const; // Create a walker starting from this commit. - RevWalk walker(int sort = GIT_SORT_NONE) const; + RevWalk walker(int sort = GIT_SORT_NONE, bool firstCommitOnly = false) const; // Calculate difference in commits between this and the given commit. // Commits that have diverged calculate the distance to a common base. diff --git a/src/git/Reference.cpp b/src/git/Reference.cpp index 1e0fb6e5..d0226b2e 100644 --- a/src/git/Reference.cpp +++ b/src/git/Reference.cpp @@ -73,9 +73,9 @@ QString Reference::qualifiedName() const { return git_reference_name(d.data()); } -RevWalk Reference::walker(int sort) const { +RevWalk Reference::walker(int sort, bool firstCommitOnly) const { Commit commit = target(); - return commit.isValid() ? commit.walker(sort) : RevWalk(); + return commit.isValid() ? commit.walker(sort, firstCommitOnly) : RevWalk(); } int Reference::difference(const Reference &ref) const { diff --git a/src/git/Reference.h b/src/git/Reference.h index 3fccd972..8dbe137a 100644 --- a/src/git/Reference.h +++ b/src/git/Reference.h @@ -47,7 +47,7 @@ public: QString qualifiedName() const; // Create a walker over the referenced commit. - RevWalk walker(int sort = GIT_SORT_NONE) const; + RevWalk walker(int sort = GIT_SORT_NONE, bool firstCommitOnly = false) const; // Calculate difference in commits between this and the given reference. // References that have diverged calculate the distance to a common base. diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index fc5d0dde..74b1361c 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -209,7 +209,8 @@ public: sort |= GIT_SORT_TOPOLOGICAL; } - mWalker = mRef.walker(sort); + mWalker = mRef.walker( + sort, mRefsFilter == CommitList::RefsFilter::SelectedRefIgnoreMerge); if (mRef.isLocalBranch()) { // Add the upstream branch. if (git::Branch upstream = git::Branch(mRef).upstream()) @@ -238,7 +239,8 @@ public: void resetSettings(bool walk = false) { git::Config config = mRepo.appConfig(); - mRefsFilter = static_cast(config.value(ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::AllRefs)); + mRefsFilter = static_cast(config.value( + ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::AllRefs)); mSortDate = config.value(ConfigKeys::kSortKey, true); mShowCleanStatus = config.value(ConfigKeys::kStatusKey, true); mGraphVisible = config.value(ConfigKeys::kGraphKey, true); diff --git a/src/ui/CommitToolBar.cpp b/src/ui/CommitToolBar.cpp index 52a56f58..f4c5178d 100644 --- a/src/ui/CommitToolBar.cpp +++ b/src/ui/CommitToolBar.cpp @@ -32,17 +32,14 @@ const QString kStyleSheet = "QToolBar {" " border-radius: 4px;" " padding-right: 12px" "}"; -template -struct SettingsEntry { +template struct SettingsEntry { QString key; T value; }; -template -using SettingsMap = QMap>; +template using SettingsMap = QMap>; -template -class ToolButton : public QToolButton { +template class ToolButton : public QToolButton { public: ToolButton(const SettingsMap &map, CommitToolBar *parent, T defaultValue) : QToolButton(parent) { @@ -120,10 +117,16 @@ CommitToolBar::CommitToolBar(QWidget *parent) : QToolBar(parent) { setToolButtonStyle(Qt::ToolButtonTextOnly); SettingsMap refsMap; - refsMap.insert(tr("Show All Branches"), {ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::AllRefs}); - refsMap.insert(tr("Show Selected Branch"), {ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::SelectedRef}); - refsMap.insert(tr("Show Selected Branch, Ignore Merge"), {ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::SelectedRefIgnoreMerge}); - addWidget(new ToolButton(refsMap, this, (int)CommitList::RefsFilter::AllRefs)); + refsMap.insert(tr("Show All Branches"), + {ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::AllRefs}); + refsMap.insert( + tr("Show Selected Branch"), + {ConfigKeys::kRefsKey, (int)CommitList::RefsFilter::SelectedRef}); + refsMap.insert(tr("Show Selected Branch, First Parent Only"), + {ConfigKeys::kRefsKey, + (int)CommitList::RefsFilter::SelectedRefIgnoreMerge}); + addWidget( + new ToolButton(refsMap, this, (int)CommitList::RefsFilter::AllRefs)); SettingsMap sortMap; sortMap.insert(tr("Sort by Date"), {ConfigKeys::kSortKey, true}); diff --git a/src/ui/ConfigKeys.cpp b/src/ui/ConfigKeys.cpp index 13e45a2d..267b6ef7 100644 --- a/src/ui/ConfigKeys.cpp +++ b/src/ui/ConfigKeys.cpp @@ -2,8 +2,8 @@ #include "ConfigKeys.h" namespace ConfigKeys { - const QString kRefsKey = "commit.refs.all"; - const QString kSortKey = "commit.sort.date"; - const QString kGraphKey = "commit.graph.visible"; - const QString kStatusKey = "commit.show.status"; -} +const QString kRefsKey = "commit.refs.all"; +const QString kSortKey = "commit.sort.date"; +const QString kGraphKey = "commit.graph.visible"; +const QString kStatusKey = "commit.show.status"; +} // namespace ConfigKeys diff --git a/src/ui/ConfigKeys.h b/src/ui/ConfigKeys.h index 43c88741..11bfd8c7 100644 --- a/src/ui/ConfigKeys.h +++ b/src/ui/ConfigKeys.h @@ -8,6 +8,6 @@ extern const QString kRefsKey; extern const QString kSortKey; extern const QString kGraphKey; extern const QString kStatusKey; -} +} // namespace ConfigKeys #endif // CONFIGKEYS_H From cf23440f9604c448d47c207bf5677ffc7d8e410a Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 10:13:15 +0200 Subject: [PATCH 06/10] Revert "disable debug output" This reverts commit 64a1c9b69895690242145e5f26ff5d51becc2c09. --- src/ui/ReferenceModel.cpp | 2 +- src/ui/TreeView.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/ReferenceModel.cpp b/src/ui/ReferenceModel.cpp index d32ae992..5dbd29b3 100644 --- a/src/ui/ReferenceModel.cpp +++ b/src/ui/ReferenceModel.cpp @@ -87,7 +87,7 @@ void ReferenceModel::update() { if (mKinds & ReferenceView::LocalBranches) { QList branches; foreach (const git::Branch &branch, mRepo.branches(GIT_BRANCH_LOCAL)) { - //Debug("ReferenceView: Local branches: " << branch.name()); + Debug("ReferenceView: Local branches: " << branch.name()); const bool branchOnCommit = !mCommit.isValid() || branch.annotatedCommit().commit() == mCommit; if ((!(mKinds & ReferenceView::ExcludeHead) || !branch.isHead()) && diff --git a/src/ui/TreeView.cpp b/src/ui/TreeView.cpp index bd0fd9e0..22a760be 100644 --- a/src/ui/TreeView.cpp +++ b/src/ui/TreeView.cpp @@ -190,8 +190,8 @@ void TreeView::handleSelectionChange(const QItemSelection &selected, } void TreeView::setCollapseCount(int value) { - //Debug("Name: " << mName << "Current Collapsed: " << mCollapseCount - // << "; New Collapsed: " << value); + Debug("Name: " << mName << "Current Collapsed: " << mCollapseCount + << "; New Collapsed: " << value); assert(value >= 0); mCollapseCount = value; emit collapseCountChanged(mCollapseCount); From f6d2a3ed4d3ab591cba613d49c60cb7c03cde700 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 10:31:55 +0200 Subject: [PATCH 07/10] format --- src/git/Config.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/git/Config.h b/src/git/Config.h index ca0f8f19..fe2afd8f 100644 --- a/src/git/Config.h +++ b/src/git/Config.h @@ -111,13 +111,15 @@ template <> void Config::setValue(const QString &, const QString &); template T Config::value(const QString &key, const T &defaultValue) const { - static_assert(sizeof(T) == 0, "no specialization found. Please implement specialization for this type!"); + static_assert(sizeof(T) == 0, "no specialization found. Please implement " + "specialization for this type!"); return T(); } template void Config::setValue(const QString &key, const T &value) { - static_assert(sizeof(T) == 0, "no specialization found. Please implement specialization for this type!"); + static_assert(sizeof(T) == 0, "no specialization found. Please implement " + "specialization for this type!"); } } // namespace git From 6f1c322ba43b9b490bfa87e57f9e13d8027a1b24 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Wed, 12 Jun 2024 19:07:46 +0200 Subject: [PATCH 08/10] add only the first parent Description: otherwise multiple columns are drawn but there is no starting point of those other branches because they get ignored --- src/ui/CommitList.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index 74b1361c..4f303a97 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -276,6 +276,9 @@ public: // FIXME: Mark commits that point to existing parent? if (indexOf(parent) < 0 && !contains(parent, rows)) replacements.append(parent); + if (mRefsFilter == CommitList::RefsFilter::SelectedRefIgnoreMerge) { + break; + } } // Set parents for next row. From be240232231dce9031e717cd0a3f6ccc46441165 Mon Sep 17 00:00:00 2001 From: Murmele Date: Thu, 13 Jun 2024 08:55:30 +0000 Subject: [PATCH 09/10] Add changelog entry --- docs/changelog.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index b5ac213b..7e1863c3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,14 @@ -### v1.4.0 - 2024-04-24 (DEV) +### vX.X.X - 2024-06-13 (DEV) -Description +Bug Fix and Feature release + +#### Added + +* Add commit filter to show only the first parent in the commit list view + +### v1.4.0 - 2024-04-24 + +Bug Fix and Feature release #### Added From ca3b2c625b978bee23d962e3c0879d49921569cb Mon Sep 17 00:00:00 2001 From: Murmele Date: Thu, 13 Jun 2024 12:11:52 +0000 Subject: [PATCH 10/10] Update changelog --- docs/changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 7e1863c3..3afb486b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,6 +6,8 @@ Bug Fix and Feature release * Add commit filter to show only the first parent in the commit list view +---- + ### v1.4.0 - 2024-04-24 Bug Fix and Feature release