implify and restructure code - stagit-gopher - A git gopher frontend. (mirror) | |
git clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/ | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit 934980659a7c1d7ccebec69a65eef2bf96a6c7a2 | |
parent efe16db1e509b1c8f8b06a003126c19f4f8dacaa | |
Author: Hiltjo Posthuma | |
Date: Fri, 8 Jan 2016 20:08:40 +0100 implify and restructure code - remove commit message and lines changed from refs page. - resolve HEAD once. - dont make filepath in writeblob() Diffstat: M stagit.c | 107 +++++++++++-------------------- 1 file changed, 37 insertions(+), 70 deletions(-) --- | |
diff --git a/stagit.c b/stagit.c | |
@@ -329,12 +329,11 @@ printcommit(FILE *fp, struct commitinfo *ci) printtime(fp, &(ci->author->when)); fputc('\n', fp); } - fputc('\n', fp); - - if (ci->msg) + if (ci->msg) { + fputc('\n', fp); xmlencode(fp, ci->msg, strlen(ci->msg)); - - fputc('\n', fp); + fputc('\n', fp); + } } void @@ -357,19 +356,18 @@ printshowfile(struct commitinfo *ci) fp = efopen(path, "w"); writeheader(fp); - fputs("\n", fp); + fputs("", fp); printcommit(fp, ci); memset(&statsbuf, 0, sizeof(statsbuf)); /* diff stat */ - if (ci->stats) { - if (!git_diff_stats_to_buf(&statsbuf, ci->stats, - GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_SHORT, 80)) { - if (statsbuf.ptr && statsbuf.ptr[0]) { - fputs("Diffstat:\n", fp); - fputs(statsbuf.ptr, fp); - } + if (ci->stats && + !git_diff_stats_to_buf(&statsbuf, ci->stats, + GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_SHORT, 80)) { + if (statsbuf.ptr && statsbuf.ptr[0]) { + fputs("Diffstat:\n", fp); + xmlencode(fp, statsbuf.ptr, strlen(statsbuf.ptr)); } } @@ -430,21 +428,13 @@ printshowfile(struct commitinfo *ci) } int -writelog(FILE *fp, const char *branch) +writelog(FILE *fp, const git_oid *oid) { struct commitinfo *ci; - const git_oid *oid; git_revwalk *w = NULL; - git_object *obj = NULL; git_oid id; size_t len; - mkdir("commit", 0755); - - if (git_revparse_single(&obj, repo, branch)) - return -1; - oid = git_object_id(obj); - git_revwalk_new(&w, repo); git_revwalk_push(w, oid); git_revwalk_sorting(w, GIT_SORT_TIME); @@ -493,7 +483,6 @@ writelog(FILE *fp, const char *branch) fputs(" |
%s | " - "Age | Commit message | " - "Author | Files | + | " - "- | Age | Author | \n\n\n", titles[j], ids[j], cols[j]); } @@ -842,28 +821,8 @@ writerefs(FILE *fp) if (ci->author) printtimeshort(fp, &(ci->author->when)); fputs("", fp); - if (ci->summary) { - if (j) - fprintf(fp, "", - relpath, ci->oid); - if ((len = strlen(ci->summary)) > summarylen) { - xmlencode(fp, ci->summary, summarylen - 1); - fputs("…", fp); - } else { - xmlencode(fp, ci->summary, len); - } - if (j) - fputs("", fp); - } - fputs(" | ", fp); if (ci->author) xmlencode(fp, ci->author->name, strlen(ci->author->name)); - fputs(" | ", fp); - fprintf(fp, "%zu", ci->filecount); - fputs(" | ", fp); - fprintf(fp, "+%zu", ci->addcount); - fputs(" | ", fp); - fprintf(fp, "-%zu", ci->delcount); fputs(" | \n", fp); relpath = "../"; @@ -876,7 +835,7 @@ writerefs(FILE *fp) } /* table footer */ if (count) - fputs("