[gitg] Show hunk context in diff
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Show hunk context in diff
- Date: Mon, 22 Dec 2014 17:36:25 +0000 (UTC)
commit e2e6df76388be8780eec639646c3b20caa335e59
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Mon Dec 22 18:35:25 2014 +0100
Show hunk context in diff
libgitg/gitg-diff-view-request-diff.vala | 10 +++++++++-
libgitg/resources/diff-view-html-builder.js | 2 +-
libgitg/resources/diff-view.css | 2 +-
3 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/libgitg/gitg-diff-view-request-diff.vala b/libgitg/gitg-diff-view-request-diff.vala
index dd0f492..694ecdb 100644
--- a/libgitg/gitg-diff-view-request-diff.vala
+++ b/libgitg/gitg-diff-view-request-diff.vala
@@ -156,7 +156,15 @@ namespace Gitg
}
builder.end_object();
- builder.set_member_name("header").add_string_value(header);
+ var h = hunk.get_header();
+ var pos = h.last_index_of("@@");
+
+ if (pos >= 0)
+ {
+ h = h[pos + 2:-1].chug();
+ }
+
+ builder.set_member_name("header").add_string_value(h);
builder.set_member_name("lines");
builder.begin_array();
diff --git a/libgitg/resources/diff-view-html-builder.js b/libgitg/resources/diff-view-html-builder.js
index 3244a73..7e05688 100644
--- a/libgitg/resources/diff-view-html-builder.js
+++ b/libgitg/resources/diff-view-html-builder.js
@@ -486,7 +486,7 @@ function diff_file(file, lnstate, data)
var hunk_header = '<span class="hunk_stats">@@ -' + h.range.old.start + ',' +
h.range.old.lines + ' +' + h.range.new.start + ',' + h.range.new.lines + ' @@</span>';
- hunk_header = hunk_header;
+ hunk_header += ' <span class="hunk_context">' + html_escape(h.header) + '</span>';
file_body += '<tr class="hunk_header"> \
<td class="gutter old">' + lnstate.gutterdots + '</td> \
diff --git a/libgitg/resources/diff-view.css b/libgitg/resources/diff-view.css
index 58f7511..247b69c 100644
--- a/libgitg/resources/diff-view.css
+++ b/libgitg/resources/diff-view.css
@@ -269,7 +269,7 @@ div.loading {
font-family: sans-serif;
}
-span.hunk_stats, span.file_path {
+span.hunk_stats, span.file_path, span.hunk_context {
display: inline-block;
vertical-align: middle;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]