- struct commitinfo *ci;
- git_branch_iterator *it = NULL;
- git_branch_t branch;
- git_reference *ref = NULL, *dref = NULL;
- const git_oid *id = NULL;
- const char *branchname = NULL;
- size_t len;
- int ret = -1;
-
- /* log for local branches */
- if (git_branch_iterator_new(&it, repo, GIT_BRANCH_LOCAL))
- return -1;
-
- fputs("<h2>Branches</h2><table id=\"branches\"><thead>\n<tr><td>Branch</td><td>Age</td>"
- "<td>Commit message</td>"
- "<td>Author</td><td>Files</td><td class=\"num\">+</td>"
- "<td class=\"num\">-</td></tr>\n</thead><tbody>\n", fp);
-
- while (!git_branch_next(&ref, &branch, it)) {
- if (git_branch_name(&branchname, ref))
- continue;
-
- id = NULL;
- switch (git_reference_type(ref)) {
- case GIT_REF_SYMBOLIC:
- if (git_reference_resolve(&dref, ref))
- goto err;
- id = git_reference_target(dref);
- break;
- case GIT_REF_OID:
- id = git_reference_target(ref);
- break;
- default:
- continue;
- }
- if (!id)
- goto err;
- if (!(ci = commitinfo_getbyoid(id)))
- break;
-
- relpath = "";
-
- fputs("<tr><td>", fp);
- xmlencode(fp, branchname, strlen(branchname));
- fputs("</td><td>", fp);
- if (ci->author)
- printtimeshort(fp, &(ci->author->when));
- fputs("</td><td>", fp);
- if (ci->summary) {
- if ((len = strlen(ci->summary)) > summarylen) {
- xmlencode(fp, ci->summary, summarylen - 1);
- fputs("…", fp);
- } else {
- xmlencode(fp, ci->summary, len);
- }
- }
- fputs("</td><td>", fp);
- if (ci->author)
- xmlencode(fp, ci->author->name, strlen(ci->author->name));
- fputs("</td><td class=\"num\">", fp);
- fprintf(fp, "%zu", ci->filecount);
- fputs("</td><td class=\"num\">", fp);
- fprintf(fp, "+%zu", ci->addcount);
- fputs("</td><td class=\"num\">", fp);
- fprintf(fp, "-%zu", ci->delcount);
- fputs("</td></tr>\n", fp);
-
- relpath = "../";