From 198343f09d814f839bdc13346bee02f16303366d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 23 Jan 2023 11:58:43 -0500 Subject: [PATCH] conversationrepository: make log able to skip merge commits Change-Id: If691d61cd1db72f9e183cd75dcb4269434d27d7a --- src/jamidht/conversation.cpp | 1 + src/jamidht/conversationrepository.cpp | 5 ++++- src/jamidht/conversationrepository.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jamidht/conversation.cpp b/src/jamidht/conversation.cpp index 99912169c0..4c97845ffe 100644 --- a/src/jamidht/conversation.cpp +++ b/src/jamidht/conversation.cpp @@ -1033,6 +1033,7 @@ Conversation::lastCommitId() const { LogOptions options; options.nbOfCommits = 1; + options.skipMerge = true; auto messages = pimpl_->loadMessages(options); if (messages.empty()) return {}; diff --git a/src/jamidht/conversationrepository.cpp b/src/jamidht/conversationrepository.cpp index 6b806c7232..7944c82e47 100644 --- a/src/jamidht/conversationrepository.cpp +++ b/src/jamidht/conversationrepository.cpp @@ -2052,11 +2052,14 @@ ConversationRepository::Impl::log(const LogOptions& options) const auto startLogging = options.from == ""; auto breakLogging = false; forEachCommit( - [&](const auto& id, const auto& author, const auto&) { + [&](const auto& id, const auto& author, const auto& commit) { if (!commits.empty()) { // Set linearized parent commits.rbegin()->linearized_parent = id; } + if (options.skipMerge && git_commit_parentcount(commit.get()) > 1) { + return CallbackResult::Skip; + } if ((options.nbOfCommits != 0 && commits.size() == options.nbOfCommits)) return CallbackResult::Break; // Stop logging diff --git a/src/jamidht/conversationrepository.h b/src/jamidht/conversationrepository.h index 64fc5ff6fe..936d9c322e 100644 --- a/src/jamidht/conversationrepository.h +++ b/src/jamidht/conversationrepository.h @@ -60,7 +60,7 @@ struct LogOptions std::string from {}; std::string to {}; uint64_t nbOfCommits {0}; // maximum number of commits wanted - + bool skipMerge {false}; // Do not include merge commits in the log. Used by the module to get last interaction without potential merges bool includeTo {false}; // If we want or not the "to" commit [from-to] or [from-to) bool fastLog {false}; // Do not parse content, used mostly to count bool logIfNotFound {true}; // Add a warning in the log if commit is not found -- GitLab