X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=src%2Fstagit.c;h=24075f6081e2f54024c1babd5ab3e0fa4458d8ad;hb=HEAD;hp=bdf2f70fe64568bd4845b0fdbf76dee2d69b4219;hpb=74775723355a0816113bf2c025c37a6c11fe5fd9;p=stagit.git diff --git a/src/stagit.c b/src/stagit.c index bdf2f70..24075f6 100644 --- a/src/stagit.c +++ b/src/stagit.c @@ -286,47 +286,6 @@ void xmlencodeline(FILE *fp, const char *s, size_t len) { size_t i; - - for (i = 0; *s && i < len; s++, i++) { - switch(*s) { - case '<': fputs("<", fp); break; - case '>': fputs(">", fp); break; - case '\'': fputs("'", fp); break; - case '&': fputs("&", fp); break; - case '"': fputs(""", fp); break; - case '\r': break; /* ignore CR */ - case '\n': break; /* ignore LF */ - default: putc(*s, fp); - } - } -} - -/* Escape characters below as HTML 2.0 / XML 1.0, ignore printing '\n', '\r' */ -void -xmlencodeline(FILE *fp, const char *s, size_t len) -{ - size_t i; - - for (i = 0; *s && i < len; s++, i++) { - switch(*s) { - case '<': fputs("<", fp); break; - case '>': fputs(">", fp); break; - case '\'': fputs("'", fp); break; - case '&': fputs("&", fp); break; - case '"': fputs(""", fp); break; - case '\r': break; /* ignore CR */ - case '\n': break; /* ignore LF */ - default: putc(*s, fp); - } - } -} - -/* Escape characters below as HTML 2.0 / XML 1.0, ignore printing '\n', '\r' */ -void -xmlencodeline(FILE *fp, const char *s, size_t len) -{ - size_t i; - for (i = 0; *s && i < len; s++, i++) { switch(*s) { case '<': fputs("<", fp); break; @@ -428,22 +387,21 @@ writeheader(FILE *fp, const char *title) name, relpath); fprintf(fp, "\n", relpath); fprintf(fp, "\n", relpath); - fputs("\n\n", fp); + fputs("

", fp); if (cloneurl[0]) { - fputs("", fp); + fputs("

", fp); } - fputs("
", fp); - fprintf(fp, "\"Home\"", + fputs("\n\n", fp); + fprintf(fp, "\"\"", relpath, relpath); - fputs("

", fp); + fputs("

", fp); xmlencode(fp, strippedname, strlen(strippedname)); - fputs("

", fp); + fputs("

", fp); xmlencode(fp, description, strlen(description)); - fputs("

git clone git clone ", fp); xmlencode(fp, cloneurl, strlen(cloneurl)); - fputs("
\n", fp); fprintf(fp, "Log | ", relpath); fprintf(fp, "Files | ", relpath); fprintf(fp, "Refs", relpath); @@ -458,7 +416,7 @@ writeheader(FILE *fp, const char *title) relpath, license); fprintf(fp, " | Download", relpath, strippedname); - fputs("
\n
\n
\n", fp); + fputs("
\n
\n", fp); } void @@ -522,6 +480,7 @@ call_chroma(const char *filename, FILE *fp, const char *s, size_t len) #else fprintf(fp, "
%s
", s); #endif + free(html); } void @@ -554,12 +513,12 @@ printcommit(FILE *fp, struct commitinfo *ci) xmlencode(fp, ci->author->email, strlen(ci->author->email)); fputs(">\nDate: ", fp); printtime(fp, &(ci->author->when)); - fputc('\n', fp); + putc('\n', fp); } if (ci->msg) { - fputc('\n', fp); + putc('\n', fp); xmlencode(fp, ci->msg, strlen(ci->msg)); - fputc('\n', fp); + putc('\n', fp); } } @@ -724,7 +683,6 @@ writelog(FILE *fp, const git_oid *oid) git_revwalk_new(&w, repo); git_revwalk_push(w, oid); - git_revwalk_simplify_first_parent(w); while (!git_revwalk_next(&id, w)) { relpath = ""; @@ -827,10 +785,10 @@ printcommitatom(FILE *fp, struct commitinfo *ci) xmlencode(fp, ci->author->email, strlen(ci->author->email)); fputs(">\nDate: ", fp); printtime(fp, &(ci->author->when)); - fputc('\n', fp); + putc('\n', fp); } if (ci->msg) { - fputc('\n', fp); + putc('\n', fp); xmlencode(fp, ci->msg, strlen(ci->msg)); } fputs("\n\n\n", fp); @@ -853,7 +811,6 @@ writeatom(FILE *fp) git_revwalk_new(&w, repo); git_revwalk_push_head(w); - git_revwalk_simplify_first_parent(w); for (i = 0; i < m && !git_revwalk_next(&id, w); i++) { if (!(ci = commitinfo_getbyoid(&id))) @@ -1195,7 +1152,8 @@ err: void usage(char *argv0) { - fprintf(stderr, "%s [-c cachefile | -l commits] repodir\n", argv0); + fprintf(stderr, "%s [-c cachefile | -l commits] " + "[-u baseurl] repodir\n", argv0); exit(1); } @@ -1228,6 +1186,10 @@ main(int argc, char *argv[]) if (argv[i][0] == '\0' || *p != '\0' || nlogcommits <= 0 || errno) usage(argv[0]); + } else if (argv[i][1] == 'u') { + if (i + 1 >= argc) + usage(argv[0]); + baseurl = argv[++i]; } } if (!repodir) @@ -1255,9 +1217,6 @@ main(int argc, char *argv[]) } #endif - if ((p = getenv("STAGIT_BASEURL"))) - baseurl = p; - if (git_repository_open_ext(&repo, repodir, GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) < 0) { fprintf(stderr, "%s: cannot open repository\n", argv[0]); @@ -1429,6 +1388,7 @@ main(int argc, char *argv[]) /* cleanup */ git_repository_free(repo); git_libgit2_shutdown(); + free(strippedname); return 0; }