Subject: [PATCH] florent vial: refactored ui-commit print functionality fore a better granularity and clarity.

Vial, Florent florent.vial at intel.com
Tue Sep 13 14:53:40 CEST 2011


Hi,

Yet another patch:
* refactored ui-commit print functionality fore a better granularity and clarity.
*added a show_diffstat_summary_only parameter to cgit_print_commit(). For the moment it is always 0 and hence behaviour is unchanged.

Cheers,
Florent


---
cmd.c       |   11 ++-
ui-commit.c |  372 +++++++++++++++++++++++++++++++++++++++--------------------
ui-commit.h |    4 +-
ui-diff.c   |  138 ++++++++++++++--------
ui-diff.h   |   24 ++++-
5 files changed, 365 insertions(+), 184 deletions(-)

diff --git a/cmd.c b/cmd.c
index c69ddbc..d2b5177 100644
--- a/cmd.c
+++ b/cmd.c
@@ -51,17 +51,22 @@ static void blob_fn(struct cgit_context *ctx)
 static void commit_fn(struct cgit_context *ctx)
{
-              cgit_print_commit(ctx->qry.sha1, ctx->qry.path);
+        /** florent vial: for the commit tab, we always show the diffstat + the diffstat summary
+             */
+             int show_diffstat_summary_only = 0;
+             cgit_print_commit(ctx->qry.sha1, ctx->qry.path, show_diffstat_summary_only);
}
 static void diff_fn(struct cgit_context *ctx)
{
-       /**  This is the real diff function so want the diff controls to be displayed,
+        /** florent vial: this is the real diff function
+                 hence we want the diff controls to be displayed,
                   as well as the whole diff.
               */
               int show_ctrls = 1;
               int show_fulldiff = 1;
-              cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, show_ctrls, show_fulldiff);
+             int show_diffstat_summary_only = 0;
+             cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, show_ctrls, show_fulldiff, show_diffstat_summary_only);
}
 static void info_fn(struct cgit_context *ctx)
diff --git a/ui-commit.c b/ui-commit.c
index a0198f9..553193c 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -12,132 +12,250 @@
#include "ui-diff.h"
#include "ui-log.h"
-void cgit_print_commit(char *hex, const char *prefix)
+void cgit_print_commit_info_author(struct commitinfo *info)
{
-              struct commit *commit, *parent;
-              struct commitinfo *info, *parent_info;
-              struct commit_list *p;
-              struct strbuf notes = STRBUF_INIT;
-              unsigned char sha1[20];
-              char *tmp, *tmp2;
-              int parents = 0;
-              int show_full_diff = ctx.cfg.hide_diff_in_commit_tab == 0 ? 1 : 0;
-
-              if (!hex)
-                              hex = ctx.qry.head;
-
-              if (get_sha1(hex, sha1)) {
-                              cgit_print_error(fmt("Bad object id: %s", hex));
-                              return;
-              }
-              commit = lookup_commit_reference(sha1);
-              if (!commit) {
-                              cgit_print_error(fmt("Bad commit reference: %s", hex));
-                              return;
-              }
-              info = cgit_parse_commit(commit);
-
-              format_note(NULL, sha1, &notes, PAGE_ENCODING, 0);
-
-              load_ref_decorations(DECORATE_FULL_REFS);
-
-              if (show_full_diff) cgit_print_diff_ctrls();
-              html("<table summary='commit info' class='commit-info'>\n");
-              html("<tr><th>author</th><td>");
-              html_txt(info->author);
-              if (!ctx.cfg.noplainemail) {
-                              html(" ");
-                              html_txt(info->author_email);
-              }
-              html("</td><td class='right'>");
-              cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
-              html("</td></tr>\n");
-              html("<tr><th>committer</th><td>");
-              html_txt(info->committer);
-              if (!ctx.cfg.noplainemail) {
-                              html(" ");
-                              html_txt(info->committer_email);
-              }
-              html("</td><td class='right'>");
-              cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
-              html("</td></tr>\n");
-              html("<tr><th>commit</th><td colspan='2' class='sha1'>");
-              tmp = sha1_to_hex(commit->object.sha1);
-              cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
-              html(" (");
-              cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
-              html(")</td></tr>\n");
-              html("<tr><th>tree</th><td colspan='2' class='sha1'>");
-              tmp = xstrdup(hex);
-              cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
-                                     ctx.qry.head, tmp, NULL);
-              if (prefix) {
-                              html(" /");
-                              cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix);
-              }
-              html("</td></tr>\n");
-              for (p = commit->parents; p ; p = p->next) {
-                              parent = lookup_commit_reference(p->item->object.sha1);
-                              if (!parent) {
-                                              html("<tr><td colspan='3'>");
-                                              cgit_print_error("Error reading parent commit");
-                                              html("</td></tr>");
-                                              continue;
-                              }
-                              html("<tr><th>parent</th>"
-                                   "<td colspan='2' class='sha1'>");
-                              tmp = tmp2 = sha1_to_hex(p->item->object.sha1);
-                              if (ctx.repo->enable_subject_links) {
-                                              parent_info = cgit_parse_commit(parent);
-                                              tmp2 = parent_info->subject;
-                              }
-                              cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
-                              html(" (");
-                              cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
-                                                     sha1_to_hex(p->item->object.sha1), prefix, 0);
-                              html(")</td></tr>");
-                              parents++;
-              }
-              if (ctx.repo->snapshots) {
-                              html("<tr><th>download</th><td colspan='2' class='sha1'>");
-                              cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
-                                                                                hex, ctx.repo->snapshots);
-                              html("</td></tr>");
-              }
-              html("</table>\n");
-              html("<div class='commit-subject'>");
-              if (ctx.repo->commit_filter)
-                              cgit_open_filter(ctx.repo->commit_filter);
-              html_txt(info->subject);
-              if (ctx.repo->commit_filter)
-                              cgit_close_filter(ctx.repo->commit_filter);
-              show_commit_decorations(commit);
-              html("</div>");
-              html("<div class='commit-msg'>");
-              if (ctx.repo->commit_filter)
-                              cgit_open_filter(ctx.repo->commit_filter);
-              html_txt(info->msg);
-              if (ctx.repo->commit_filter)
-                              cgit_close_filter(ctx.repo->commit_filter);
-              html("</div>");
-              if (notes.len != 0) {
-                              html("<div class='notes-header'>Notes</div>");
-                              html("<div class='notes'>");
-                              if (ctx.repo->commit_filter)
-                                              cgit_open_filter(ctx.repo->commit_filter);
-                              html_txt(notes.buf);
-                              if (ctx.repo->commit_filter)
-                                              cgit_close_filter(ctx.repo->commit_filter);
-                              html("</div>");
-                              html("<div class='notes-footer'></div>");
-              }
-              if (parents < 3) {
-                              if (parents)
-                                              tmp = sha1_to_hex(commit->parents->item->object.sha1);
-                              else
-                                              tmp = NULL;
-                              cgit_print_diff(ctx.qry.sha1, tmp, prefix, 0, show_full_diff);
-              }
-              strbuf_release(&notes);
-              cgit_free_commitinfo(info);
+  html("<tr><th>author</th><td>");
+  html_txt(info->author);
+  if (!ctx.cfg.noplainemail)
+  {
+      html(" ");
+      html_txt(info->author_email);
+  }
+  html("</td><td class='right'>");
+  cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
+  html("</td></tr>\n");
+}
+
+void cgit_print_commit_info_committer(struct commitinfo *info)
+{
+  html("<tr><th>committer</th><td>");
+  html_txt(info->committer);
+  if (!ctx.cfg.noplainemail)
+  {
+      html(" ");
+      html_txt(info->committer_email);
+  }
+  html("</td><td class='right'>");
+  cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
+  html("</td></tr>\n");
+}
+
+void cgit_print_commit_info_commit(struct commit *commit, const char *prefix)
+{
+    char *tmp;
+    html("<tr><th>commit</th><td colspan='2' class='sha1'>");
+    tmp = sha1_to_hex(commit->object.sha1);
+    cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
+    html(" (");
+    cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
+    html(")</td></tr>\n");
+}
+
+void cgit_print_commit_info_tree(char *hex, struct commit *commit, const char *prefix)
+{
+    char* tmp;
+    html("<tr><th>tree</th><td colspan='2' class='sha1'>");
+    tmp = xstrdup(hex);
+    cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
+            ctx.qry.head, tmp, NULL);
+    if (prefix)
+    {
+        html(" /");
+        cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix);
+    }
+    html("</td></tr>\n");
+}
+
+int cgit_get_commit_info_parent(struct commit *commit)
+{
+    struct commit *parent;
+    struct commit_list *p;
+    int nb_parents = 0;
+    for (p = commit->parents; p ; p = p->next)
+    {
+        parent = lookup_commit_reference(p->item->object.sha1);
+        if (!parent) continue;
+        nb_parents++;
+    }
+    return nb_parents;
+}
+
+void cgit_print_commit_info_parent(char *hex, struct commit *commit, const char *prefix)
+{
+    struct commit *parent;
+    struct commit_list *p;
+    struct commitinfo *parent_info;
+    char *tmp, *tmp2;
+    int nb_parents = 0;
+    for (p = commit->parents; p ; p = p->next)
+    {
+        parent = lookup_commit_reference(p->item->object.sha1);
+        if (!parent)
+        {
+            html("<tr><td colspan='3'>");
+            cgit_print_error("Error reading parent commit");
+            html("</td></tr>");
+            continue;
+        }
+        html("<tr><th>parent</th>"
+          "<td colspan='2' class='sha1'>");
+        tmp = tmp2 = sha1_to_hex(p->item->object.sha1);
+        if (ctx.repo->enable_subject_links)
+        {
+            parent_info = cgit_parse_commit(parent);
+            tmp2 = parent_info->subject;
+        }
+        cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
+        html(" (");
+        cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
+                sha1_to_hex(p->item->object.sha1), prefix, 0);
+        html(")</td></tr>");
+        nb_parents++;
+    }
+}
+
+void cgit_print_commit_info_snapshots(char *hex)
+{
+  if (ctx.repo->snapshots)
+  {
+      html("<tr><th>download</th><td colspan='2' class='sha1'>");
+      cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
+                    hex, ctx.repo->snapshots);
+      html("</td></tr>");
+  }
+}
+
+void cgit_print_commit_info(char *hex, struct commitinfo *info, struct commit *commit, const char *prefix)
+{
+
+  html("<table summary='commit info' class='commit-info'>\n");
+
+  cgit_print_commit_info_author(info);
+
+  cgit_print_commit_info_committer(info);
+
+  cgit_print_commit_info_commit(commit, prefix);
+
+  cgit_print_commit_info_tree(hex, commit, prefix);
+
+  cgit_print_commit_info_parent(hex, commit, prefix);
+
+  cgit_print_commit_info_snapshots(hex);
+
+  html("</table>\n");
+
+}
+
+void cgit_print_commit_subject(struct commitinfo *info, struct commit *commit)
+{
+    html("<div class='commit-subject'>");
+    if (ctx.repo->commit_filter) cgit_open_filter(ctx.repo->commit_filter);
+    html_txt(info->subject);
+    if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter);
+    show_commit_decorations(commit);
+    html("</div>");
+}
+
+void cgit_print_commit_message(struct commitinfo *info)
+{
+    html("<div class='commit-msg'>");
+    if (ctx.repo->commit_filter) cgit_open_filter(ctx.repo->commit_filter);
+    html_txt(info->msg);
+    if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter);
+    html("</div>");
+}
+
+void cgit_print_commit_notes(struct strbuf *notes)
+{
+    if (notes && notes->len != 0)
+    {
+        html("<div class='notes-header'>Notes</div>");
+        html("<div class='notes'>");
+        if (ctx.repo->commit_filter) cgit_open_filter(ctx.repo->commit_filter);
+        html_txt(notes->buf);
+        if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter);
+        html("</div>");
+        html("<div class='notes-footer'></div>");
+    }
+}
+
+void cgit_print_commit_diffstat(struct commit *commit, const char *prefix, int show_diffstat_summary_only)
+{
+    char* tmp;
+    int nb_parents = 0;
+
+    /** make the displaying or not of the diff in the commit tab an option */
+    int show_fulldiff = ctx.cfg.hide_diff_in_commit_tab == 1 ? 0 : 1;
+    int show_ctrls = show_fulldiff;
+
+    nb_parents = cgit_get_commit_info_parent(commit);
+    if (nb_parents < 3)
+    {
+        if (nb_parents)
+        {
+            tmp = sha1_to_hex(commit->parents->item->object.sha1);
+        }
+        else
+        {
+            tmp = NULL;
+        }
+
+        cgit_print_diff(ctx.qry.sha1, tmp, prefix, show_ctrls, show_fulldiff, show_diffstat_summary_only);
+    }
+}
+
+void cgit_print_commit_only(struct commit *commit, unsigned char *sha1, char *hex, const char *prefix, int show_diffstat_summary_only)
+{
+    struct commitinfo *info;
+    struct strbuf notes = STRBUF_INIT;
+
+    info = cgit_parse_commit(commit);
+
+    format_note(NULL, sha1, &notes, PAGE_ENCODING, 0);
+
+    load_ref_decorations(DECORATE_FULL_REFS);
+
+    // florent vial: show ONLY the diffstat box for the commit, including diffstat summary
+    // reason: the whole diff that might be huge and should be called explicitely.
+    // that is why we hide the diff controls as well
+    //cgit_print_diff_ctrls();
+
+    if (!show_diffstat_summary_only)
+    {
+      cgit_print_commit_info(hex, info, commit, prefix);
+
+      cgit_print_commit_subject(info, commit);
+
+      cgit_print_commit_message(info);
+
+      cgit_print_commit_notes(&notes);
+    }
+
+    cgit_print_commit_diffstat(commit, prefix, show_diffstat_summary_only);
+
+    strbuf_release(&notes);
+    cgit_free_commitinfo(info);
+}
+
+void cgit_print_commit(char *hex, const char *prefix, int show_diffstat_summary_only)
+{
+    struct commit *commit;
+    unsigned char sha1[20];
+
+    if (!hex)  hex = ctx.qry.head;
+
+    if (get_sha1(hex, sha1))
+    {
+        cgit_print_error(fmt("Bad object id: %s", hex));
+        return;
+    }
+
+    commit = lookup_commit_reference(sha1);
+    if (!commit)
+    {
+        cgit_print_error(fmt("Bad commit reference: %s", hex));
+        return;
+    }
+
+    cgit_print_commit_only(commit, sha1, hex, prefix, show_diffstat_summary_only);
}
diff --git a/ui-commit.h b/ui-commit.h
index 8198b4b..e83c073 100644
--- a/ui-commit.h
+++ b/ui-commit.h
@@ -1,6 +1,8 @@
#ifndef UI_COMMIT_H
#define UI_COMMIT_H
-extern void cgit_print_commit(char *hex, const char *prefix);
+extern void cgit_print_commit(char *hex, const char *prefix, int show_diffstat_summary_only);
+
+extern void cgit_print_commit_diffstat(struct commit *commit, const char *prefix, int show_diffstat_summary_only);
 #endif /* UI_COMMIT_H */
diff --git a/ui-diff.c b/ui-diff.c
index 4102b5d..1d67e5d 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -18,7 +18,8 @@ static int files, slots;
static int total_adds, total_rems, max_changes;
static int lines_added, lines_removed;
-static struct fileinfo {
+static struct fileinfo
+{
               char status;
               unsigned char old_sha1[20];
               unsigned char new_sha1[20];
@@ -81,15 +82,18 @@ static void print_fileinfo(struct fileinfo *info)
                html("<tr>");
               htmlf("<td class='mode'>");
-              if (is_null_sha1(info->new_sha1)) {
+             if (is_null_sha1(info->new_sha1))
+             {
                               cgit_print_filemode(info->old_mode);
-              } else {
+             } else
+             {
                               cgit_print_filemode(info->new_mode);
               }
                if (info->old_mode != info->new_mode &&
                   !is_null_sha1(info->old_sha1) &&
-                  !is_null_sha1(info->new_sha1)) {
+                 !is_null_sha1(info->new_sha1))
+             {
                               html("<span class='modechange'>[");
                               cgit_print_filemode(info->old_mode);
                               html("]</span>");
@@ -141,7 +145,8 @@ static void inspect_filepair(struct diff_filepair *pair)
               lines_removed = 0;
               cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size,
                                               &binary, 0, ctx.qry.ignorews, count_diff_lines);
-              if (files >= slots) {
+             if (files >= slots)
+             {
                               if (slots == 0)
                                               slots = 4;
                               else
@@ -161,36 +166,50 @@ static void inspect_filepair(struct diff_filepair *pair)
               items[files-1].new_size = new_size;
               items[files-1].binary = binary;
               if (lines_added + lines_removed > max_changes)
+             {
                               max_changes = lines_added + lines_removed;
+             }
               total_adds += lines_added;
               total_rems += lines_removed;
}
 void cgit_print_diffstat(const unsigned char *old_sha1,
-                                              const unsigned char *new_sha1, const char *prefix)
+                                             const unsigned char *new_sha1,
+                                             const char *prefix,
+                                             int show_diffstat_summary_only)
{
               int i;
-
-              html("<div class='diffstat-header'>");
-              cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
-                                     ctx.qry.sha2, NULL, 0);
-              if (prefix) {
-                              html(" (limited to '");
-                              html_txt(prefix);
-                              html("')");
+
+             /** florent vial: display the Diffstat element only
+                 if show_diffstat_summary_only is not specified
+             */
+             if (!show_diffstat_summary_only)
+             {
+               html("<div class='diffstat-header'>");
+               cgit_diff_link("Diffstat", NULL, NULL,
+                                             ctx.qry.head, ctx.qry.sha1, ctx.qry.sha2, NULL, 0);
+               if (prefix)
+               {
+                               html(" (limited to '");
+                               html_txt(prefix);
+                               html("')");
+               }
+               html("</div>");
               }
-              html("</div>");
-              html("<table summary='diffstat' class='diffstat'>");
+
               max_changes = 0;
-              cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix,
-                                     ctx.qry.ignorews);
-              for(i = 0; i<files; i++)
-                              print_fileinfo(&items[i]);
-              html("</table>");
-              html("<div class='diffstat-summary'>");
-              htmlf("%d files changed, %d insertions, %d deletions",
-                    files, total_adds, total_rems);
-              html("</div>");
+             cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, ctx.qry.ignorews);
+
+             if (!show_diffstat_summary_only)
+             {
+                 html("<table summary='diffstat' class='diffstat'>");
+                 for(i = 0; i<files; i++) print_fileinfo(&items[i]);
+                 html("</table>");
+             }
+
+             if (!show_diffstat_summary_only) html("<div class='diffstat-summary'>");
+             htmlf("%d files changed, %d insertions, %d deletions", files, total_adds, total_rems);
+             if (!show_diffstat_summary_only) html("</div>");
}

@@ -354,67 +373,86 @@ void cgit_print_diff_ctrls()
               html("</div>");
}
-void cgit_print_diff(const char *new_rev, const char *old_rev,
-                                   const char *prefix, int show_ctrls, int show_full_diff)
+void cgit_print_diff(const char *new_rev,
+                                  const char *old_rev,
+                                  const char *prefix,
+                                  int show_ctrls,
+                                  int show_fulldiff,
+                                  int show_diffstat_summary_only)
{
               enum object_type type;
               unsigned long size;
               struct commit *commit, *commit2;
-              if (!new_rev)
-                              new_rev = ctx.qry.head;
+             if (!new_rev) new_rev = ctx.qry.head;
               get_sha1(new_rev, new_rev_sha1);
               type = sha1_object_info(new_rev_sha1, &size);
-              if (type == OBJ_BAD) {
+             if (type == OBJ_BAD)
+             {
                               cgit_print_error(fmt("Bad object name: %s", new_rev));
                               return;
               }
               commit = lookup_commit_reference(new_rev_sha1);
-              if (!commit || parse_commit(commit)) {
+             if (!commit || parse_commit(commit))
+             {
                               cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(new_rev_sha1)));
                               return;
               }
                if (old_rev)
+             {
                               get_sha1(old_rev, old_rev_sha1);
+             }
               else if (commit->parents && commit->parents->item)
+             {
                               hashcpy(old_rev_sha1, commit->parents->item->object.sha1);
+             }
               else
+             {
                               hashclr(old_rev_sha1);
+             }
-              if (!is_null_sha1(old_rev_sha1)) {
+             if (!is_null_sha1(old_rev_sha1))
+             {
                               type = sha1_object_info(old_rev_sha1, &size);
-                              if (type == OBJ_BAD) {
+                             if (type == OBJ_BAD)
+                             {
                                               cgit_print_error(fmt("Bad object name: %s", sha1_to_hex(old_rev_sha1)));
                                               return;
                               }
                               commit2 = lookup_commit_reference(old_rev_sha1);
-                              if (!commit2 || parse_commit(commit2)) {
+                             if (!commit2 || parse_commit(commit2))
+                             {
                                               cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1)));
                                               return;
                               }
               }
                if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
+             {
                               use_ssdiff = 1;
+             }
-              if (show_ctrls)
-                              cgit_print_diff_ctrls();
-
-              cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
+        // this displays additional controls to the webpage (diff options: context, space, mode).
+             if (show_ctrls) cgit_print_diff_ctrls();
-              if (show_full_diff)
+             // this displays either diffstat + diffstat summary or diffstat summary only
+             cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix, show_diffstat_summary_only);
+
+             // florent vial: do not show the diff table that might be huge
+             // if not explicitely specified
+             if (show_fulldiff)
               {
-                if (use_ssdiff) {
-                                html("<table summary='ssdiff' class='ssdiff'>");
-                } else {
-                                html("<table summary='diff' class='diff'>");
-                                html("<tr><td>");
-                }
-                cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix,
-                                              ctx.qry.ignorews);
-                if (!use_ssdiff)
-                                html("</td></tr>");
-                html("</table>");
+                 if (use_ssdiff)
+                 {
+                                 html("<table summary='ssdiff' class='ssdiff'>");
+                 } else
+                 {
+                                 html("<table summary='diff' class='diff'>");
+                                 html("<tr><td>");
+                 }
+                 cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb, prefix,  ctx.qry.ignorews);
+                 if (!use_ssdiff) html("</td></tr>");
+                 html("</table>");
               }
}
diff --git a/ui-diff.h b/ui-diff.h
index 797cd70..f2093a5 100644
--- a/ui-diff.h
+++ b/ui-diff.h
@@ -3,11 +3,29 @@
 extern void cgit_print_diff_ctrls();
+/**
+ at param show_diffstat_summary_only flag to specify wether onyl the diffstat summary should be displayed or not
+       if it is set to true, then only the diffstat summary is displayed (files changed, insertions, deletions)
+       if it is set to false, then the diffstat and the diffstat summary are displayed.
+*/
extern void cgit_print_diffstat(const unsigned char *old_sha1,
-                                                              const unsigned char *new_sha1);
+                                                             const unsigned char *new_sha1,
+                                                             const char *prefix,
+                                                             int show_diffstat_summary_only);
-extern void cgit_print_diff(const char *new_hex, const char *old_hex,
-                                                  const char *prefix, int show_ctrls, int show_full_diff);
+/**
+ at param show_fulldiff flag to specify wether ton show the diff or not
+ at param diffstat_summary_only flag to specify wether onyl the diffstat summary should be displayed or not
+ at param show_diffstat_summary_only flag to specify wether onyl the diffstat summary should be displayed or not
+       if it is set to true, then only the diffstat summary is displayed (files changed, insertions, deletions)
+       if it is set to false, then the diffstat and the diffstat summary are displayed.
+*/
+extern void cgit_print_diff(const char *new_hex,
+                                                 const char *old_hex,
+                                                 const char *prefix,
+                                                 int show_ctrls,
+                                                 int show_fulldiff,
+                                                 int show_diffstat_summary_only);
 extern struct diff_filespec *cgit_get_current_old_file(void);
extern struct diff_filespec *cgit_get_current_new_file(void);
--
1.7.0.4




More information about the CGit mailing list