moved log_menu|content_action to log.c|h
authorChristian Thaeter <ct@pipapo.org>
Tue, 15 Jan 2008 14:38:43 +0000 (15:38 +0100)
committerChristian Thaeter <ct@pipapo.org>
Tue, 15 Jan 2008 14:38:43 +0000 (15:38 +0100)
src/actions.c
src/log.c
src/log.h

index 65f31d3..b392ba9 100644 (file)
@@ -32,9 +32,6 @@
 /* todo configure this */
 #define SHA1_HEADER <openssl/sha.h>
 #include "git/cache.h"
-#include "git/commit.h"
-#include "git/diff.h"
-#include "git/revision.h"
 
 #include <stdio.h>
 
@@ -158,163 +155,6 @@ webgit_summary_action (struct webgit_query* query)
 /*
   Log page
 */
-static Html
-webgit_log_menu_action (struct webgit_query* query)
-{
-  (void) query;
-  return html ("TODO: log sidebar");
-}
-
-
-static Html
-webgit_log_content_action (struct webgit_query* query)
-{
-  webgit_enter_repository (query);
-
-  struct rev_info rev;
-  const char* object;
-  if (query->object)
-    object = query->object;
-  else if (query->head)
-    object = query->head;
-  else
-    object = "HEAD";
-
-  const char* argv[] = {NULL, object, NULL};
-  int argc = 2;
-
-  init_revisions (&rev, NULL);
-  rev.verbose_header = 1;
-  rev.topo_order = 1;
-
-  setup_revisions (argc, argv, &rev, NULL);
-
-  prepare_revision_walk(&rev);
-
-  Html table = html_list ();
-  Html cont = html_list ();
-
-  fprintf (stderr, "%s\n", query->object);
-
-  unsigned char sha1[20];
-  if (query->object)
-    get_sha1 (query->object, sha1);
-
-  int cnt = query->count;
-
-  struct commit *commit;
-  while ((commit = get_revision (&rev)))
-    {
-      if (query->object)
-        {
-          if (!hashcmp (sha1, commit->object.sha1))
-            {
-              /* found first commit to display */
-              free (query->object);
-              query->object = NULL;
-            }
-          else
-            /* not yet, fall through */
-            continue;
-        }
-
-      if (!cnt--)
-        {
-          /* displayed query->count lines, finish */
-
-          html_list_append (cont,
-                            webgit_log_link (
-                                             query,
-                                             query->repo,
-                                             query->head,
-                                             sha1_to_hex(commit->object.sha1), 40,
-                                             query->count_def,
-                                             html("More..."))
-                            );
-          free(commit->buffer);
-          commit->buffer = NULL;
-          free_commit_list(commit->parents);
-          commit->parents = NULL;
-          break;
-        }
-
-      struct tm tm;
-      webgit_commit_committer_date_parse (commit, &tm);
-
-      char pretty_date[256];
-      strftime (pretty_date, 255, "%c", &tm);
-
-      html_list_append (table,
-                        html (
-                              html (
-                                    html_tag ("tr"),
-                                    html(html_tag ("td"),
-                                         html_strndup (pretty_date, 254)
-                                         ),
-                                    html(html_tag ("td"),
-                                         webgit_object_link (query,
-                                                             query->repo,
-                                                             strlen (query->repo),
-                                                             sha1_to_hex (commit->object.sha1),
-                                                             40,
-                                                             NULL,
-                                                             webgit_header_parse (commit)
-                                                             )
-                                         )
-                                    ),
-                              html (
-                                    html_tag ("tr"),
-                                    html(html_tag ("td"),
-                                         webgit_email_link (
-                                                            webgit_commit_author_name_parse (commit),
-                                                            webgit_commit_author_email_parse (commit)
-                                                            )
-                                         ),
-                                    html (html_tag ("td"),
-                                         html(
-                                              "Diff ",
-                                              " ",
-                                              webgit_object_link (query,
-                                                                  query->repo,
-                                                                  strlen (query->repo),
-                                                                  webgit_commit_tree_parse (commit),
-                                                                  40,
-                                                                  NULL,
-                                                                  html ("Tree")
-                                                                  )
-                                              )
-                                          )
-                                    ),
-                              html (
-                                    html_tag ("tr"),
-                                    html(html_tag ("td", html_attr ("colspan", "2")),
-                                         html(html_tag ("pre"),
-                                              webgit_message_parse (commit)
-                                              ),
-                                         html(html_tag ("hr"))
-                                         )
-                                    )
-                              )
-                        );
-
-
-#if 0 /* traverse parents */
-      struct commit *parent;
-      while ((parent = pop_commit (&commit->parents)))
-        {
-        }
-#endif
-
-      free(commit->buffer);
-      commit->buffer = NULL;
-      free_commit_list(commit->parents);
-      commit->parents = NULL;
-    }
-
-  return html (html ( html_tag ("table"), table), cont);
-}
-
-
 static Html
 webgit_log_action (struct webgit_query* query)
 {
index 2a89f20..c220aca 100644 (file)
--- a/src/log.c
+++ b/src/log.c
 */
 
 #include "log.h"
+#include "object.h"
+
+#define SHA1_HEADER <openssl/sha.h>
+#include "git/cache.h"
+#include "git/commit.h"
+#include "git/diff.h"
+#include "git/revision.h"
 
 Html
 webgit_log_link (struct webgit_query* query,
@@ -49,3 +56,160 @@ webgit_log_link (struct webgit_query* query,
                );
 }
 
+
+Html
+webgit_log_menu_action (struct webgit_query* query)
+{
+  (void) query;
+  return html ("TODO: log sidebar");
+}
+
+
+
+Html
+webgit_log_content_action (struct webgit_query* query)
+{
+  webgit_enter_repository (query);
+
+  struct rev_info rev;
+  const char* object;
+  if (query->object)
+    object = query->object;
+  else if (query->head)
+    object = query->head;
+  else
+    object = "HEAD";
+
+  const char* argv[] = {NULL, object, NULL};
+  int argc = 2;
+
+  init_revisions (&rev, NULL);
+  rev.verbose_header = 1;
+  rev.topo_order = 1;
+
+  setup_revisions (argc, argv, &rev, NULL);
+
+  prepare_revision_walk(&rev);
+
+  Html table = html_list ();
+  Html cont = html_list ();
+
+  fprintf (stderr, "%s\n", query->object);
+
+  unsigned char sha1[20];
+  if (query->object)
+    get_sha1 (query->object, sha1);
+
+  int cnt = query->count;
+
+  struct commit *commit;
+  while ((commit = get_revision (&rev)))
+    {
+      if (query->object)
+        {
+          if (!hashcmp (sha1, commit->object.sha1))
+            {
+              /* found first commit to display */
+              free (query->object);
+              query->object = NULL;
+            }
+          else
+            /* not yet, fall through */
+            continue;
+        }
+
+      if (!cnt--)
+        {
+          /* displayed query->count lines, finish */
+
+          html_list_append (cont,
+                            webgit_log_link (
+                                             query,
+                                             query->repo,
+                                             query->head,
+                                             sha1_to_hex(commit->object.sha1), 40,
+                                             query->count_def,
+                                             html("More..."))
+                            );
+          free(commit->buffer);
+          commit->buffer = NULL;
+          free_commit_list(commit->parents);
+          commit->parents = NULL;
+          break;
+        }
+
+      struct tm tm;
+      webgit_commit_committer_date_parse (commit, &tm);
+
+      char pretty_date[256];
+      strftime (pretty_date, 255, "%c", &tm);
+
+      html_list_append (table,
+                        html (
+                              html (
+                                    html_tag ("tr"),
+                                    html(html_tag ("td"),
+                                         html_strndup (pretty_date, 254)
+                                         ),
+                                    html(html_tag ("td"),
+                                         webgit_object_link (query,
+                                                             query->repo,
+                                                             strlen (query->repo),
+                                                             sha1_to_hex (commit->object.sha1),
+                                                             40,
+                                                             NULL,
+                                                             webgit_header_parse (commit)
+                                                             )
+                                         )
+                                    ),
+                              html (
+                                    html_tag ("tr"),
+                                    html(html_tag ("td"),
+                                         webgit_email_link (
+                                                            webgit_commit_author_name_parse (commit),
+                                                            webgit_commit_author_email_parse (commit)
+                                                            )
+                                         ),
+                                    html (html_tag ("td"),
+                                         html(
+                                              "Diff ",
+                                              " ",
+                                              webgit_object_link (query,
+                                                                  query->repo,
+                                                                  strlen (query->repo),
+                                                                  webgit_commit_tree_parse (commit),
+                                                                  40,
+                                                                  NULL,
+                                                                  html ("Tree")
+                                                                  )
+                                              )
+                                          )
+                                    ),
+                              html (
+                                    html_tag ("tr"),
+                                    html(html_tag ("td", html_attr ("colspan", "2")),
+                                         html(html_tag ("pre"),
+                                              webgit_message_parse (commit)
+                                              ),
+                                         html(html_tag ("hr"))
+                                         )
+                                    )
+                              )
+                        );
+
+
+#if 0 /* traverse parents */
+      struct commit *parent;
+      while ((parent = pop_commit (&commit->parents)))
+        {
+        }
+#endif
+
+      free(commit->buffer);
+      commit->buffer = NULL;
+      free_commit_list(commit->parents);
+      commit->parents = NULL;
+    }
+
+  return html (html ( html_tag ("table"), table), cont);
+}
index 3555e8d..d146827 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -31,4 +31,10 @@ webgit_log_link (struct webgit_query* query,
                  int count,
                  Html text);
 
+Html
+webgit_log_menu_action (struct webgit_query* query);
+
+Html
+webgit_log_content_action (struct webgit_query* query);
+
 #endif