]> git.armaanb.net Git - stagit.git/blobdiff - stagit.c
improve example scripts, add to build (Makefile)
[stagit.git] / stagit.c
index 5eb5f1c6d198ffb4109ddae54a43080cdad76415..3362fe5fca417fab35719c2580ebbd8d8b336bdf 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -46,11 +46,6 @@ struct commitinfo {
        size_t ndeltas;
 };
 
-/* summary length (bytes) in the log */
-static const unsigned summarylen = 70;
-/* display line count or file size in file tree index */
-static const int showlinecount = 1;
-
 static git_repository *repo;
 
 static const char *relpath = "";
@@ -213,8 +208,6 @@ commitinfo_getbyoid(const git_oid *id)
        opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH;
        if (git_diff_tree_to_tree(&(ci->diff), repo, ci->parent_tree, ci->commit_tree, &opts))
                goto err;
-       if (commitinfo_getstats(ci) == -1)
-               goto err;
 
        return ci;
 
@@ -297,7 +290,7 @@ printtime(FILE *fp, const git_time *intime)
        t = (time_t)intime->time + (intime->offset * 60);
        if (!(intm = gmtime(&t)))
                return;
-       strftime(out, sizeof(out), "%a %b %e %H:%M:%S", intm);
+       strftime(out, sizeof(out), "%a, %e %b %Y %H:%M:%S", intm);
        if (intime->offset < 0)
                fprintf(fp, "%s -%02d%02d", out,
                            -(intime->offset) / 60, -(intime->offset) % 60);
@@ -537,20 +530,13 @@ printshowfile(FILE *fp, struct commitinfo *ci)
 void
 writelogline(FILE *fp, struct commitinfo *ci)
 {
-       size_t len;
-
        fputs("<tr><td>", fp);
        if (ci->author)
                printtimeshort(fp, &(ci->author->when));
        fputs("</td><td>", fp);
        if (ci->summary) {
                fprintf(fp, "<a href=\"%scommit/%s.html\">", relpath, ci->oid);
-               if ((len = strlen(ci->summary)) > summarylen) {
-                       xmlencode(fp, ci->summary, summarylen - 1);
-                       fputs("…", fp);
-               } else {
-                       xmlencode(fp, ci->summary, len);
-               }
+               xmlencode(fp, ci->summary, strlen(ci->summary));
                fputs("</a>", fp);
        }
        fputs("</td><td>", fp);
@@ -587,6 +573,9 @@ writelog(FILE *fp, const git_oid *oid)
                        break;
                if (!(ci = commitinfo_getbyoid(&id)))
                        break;
+               /* lookup stats: only required here */
+               if (commitinfo_getstats(ci) == -1)
+                       goto err;
 
                writelogline(fp, ci);
                if (cachefile)
@@ -608,6 +597,7 @@ writelog(FILE *fp, const git_oid *oid)
                        writefooter(fpfile);
                        fclose(fpfile);
                }
+err:
                commitinfo_free(ci);
        }
        git_revwalk_free(w);
@@ -836,7 +826,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
                        fprintf(fp, "</td><td><a href=\"%s%s\">", relpath, filepath);
                        xmlencode(fp, entrypath, strlen(entrypath));
                        fputs("</a></td><td class=\"num\" align=\"right\">", fp);
-                       if (showlinecount && lc > 0)
+                       if (lc > 0)
                                fprintf(fp, "%dL", lc);
                        else
                                fprintf(fp, "%juB", (uintmax_t)filesize);