refactored log listing
authorChristian Thaeter <ct@pipapo.org>
Wed, 16 Jan 2008 13:22:01 +0000 (14:22 +0100)
committerChristian Thaeter <ct@pipapo.org>
Wed, 16 Jan 2008 13:22:01 +0000 (14:22 +0100)
src/log.c
src/log.h

index c61375b..2a49653 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -65,19 +65,10 @@ webgit_log_menu_action (struct webgit_query* query)
 }
 
 
-
 Html
-webgit_log_content_action (struct webgit_query* query)
+webgit_log_table (struct webgit_query* query, const char* object, int count, int msg_flag)
 {
   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;
 
@@ -92,34 +83,12 @@ webgit_log_content_action (struct webgit_query* query)
   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--)
+      if (!count--)
         {
           /* displayed query->count lines, finish */
-
           html_list_append (cont,
                             webgit_log_link (
                                              query,
@@ -136,6 +105,8 @@ webgit_log_content_action (struct webgit_query* query)
           break;
         }
 
+      /* TODO: check if commit is one of the heads and display that */
+
       struct tm tm;
       webgit_commit_committer_date_parse (commit, &tm);
 
@@ -156,7 +127,7 @@ webgit_log_content_action (struct webgit_query* query)
                                                              sha1_to_hex (commit->object.sha1),
                                                              40,
                                                              NULL,
-                                                             webgit_header_parse (commit)
+                                                             webgit_commit_header_parse (commit)
                                                              )
                                          )
                                     ),
@@ -182,15 +153,6 @@ webgit_log_content_action (struct webgit_query* query)
                                                                   )
                                               )
                                           )
-                                    ),
-                              html (
-                                    html_tag ("tr"),
-                                    html(html_tag ("td", html_attr ("colspan", "2")),
-                                         html(html_tag ("pre"),
-                                              webgit_message_parse (commit)
-                                              ),
-                                         html(html_tag ("hr"))
-                                         )
                                     )
                               )
                         );
@@ -224,3 +186,18 @@ webgit_log_content_action (struct webgit_query* query)
 
   return html (html ( html_tag ("table"), table), cont);
 }
+
+
+Html
+webgit_log_content_action (struct webgit_query* query)
+{
+  const char* object;
+  if (query->object)
+    object = query->object;
+  else if (query->head)
+    object = query->head;
+  else
+    object = "HEAD";
+
+  return webgit_log_table (query, object, query->count, 1);
+}
index d146827..e1bc6b9 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -37,4 +37,7 @@ webgit_log_menu_action (struct webgit_query* query);
 Html
 webgit_log_content_action (struct webgit_query* query);
 
+Html
+webgit_log_table (struct webgit_query* query, const char* object, int count, int msg_flag);
+
 #endif