git repos / sago_web_git

commit f94948ee

Poul Sander · 2026-06-22 22:14
f94948ee920ac4654a97980edc83bf249aa160f5 patch · browse files
parent 9881d02ac31dadb3794f4728eb6cef4afe5721d3

Add a notice if we are browsing at a specific commit

Changed files

M .gitignore before
M src/git_repo.cpp before
M src/git_repo.h before
M static/style.css before
M templates/skin.tmpl before
diff --git a/.gitignore b/.gitignore index 7bde8c0..fae4661 100644 --- a/.gitignore +++ b/.gitignore
@@ -1,2 +1,3 @@
build/
+cache/
*.o
diff --git a/src/git_repo.cpp b/src/git_repo.cpp index e1c3a6a..ef9440f 100644 --- a/src/git_repo.cpp +++ b/src/git_repo.cpp
@@ -480,6 +480,8 @@ std::vector<CommitInfo> GitRepo::log(const std::string &start_oid, int limit) co
info.short_oid = info.oid.substr(0, SHORT_OID_LEN);
const char *summary = git_commit_summary(commit);
info.summary = summary ? summary : "";
+ const char *body = git_commit_body(commit);
+ info.body = body ? body : "";
const git_signature *author = git_commit_author(commit);
if (author) {
info.author_name = author->name;
diff --git a/src/git_repo.h b/src/git_repo.h index f1c5ee3..0b78345 100644 --- a/src/git_repo.h +++ b/src/git_repo.h
@@ -28,6 +28,7 @@ struct CommitInfo {
std::string oid;
std::string short_oid;
std::string summary;
+ std::string body; // message past the summary, "" when there is none
std::string author_name;
std::string author_email;
std::time_t time = 0;
diff --git a/static/style.css b/static/style.css index af201b1..ccc59ab 100644 --- a/static/style.css +++ b/static/style.css
@@ -38,6 +38,7 @@ h1 { font-size: 1.4rem; word-break: break-all; }
.meta, .actions, .tags { color: var(--muted); font-size: 0.9rem; }
.actions a { font-size: 0.9rem; }
.tags a { display: inline-block; padding: 0 0.4rem; border: 1px solid var(--muted); border-radius: 3px; }
+.commit-notice { color: var(--muted); font-size: 0.9rem; font-family: monospace; }
.repo-list { list-style: none; padding: 0; }
.repo-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
@@ -46,6 +47,8 @@ table { width: 100%; border-collapse: collapse; }
table.tree td, table.log td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); }
table.tree .size, table.log .date, table.log .author { color: var(--muted); white-space: nowrap; }
table.tree .size { text-align: right; }
+.commit-more summary { color: var(--muted); font-size: 0.85rem; cursor: pointer; }
+.commit-body { margin: 0.5rem 0 0; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.dir { font-weight: 600; }
.submodule { color: var(--muted); }
diff --git a/templates/skin.tmpl b/templates/skin.tmpl index e4eb4d1..e21a321 100644 --- a/templates/skin.tmpl +++ b/templates/skin.tmpl
@@ -78,6 +78,9 @@
<% view tree_view uses content::tree_view extends master %>
<% template content_body() %>
<h1><%= repo %><% if (content.path.length() > 0) %>/<%= path %><% end %></h1>
+<% if (content.query.length() > 0) %>
+<p class="commit-notice">browsing at commit = <%= commit_oid %></p>
+<% end %>
<% if (not content.on_default_branch) %>
<% if (content.branches.size() > 0) %>
<p class="tags">branches: <% foreach b in branches %><% item %><a href="/repos/<%= repo %>/tree/?id=<%= b.target_oid %>"><%= b.name %></a> <% end item %><% end foreach %></p>
@@ -117,6 +120,9 @@
<% view file_view uses content::file_view extends master %>
<% template content_body() %>
<h1><%= path %></h1>
+<% if (content.query.length() > 0) %>
+<p class="commit-notice">browsing at commit = <%= commit_oid %></p>
+<% end %>
<% if (not content.on_default_branch) %>
<% if (content.branches.size() > 0) %>
<p class="tags">branches: <% foreach b in branches %><% item %><a href="/repos/<%= repo %>/tree/?id=<%= b.target_oid %>"><%= b.name %></a> <% end item %><% end foreach %></p>
@@ -180,7 +186,11 @@
<% foreach c in commits %><% item %>
<tr>
<td class="commit"><a href="/repos/<%= repo %>/commit/<%= c.oid %>"><%= c.short_oid %></a></td>
-<td class="msg"><a href="/repos/<%= repo %>/commit/<%= c.oid %>"><%= c.summary %></a></td>
+<td class="msg"><a href="/repos/<%= repo %>/commit/<%= c.oid %>"><%= c.summary %></a>
+<% if (c.body.length() > 0) %>
+<details class="commit-more"><summary>expand</summary><pre class="commit-body"><%= c.body %></pre></details>
+<% end %>
+</td>
<td class="author"><%= c.author_name %></td>
<td class="date"><% c++ out() << util::format_time(c.time); %></td>
</tr>