[gitg] Fixed showing and parsing diff for merge commit
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Subject: [gitg] Fixed showing and parsing diff for merge commit
- Date: Tue, 23 Jun 2009 23:01:45 +0000 (UTC)
commit e50c5f42a23b84f49c2273408d8289518208fcab
Author: Jesse van den Kieboom <jesse icecrew nl>
Date: Wed Jun 24 01:01:23 2009 +0200
Fixed showing and parsing diff for merge commit
Before, only non-merge commits were shown properly (e.g. with file list
and proper highlighting). Now merge commits also show the changed file
list and highlighting has been fixed. Fixes bug #580611.
data/gitgdiff.lang | 2 +-
gitg/gitg-diff-view.c | 9 +++++----
gitg/gitg-revision-view.c | 18 +++++++++++++-----
3 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/data/gitgdiff.lang b/data/gitgdiff.lang
index 24d7c03..f7f27dc 100644
--- a/data/gitgdiff.lang
+++ b/data/gitgdiff.lang
@@ -39,7 +39,7 @@
<context id="gitgdiff">
<include>
<context id="header" style-ref="header">
- <start>^diff --git</start>
+ <start>^diff --(git|cc)</start>
<end>\+\+\+ .*$</end>
</context>
diff --git a/gitg/gitg-diff-view.c b/gitg/gitg-diff-view.c
index 044f026..a176b6f 100644
--- a/gitg/gitg-diff-view.c
+++ b/gitg/gitg-diff-view.c
@@ -461,7 +461,7 @@ ensure_scan(GitgDiffView *view, guint last_line)
text = gtk_text_iter_get_text(&start, &end);
- if (g_str_has_prefix(text, "diff --git"))
+ if (g_str_has_prefix(text, "diff --git") || g_str_has_prefix(text, "diff --cc"))
{
/* start new header region */
Header *header = g_slice_new(Header);
@@ -899,14 +899,15 @@ header_parse_index(GitgDiffView *view, Header *header)
if (sep)
{
gchar *last = strstr(sep, " ");
+ gchar *bet = strstr(start, ",");
if (!last)
last = line + strlen(line);
-
- strncpy(header->index_from, start, sep - start);
+
+ strncpy(header->index_from, start, (bet ? bet : sep) - start);
strncpy(header->index_to, sep + 2, last - (sep + 2));
- header->index_from[sep - start] = '\0';
+ header->index_from[(bet ? bet : sep) - start] = '\0';
header->index_to[last - (sep + 2)] = '\0';
ret = TRUE;
diff --git a/gitg/gitg-revision-view.c b/gitg/gitg-revision-view.c
index 28e40ff..e615ecb 100644
--- a/gitg/gitg-revision-view.c
+++ b/gitg/gitg-revision-view.c
@@ -499,19 +499,27 @@ on_diff_files_update(GitgRunner *runner, gchar **buffer, GitgRevisionView *self)
if (**line == '\0')
continue;
- gchar **parts = g_strsplit(*line, " ", 5);
+ // Count parents
+ gint parents = 0;
+ gchar *ptr = *line;
- if (g_strv_length(parts) == 5)
+ while (*(ptr++) == ':')
+ ++parents;
+
+ gint numparts = 3 + 2 * parents;
+ gchar **parts = g_strsplit(ptr, " ", numparts);
+
+ if (g_strv_length(parts) == numparts)
{
- gchar **files = g_strsplit(parts[4], "\t", -1);
- DiffFile *f = diff_file_new(parts[2], parts[3], files[0], files[1]);
+ gchar **files = g_strsplit(parts[numparts - 1], "\t", -1);
+
+ DiffFile *f = diff_file_new(parts[parents + 1], parts[numparts - 2], files[0], files[1]);
add_diff_file(self, f);
diff_file_unref(f);
g_strfreev(files);
}
- else
g_strfreev(parts);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]