21 char oid[GIT_OID_HEXSZ + 1];
22 char parentoid[GIT_OID_HEXSZ + 1];
24 const git_signature *author;
28 git_diff_stats *stats;
32 git_tree *commit_tree;
33 git_tree *parent_tree;
40 static git_repository *repo;
42 static const char *relpath = "";
43 static const char *repodir;
45 static char name[255];
46 static char description[255];
47 static char cloneurl[1024];
48 static int hasreadme, haslicense;
51 commitinfo_free(struct commitinfo *ci)
56 git_diff_stats_free(ci->stats);
57 git_diff_free(ci->diff);
58 git_tree_free(ci->commit_tree);
59 git_tree_free(ci->parent_tree);
60 git_commit_free(ci->commit);
64 commitinfo_getbyoid(const git_oid *id)
66 struct commitinfo *ci;
67 git_diff_options opts;
70 if (!(ci = calloc(1, sizeof(struct commitinfo))))
74 if (git_commit_lookup(&(ci->commit), repo, id))
77 git_oid_tostr(ci->oid, sizeof(ci->oid), git_commit_id(ci->commit));
78 git_oid_tostr(ci->parentoid, sizeof(ci->parentoid), git_commit_parent_id(ci->commit, 0));
80 ci->author = git_commit_author(ci->commit);
81 ci->summary = git_commit_summary(ci->commit);
82 ci->msg = git_commit_message(ci->commit);
84 if ((error = git_commit_tree(&(ci->commit_tree), ci->commit)))
86 if (!(error = git_commit_parent(&(ci->parent), ci->commit, 0))) {
87 if ((error = git_commit_tree(&(ci->parent_tree), ci->parent)))
91 ci->parent_tree = NULL;
94 git_diff_init_options(&opts, GIT_DIFF_OPTIONS_VERSION);
95 opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH;
96 if ((error = git_diff_tree_to_tree(&(ci->diff), repo, ci->parent_tree, ci->commit_tree, &opts)))
98 if (git_diff_get_stats(&(ci->stats), ci->diff))
101 ci->addcount = git_diff_stats_insertions(ci->stats);
102 ci->delcount = git_diff_stats_deletions(ci->stats);
103 ci->filecount = git_diff_stats_files_changed(ci->stats);
115 efopen(const char *name, const char *flags)
119 if (!(fp = fopen(name, flags)))
125 /* Escape characters below as HTML 2.0 / XML 1.0. */
127 xmlencode(FILE *fp, const char *s, size_t len)
131 for (i = 0; *s && i < len; s++, i++) {
133 case '<': fputs("<", fp); break;
134 case '>': fputs(">", fp); break;
135 case '\'': fputs("'", fp); break;
136 case '&': fputs("&", fp); break;
137 case '"': fputs(""", fp); break;
138 default: fputc(*s, fp);
143 /* Some implementations of dirname(3) return a pointer to a static
144 * internal buffer (OpenBSD). Others modify the contents of `path` (POSIX).
145 * This is a wrapper function that is compatible with both versions.
146 * The program will error out if dirname(3) failed, this can only happen
147 * with the OpenBSD version. */
149 xdirname(const char *path)
153 if (!(p = strdup(path)))
155 if (!(b = dirname(p)))
157 if (!(b = strdup(b)))
164 /* Some implementations of basename(3) return a pointer to a static
165 * internal buffer (OpenBSD). Others modify the contents of `path` (POSIX).
166 * This is a wrapper function that is compatible with both versions.
167 * The program will error out if basename(3) failed, this can only happen
168 * with the OpenBSD version. */
170 xbasename(const char *path)
174 if (!(p = strdup(path)))
176 if (!(b = basename(p)))
178 if (!(b = strdup(b)))
186 mkdirp(const char *path)
188 char tmp[PATH_MAX], *p;
190 strlcpy(tmp, path, sizeof(tmp));
191 for (p = tmp + (tmp[0] == '/'); *p; p++) {
195 if (mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO) < 0 && errno != EEXIST)
199 if (mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO) < 0 && errno != EEXIST)
205 printtimeformat(FILE *fp, const git_time *intime, const char *fmt)
211 t = (time_t) intime->time + (intime->offset * 60);
213 strftime(out, sizeof(out), fmt, intm);
218 printtimez(FILE *fp, const git_time *intime)
220 printtimeformat(fp, intime, "%Y-%m-%dT%H:%M:%SZ");
224 printtime(FILE *fp, const git_time *intime)
226 printtimeformat(fp, intime, "%a %b %e %T %Y");
230 printtimeshort(FILE *fp, const git_time *intime)
232 printtimeformat(fp, intime, "%Y-%m-%d %H:%M");
236 writeheader(FILE *fp)
238 fputs("<!DOCTYPE HTML>"
239 "<html dir=\"ltr\" lang=\"en\">\n<head>\n"
240 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
241 "<meta http-equiv=\"Content-Language\" content=\"en\" />\n<title>", fp);
242 xmlencode(fp, name, strlen(name));
245 xmlencode(fp, description, strlen(description));
246 fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/png\" href=\"%sfavicon.png\" />\n", relpath);
247 fprintf(fp, "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"%s Atom Feed\" href=\"%satom.xml\" />\n",
249 fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath);
250 fputs("</head>\n<body>\n<table><tr><td>", fp);
251 fprintf(fp, "<a href=\"../%s\"><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>",
253 fputs("</td><td><h1>", fp);
254 xmlencode(fp, name, strlen(name));
255 fputs("</h1><span class=\"desc\">", fp);
256 xmlencode(fp, description, strlen(description));
257 fputs("</span></td></tr>", fp);
259 fputs("<tr class=\"url\"><td></td><td>git clone <a href=\"", fp);
260 xmlencode(fp, cloneurl, strlen(cloneurl));
262 xmlencode(fp, cloneurl, strlen(cloneurl));
263 fputs("</a></td></tr>", fp);
265 fputs("<tr><td></td><td>\n", fp);
266 fprintf(fp, "<a href=\"%slog/HEAD.html\">Log</a> | ", relpath);
267 fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath);
268 fprintf(fp, "<a href=\"%srefs.html\">Refs/branches</a>", relpath);
270 fprintf(fp, " | <a href=\"%sfile/README.html\">README</a>", relpath);
272 fprintf(fp, " | <a href=\"%sfile/LICENSE.html\">LICENSE</a>", relpath);
273 fputs("</td></tr></table>\n<hr/><div id=\"content\">\n", fp);
279 writefooter(FILE *fp)
281 return !fputs("</div></body>\n</html>", fp);
285 writeblobhtml(FILE *fp, const git_blob *blob)
289 char *nfmt = "<a href=\"#l%d\" id=\"l%d\">%d</a>\n";
290 const char *s = git_blob_rawcontent(blob);
291 git_off_t len = git_blob_rawsize(blob);
293 fputs("<table id=\"blob\"><tr><td class=\"num\"><pre>\n", fp);
296 fprintf(fp, nfmt, n, n, n);
297 for (i = 0; i < len - 1; i++) {
300 fprintf(fp, nfmt, n, n, n);
305 fputs("</pre></td><td><pre>\n", fp);
306 xmlencode(fp, s, (size_t)len);
307 fputs("</pre></td></tr></table>\n", fp);
311 printcommit(FILE *fp, struct commitinfo *ci)
313 fprintf(fp, "<b>commit</b> <a href=\"%scommit/%s.html\">%s</a>\n",
314 relpath, ci->oid, ci->oid);
316 if (ci->parentoid[0])
317 fprintf(fp, "<b>parent</b> <a href=\"%scommit/%s.html\">%s</a>\n",
318 relpath, ci->parentoid, ci->parentoid);
321 if ((count = (int)git_commit_parentcount(commit)) > 1) {
322 fputs("<b>Merge:</b>", fp);
323 for (i = 0; i < count; i++) {
324 git_oid_tostr(buf, 8, git_commit_parent_id(commit, i));
325 fprintf(fp, " <a href=\"%scommit/%s.html\">%s</a>",
332 fputs("<b>Author:</b> ", fp);
333 xmlencode(fp, ci->author->name, strlen(ci->author->name));
334 fputs(" <<a href=\"mailto:", fp);
335 xmlencode(fp, ci->author->email, strlen(ci->author->email));
337 xmlencode(fp, ci->author->email, strlen(ci->author->email));
338 fputs("</a>>\n<b>Date:</b> ", fp);
339 printtime(fp, &(ci->author->when));
345 xmlencode(fp, ci->msg, strlen(ci->msg));
351 printshowfile(struct commitinfo *ci)
353 const git_diff_delta *delta;
354 const git_diff_hunk *hunk;
355 const git_diff_line *line;
358 size_t ndeltas, nhunks, nhunklines;
363 snprintf(path, sizeof(path), "commit/%s.html", ci->oid);
364 /* check if file exists if so skip it */
365 if (!access(path, F_OK))
368 fp = efopen(path, "w");
370 fputs("<pre>\n", fp);
373 memset(&statsbuf, 0, sizeof(statsbuf));
377 if (!git_diff_stats_to_buf(&statsbuf, ci->stats,
378 GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_SHORT, 80)) {
379 if (statsbuf.ptr && statsbuf.ptr[0]) {
380 fputs("<b>Diffstat:</b>\n", fp);
381 fputs(statsbuf.ptr, fp);
388 ndeltas = git_diff_num_deltas(ci->diff);
389 for (i = 0; i < ndeltas; i++) {
390 if (git_patch_from_diff(&patch, ci->diff, i)) {
391 git_patch_free(patch);
395 delta = git_patch_get_delta(patch);
396 fprintf(fp, "<b>diff --git a/<a href=\"%sfile/%s.html\">%s</a> b/<a href=\"%sfile/%s.html\">%s</a></b>\n",
397 relpath, delta->old_file.path, delta->old_file.path,
398 relpath, delta->new_file.path, delta->new_file.path);
400 /* check binary data */
401 if (delta->flags & GIT_DIFF_FLAG_BINARY) {
402 fputs("Binary files differ\n", fp);
403 git_patch_free(patch);
407 nhunks = git_patch_num_hunks(patch);
408 for (j = 0; j < nhunks; j++) {
409 if (git_patch_get_hunk(&hunk, &nhunklines, patch, j))
412 fprintf(fp, "<span class=\"h\">%s</span>\n", hunk->header);
415 if (git_patch_get_line_in_hunk(&line, patch, j, k))
417 if (line->old_lineno == -1)
418 fprintf(fp, "<a href=\"#h%zu-%zu\" id=\"h%zu-%zu\" class=\"i\">+",
420 else if (line->new_lineno == -1)
421 fprintf(fp, "<a href=\"#h%zu-%zu\" id=\"h%zu-%zu\" class=\"d\">-",
425 xmlencode(fp, line->content, line->content_len);
426 if (line->old_lineno == -1 || line->new_lineno == -1)
430 git_patch_free(patch);
432 git_buf_free(&statsbuf);
434 fputs("</pre>\n", fp);
441 writelog(FILE *fp, const char *branch)
443 struct commitinfo *ci;
445 git_revwalk *w = NULL;
446 git_object *obj = NULL;
450 mkdir("commit", 0755);
452 if (git_revparse_single(&obj, repo, branch))
454 oid = git_object_id(obj);
456 git_revwalk_new(&w, repo);
457 git_revwalk_push(w, oid);
458 git_revwalk_sorting(w, GIT_SORT_TIME);
459 git_revwalk_simplify_first_parent(w);
461 fputs("<table id=\"log\"><thead>\n<tr><td>Age</td><td>Commit message</td>"
462 "<td>Author</td><td>Files</td><td class=\"num\">+</td>"
463 "<td class=\"num\">-</td></tr>\n</thead><tbody>\n", fp);
464 while (!git_revwalk_next(&id, w)) {
467 if (!(ci = commitinfo_getbyoid(&id)))
470 fputs("<tr><td>", fp);
472 printtimeshort(fp, &(ci->author->when));
473 fputs("</td><td>", fp);
475 fprintf(fp, "<a href=\"%scommit/%s.html\">", relpath, ci->oid);
476 if ((len = strlen(ci->summary)) > summarylen) {
477 xmlencode(fp, ci->summary, summarylen - 1);
480 xmlencode(fp, ci->summary, len);
484 fputs("</td><td>", fp);
486 xmlencode(fp, ci->author->name, strlen(ci->author->name));
487 fputs("</td><td class=\"num\">", fp);
488 fprintf(fp, "%zu", ci->filecount);
489 fputs("</td><td class=\"num\">", fp);
490 fprintf(fp, "+%zu", ci->addcount);
491 fputs("</td><td class=\"num\">", fp);
492 fprintf(fp, "-%zu", ci->delcount);
493 fputs("</td></tr>\n", fp);
500 fputs("</tbody></table>", fp);
503 git_object_free(obj);
511 printcommitatom(FILE *fp, struct commitinfo *ci)
513 fputs("<entry>\n", fp);
515 fprintf(fp, "<id>%s</id>\n", ci->oid);
517 fputs("<updated>", fp);
518 printtimez(fp, &(ci->author->when));
519 fputs("</updated>\n", fp);
522 fputs("<title type=\"text\">", fp);
523 xmlencode(fp, ci->summary, strlen(ci->summary));
524 fputs("</title>\n", fp);
527 fputs("<content type=\"text\">", fp);
528 fprintf(fp, "commit %s\n", ci->oid);
529 if (ci->parentoid[0])
530 fprintf(fp, "parent %s\n", ci->parentoid);
533 if ((count = (int)git_commit_parentcount(commit)) > 1) {
535 for (i = 0; i < count; i++) {
536 git_oid_tostr(buf, 8, git_commit_parent_id(commit, i));
537 fprintf(fp, " %s", buf);
544 fputs("Author: ", fp);
545 xmlencode(fp, ci->author->name, strlen(ci->author->name));
547 xmlencode(fp, ci->author->email, strlen(ci->author->email));
548 fputs(">\nDate: ", fp);
549 printtime(fp, &(ci->author->when));
554 xmlencode(fp, ci->msg, strlen(ci->msg));
555 fputs("\n</content>\n", fp);
557 fputs("<author><name>", fp);
558 xmlencode(fp, ci->author->name, strlen(ci->author->name));
559 fputs("</name>\n<email>", fp);
560 xmlencode(fp, ci->author->email, strlen(ci->author->email));
561 fputs("</email>\n</author>\n", fp);
563 fputs("</entry>\n", fp);
569 struct commitinfo *ci;
570 git_revwalk *w = NULL;
572 size_t i, m = 100; /* max */
574 fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
575 "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n<title>", fp);
576 xmlencode(fp, name, strlen(name));
577 fputs(", branch master</title>\n<subtitle>", fp);
579 xmlencode(fp, description, strlen(description));
580 fputs("</subtitle>\n", fp);
582 git_revwalk_new(&w, repo);
583 git_revwalk_push_head(w);
584 git_revwalk_sorting(w, GIT_SORT_TIME);
585 git_revwalk_simplify_first_parent(w);
587 for (i = 0; i < m && !git_revwalk_next(&id, w); i++) {
588 if (!(ci = commitinfo_getbyoid(&id)))
590 printcommitatom(fp, ci);
595 fputs("</feed>", fp);
601 writeblob(git_object *obj, const char *filename, git_off_t filesize)
603 char fpath[PATH_MAX];
604 char tmp[PATH_MAX] = "";
608 snprintf(fpath, sizeof(fpath), "file/%s.html", filename);
619 strlcat(tmp, "../", sizeof(tmp));
624 fp = efopen(fpath, "w");
627 xmlencode(fp, filename, strlen(filename));
628 fprintf(fp, " (%" PRIu32 "b)", filesize);
629 fputs("</p><hr/>", fp);
631 if (git_blob_is_binary((git_blob *)obj)) {
632 fputs("<p>Binary file</p>\n", fp);
634 writeblobhtml(fp, (git_blob *)obj);
647 filemode(git_filemode_t m)
649 static char mode[11];
651 memset(mode, '-', sizeof(mode) - 1);
662 else if (S_ISFIFO(m))
666 else if (S_ISSOCK(m))
671 if (m & S_IRUSR) mode[1] = 'r';
672 if (m & S_IWUSR) mode[2] = 'w';
673 if (m & S_IXUSR) mode[3] = 'x';
674 if (m & S_IRGRP) mode[4] = 'r';
675 if (m & S_IWGRP) mode[5] = 'w';
676 if (m & S_IXGRP) mode[6] = 'x';
677 if (m & S_IROTH) mode[7] = 'r';
678 if (m & S_IWOTH) mode[8] = 'w';
679 if (m & S_IXOTH) mode[9] = 'x';
681 if (m & S_ISUID) mode[3] = (mode[3] == 'x') ? 's' : 'S';
682 if (m & S_ISGID) mode[6] = (mode[6] == 'x') ? 's' : 'S';
683 if (m & S_ISVTX) mode[9] = (mode[9] == 'x') ? 't' : 'T';
689 writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path)
691 const git_tree_entry *entry = NULL;
692 const char *filename;
693 char filepath[PATH_MAX];
694 git_object *obj = NULL;
699 count = git_tree_entrycount(tree);
700 for (i = 0; i < count; i++) {
701 if (!(entry = git_tree_entry_byindex(tree, i)) ||
702 git_tree_entry_to_object(&obj, repo, entry))
704 filename = git_tree_entry_name(entry);
705 switch (git_object_type(obj)) {
710 ret = writefilestree(fp, (git_tree *)obj, branch,
712 git_object_free(obj);
717 git_object_free(obj);
721 snprintf(filepath, sizeof(filepath), "%s/%s",
725 filesize = git_blob_rawsize((git_blob *)obj);
727 fputs("<tr><td>", fp);
728 fprintf(fp, "%s", filemode(git_tree_entry_filemode(entry)));
729 fprintf(fp, "</td><td><a href=\"%sfile/", relpath);
730 xmlencode(fp, filename, strlen(filename));
731 fputs(".html\">", fp);
732 xmlencode(fp, filename, strlen(filename));
733 fputs("</a></td><td class=\"num\">", fp);
734 fprintf(fp, "%" PRIu32, filesize);
735 fputs("</td></tr>\n", fp);
737 writeblob(obj, filename, filesize);
744 writefiles(FILE *fp, const char *branch)
747 git_tree *tree = NULL;
748 git_object *obj = NULL;
749 git_commit *commit = NULL;
752 fputs("<table id=\"files\"><thead>\n<tr>"
753 "<td>Mode</td><td>Name</td><td class=\"num\">Size</td>"
754 "</tr>\n</thead><tbody>\n", fp);
756 if (git_revparse_single(&obj, repo, branch))
758 id = git_object_id(obj);
759 if (git_commit_lookup(&commit, repo, id) ||
760 git_commit_tree(&tree, commit))
762 ret = writefilestree(fp, tree, branch, "");
765 fputs("</tbody></table>", fp);
767 git_object_free(obj);
768 git_commit_free(commit);
775 writebranches(FILE *fp)
777 struct commitinfo *ci;
778 git_branch_iterator *it = NULL;
780 git_reference *ref = NULL, *dref = NULL;
781 const git_oid *id = NULL;
782 const char *branchname = NULL;
786 /* log for local branches */
787 if (git_branch_iterator_new(&it, repo, GIT_BRANCH_LOCAL))
790 fputs("<h2>Branches</h2><table id=\"branches\"><thead>\n<tr><td>Branch</td><td>Age</td>"
791 "<td>Commit message</td>"
792 "<td>Author</td><td>Files</td><td class=\"num\">+</td>"
793 "<td class=\"num\">-</td></tr>\n</thead><tbody>\n", fp);
795 while (!git_branch_next(&ref, &branch, it)) {
796 if (git_branch_name(&branchname, ref))
800 switch (git_reference_type(ref)) {
801 case GIT_REF_SYMBOLIC:
802 if (git_reference_resolve(&dref, ref))
804 id = git_reference_target(dref);
807 id = git_reference_target(ref);
814 if (!(ci = commitinfo_getbyoid(id)))
819 fputs("<tr><td>", fp);
820 xmlencode(fp, branchname, strlen(branchname));
821 fputs("</td><td>", fp);
823 printtimeshort(fp, &(ci->author->when));
824 fputs("</td><td>", fp);
826 fprintf(fp, "<a href=\"%scommit/%s.html\">", relpath, ci->oid);
827 if ((len = strlen(ci->summary)) > summarylen) {
828 xmlencode(fp, ci->summary, summarylen - 1);
831 xmlencode(fp, ci->summary, len);
835 fputs("</td><td>", fp);
837 xmlencode(fp, ci->author->name, strlen(ci->author->name));
838 fputs("</td><td class=\"num\">", fp);
839 fprintf(fp, "%zu", ci->filecount);
840 fputs("</td><td class=\"num\">", fp);
841 fprintf(fp, "+%zu", ci->addcount);
842 fputs("</td><td class=\"num\">", fp);
843 fprintf(fp, "-%zu", ci->delcount);
844 fputs("</td></tr>\n", fp);
849 git_reference_free(ref);
850 git_reference_free(dref);
857 fputs("</tbody></table>", fp);
858 git_reference_free(ref);
859 git_reference_free(dref);
860 git_branch_iterator_free(it);
866 tagcompare(void *s1, void *s2)
868 return strcmp(*(char **)s1, *(char **)s2);
874 struct commitinfo *ci;
875 git_strarray tagnames;
876 git_object *obj = NULL;
877 const git_oid *id = NULL;
880 /* summary page with branches and tags */
881 memset(&tagnames, 0, sizeof(tagnames));
882 if (git_tag_list(&tagnames, repo))
884 if (!tagnames.count) {
885 git_strarray_free(&tagnames);
890 qsort(tagnames.strings, tagnames.count, sizeof(char *),
891 (int (*)(const void *, const void *))&tagcompare);
893 fputs("<h2>Tags</h2><table id=\"branches\"><thead>\n<tr><td>Tag</td>"
894 "<td>Age</td><td>Commit message</td>"
895 "<td>Author</td><td>Files</td><td class=\"num\">+</td>"
896 "<td class=\"num\">-</td></tr>\n</thead><tbody>\n", fp);
898 for (i = 0; i < tagnames.count; i++) {
899 if (git_revparse_single(&obj, repo, tagnames.strings[i]))
901 id = git_object_id(obj);
902 if (!(ci = commitinfo_getbyoid(id)))
907 fputs("<tr><td>", fp);
908 xmlencode(fp, tagnames.strings[i], strlen(tagnames.strings[i]));
909 fputs("</td><td>", fp);
911 printtimeshort(fp, &(ci->author->when));
912 fputs("</td><td>", fp);
914 fprintf(fp, "<a href=\"%scommit/%s.html\">", relpath, ci->oid);
915 if ((len = strlen(ci->summary)) > summarylen) {
916 xmlencode(fp, ci->summary, summarylen - 1);
919 xmlencode(fp, ci->summary, len);
923 fputs("</td><td>", fp);
925 xmlencode(fp, ci->author->name, strlen(ci->author->name));
926 fputs("</td><td class=\"num\">", fp);
927 fprintf(fp, "%zu", ci->filecount);
928 fputs("</td><td class=\"num\">", fp);
929 fprintf(fp, "+%zu", ci->addcount);
930 fputs("</td><td class=\"num\">", fp);
931 fprintf(fp, "-%zu", ci->delcount);
932 fputs("</td></tr>\n", fp);
937 git_object_free(obj);
939 fputs("</tbody></table>", fp);
940 git_strarray_free(&tagnames);
950 if ((ret = writebranches(fp)))
953 return writetags(fp);
957 main(int argc, char *argv[])
959 git_object *obj = NULL;
960 const git_error *e = NULL;
962 char path[PATH_MAX], *p;
966 fprintf(stderr, "%s <repodir>\n", argv[0]);
973 if ((status = git_repository_open_ext(&repo, repodir,
974 GIT_REPOSITORY_OPEN_NO_SEARCH, NULL)) < 0) {
976 fprintf(stderr, "error %d/%d: %s\n", status, e->klass, e->message);
980 /* use directory name as name */
981 p = xbasename(repodir);
982 snprintf(name, sizeof(name), "%s", p);
985 /* read description or .git/description */
986 snprintf(path, sizeof(path), "%s%s%s",
987 repodir, repodir[strlen(repodir)] == '/' ? "" : "/", "description");
988 if (!(fpread = fopen(path, "r"))) {
989 snprintf(path, sizeof(path), "%s%s%s",
990 repodir, repodir[strlen(repodir)] == '/' ? "" : "/", ".git/description");
991 fpread = fopen(path, "r");
994 if (!fgets(description, sizeof(description), fpread))
995 description[0] = '\0';
999 /* read url or .git/url */
1000 snprintf(path, sizeof(path), "%s%s%s",
1001 repodir, repodir[strlen(repodir)] == '/' ? "" : "/", "url");
1002 if (!(fpread = fopen(path, "r"))) {
1003 snprintf(path, sizeof(path), "%s%s%s",
1004 repodir, repodir[strlen(repodir)] == '/' ? "" : "/", ".git/url");
1005 fpread = fopen(path, "r");
1008 if (!fgets(cloneurl, sizeof(cloneurl), fpread))
1014 haslicense = !git_revparse_single(&obj, repo, "HEAD:LICENSE");
1015 git_object_free(obj);
1017 hasreadme = !git_revparse_single(&obj, repo, "HEAD:README");
1018 git_object_free(obj);
1022 fp = efopen("log/HEAD.html", "w");
1026 writelog(fp, "HEAD");
1030 /* files for HEAD */
1031 fp = efopen("files.html", "w");
1033 writefiles(fp, "HEAD");
1037 /* summary page with branches and tags */
1038 fp = efopen("refs.html", "w");
1045 fp = efopen("atom.xml", "w");
1050 git_repository_free(repo);
1051 git_libgit2_shutdown();