]> git.armaanb.net Git - stagit.git/blobdiff - stagit.c
more verbose errors: show which file failed on open
[stagit.git] / stagit.c
index d310a583f3e4d0a9b76c249d05f719a9e05b0036..43cd2ef605cbbf537a8052dee3ecd7fbd55d083a 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -208,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;
 
@@ -225,7 +223,7 @@ efopen(const char *name, const char *flags)
        FILE *fp;
 
        if (!(fp = fopen(name, flags)))
-               err(1, "fopen");
+               err(1, "fopen: '%s'", name);
 
        return fp;
 }
@@ -292,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);
@@ -575,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)
@@ -596,6 +597,7 @@ writelog(FILE *fp, const git_oid *oid)
                        writefooter(fpfile);
                        fclose(fpfile);
                }
+err:
                commitinfo_free(ci);
        }
        git_revwalk_free(w);
@@ -1092,7 +1094,7 @@ main(int argc, char *argv[])
        /* log for HEAD */
        fp = efopen("log.html", "w");
        relpath = "";
-       mkdir("commit", 0755);
+       mkdir("commit", S_IRWXU | S_IRWXG | S_IRWXO);
        writeheader(fp, "Log");
        fputs("<table id=\"log\"><thead>\n<tr><td><b>Date</b></td>"
              "<td><b>Commit message</b></td>"
@@ -1113,7 +1115,7 @@ main(int argc, char *argv[])
                if ((fd = mkstemp(tmppath)) == -1)
                        err(1, "mkstemp");
                if (!(wcachefp = fdopen(fd, "w")))
-                       err(1, "fdopen");
+                       err(1, "fdopen: '%s'", tmppath);
                /* write last commit id (HEAD) */
                git_oid_tostr(buf, sizeof(buf), head);
                fprintf(wcachefp, "%s\n", buf);