aboutsummaryrefslogtreecommitdiff
path: root/gitstatus/src/gitstatus.cc
diff options
context:
space:
mode:
authorRoman Perepelitsa <roman.perepelitsa@gmail.com>2021-05-30 11:35:40 +0300
committerRoman Perepelitsa <roman.perepelitsa@gmail.com>2021-05-30 11:35:40 +0300
commitf217e4a39a284f6db7be7a4cfde8647085f97865 (patch)
tree112ee2c9ed6b2c572665e6cb6c872c977a5a9455 /gitstatus/src/gitstatus.cc
parent77fa0e6dcc56d71590967714f9e76bbf2c9ecc17 (diff)
parentba83466e1da75d9260ebbb145215d9c46d6eadf6 (diff)
Merge commit 'ba83466e1da75d9260ebbb145215d9c46d6eadf6'
Diffstat (limited to 'gitstatus/src/gitstatus.cc')
-rw-r--r--gitstatus/src/gitstatus.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/gitstatus/src/gitstatus.cc b/gitstatus/src/gitstatus.cc
index 5560ca8d..81399ea7 100644
--- a/gitstatus/src/gitstatus.cc
+++ b/gitstatus/src/gitstatus.cc
@@ -41,6 +41,10 @@ namespace {
using namespace std::string_literals;
+void Truncate(std::string& s, size_t max_len) {
+ if (s.size() > max_len) s.resize(max_len);
+}
+
void ProcessRequest(const Options& opts, RepoCache& cache, Request req) {
Timer timer;
ON_SCOPE_EXIT(&) { timer.Report("request"); };
@@ -167,6 +171,11 @@ void ProcessRequest(const Options& opts, RepoCache& cache, Request req) {
// The number of files in the index with assume-unchanged bit set.
resp.Print(stats.num_assume_unchanged);
+ CommitMessage msg = head_target ? GetCommitMessage(repo->repo(), *head_target) : CommitMessage();
+ Truncate(msg.summary, opts.max_commit_summary_length);
+ resp.Print(msg.encoding);
+ resp.Print(msg.summary);
+
resp.Dump("with git status");
}