]> git.armaanb.net Git - stagit.git/commitdiff
treat an empty repo (without a HEAD) as valid
authorHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 29 May 2016 13:04:52 +0000 (15:04 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 29 May 2016 13:04:52 +0000 (15:04 +0200)
and create the standard files. Disable caching if there is no HEAD.

stagit.c

index e20c3706658d5173b05dac026b2b91d1ba6b683c..c2ff96632c113349fbbc84191ac24edd733917ea 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -1038,11 +1038,14 @@ main(int argc, char *argv[])
        }
 
        /* find HEAD */
-       if (git_revparse_single(&obj, repo, "HEAD"))
-               return 1;
-       head = git_object_id(obj);
+       if (!git_revparse_single(&obj, repo, "HEAD"))
+               head = git_object_id(obj);
        git_object_free(obj);
 
+       /* don't cache if there is no HEAD */
+       if (!head)
+               cachefile = NULL;
+
        /* use directory name as name */
        if ((name = strrchr(repodirabs, '/')))
                name++;
@@ -1138,7 +1141,8 @@ main(int argc, char *argv[])
                }
                fclose(wcachefp);
        } else {
-               writelog(fp, head);
+               if (head)
+                       writelog(fp, head);
        }
 
        fputs("</tbody></table>", fp);
@@ -1148,7 +1152,8 @@ main(int argc, char *argv[])
        /* files for HEAD */
        fp = efopen("files.html", "w");
        writeheader(fp, "Files");
-       writefiles(fp, head, "HEAD");
+       if (head)
+               writefiles(fp, head, "HEAD");
        writefooter(fp);
        fclose(fp);