stagit

static git page generator  https://git.ce9e.org
git clone https://git.ce9e.org/stagit.git

commit
976716284746fd7f485dcf0139828983f133121c
parent
8c1c1c0ce8aee0f053a29195f828eb5186144b3b
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-03-28 08:41
mostly remove relpath

avoid mutable state

Diffstat

M stagit.c 24 ++++++++++--------------

1 files changed, 10 insertions, 14 deletions


diff --git a/stagit.c b/stagit.c

@@ -49,7 +49,6 @@ struct commitstats {
   49    49 
   50    50 static git_repository *repo;
   51    51 
   52    -1 static const char *relpath = "";
   53    52 static const char *repodir;
   54    53 
   55    54 /* reponame is a pointer into repodirabs */
@@ -312,7 +311,7 @@ printtimeshort(FILE *fp, const git_time *intime)
  312   311 }
  313   312 
  314   313 void
  315    -1 write_header(FILE *fp, const char *title)
   -1   314 write_header(FILE *fp, const char *title, const char *relpath)
  316   315 {
  317   316 	fputs("<!DOCTYPE html>\n", fp);
  318   317 	fputs("<html>\n", fp);
@@ -446,12 +445,12 @@ write_commit_file(FILE *fp, struct deltainfo *di, size_t i)
  446   445 
  447   446 	fprintf(fp, "<h2 id=\"h%zu\">\n", i);
  448   447 	fputs("diff --git\n", fp);
  449    -1 	fprintf(fp, "a/<a href=\"%sblob/", relpath);
   -1   448 	fprintf(fp, "a/<a href=\"../blob/");
  450   449 	xmlencode(fp, delta->old_file.path, strlen(delta->old_file.path));
  451   450 	fputs("\">", fp);
  452   451 	xmlencode(fp, delta->old_file.path, strlen(delta->old_file.path));
  453   452 	fputs("</a>\n", fp);
  454    -1 	fprintf(fp, "b/<a href=\"%sblob/", relpath);
   -1   453 	fprintf(fp, "b/<a href=\"../blob/");
  455   454 	xmlencode(fp, delta->new_file.path, strlen(delta->new_file.path));
  456   455 	fputs("\">", fp);
  457   456 	xmlencode(fp, delta->new_file.path, strlen(delta->new_file.path));
@@ -494,11 +493,10 @@ write_commit(FILE *fp, struct commitinfo *ci)
  494   493 	struct commitstats *cs = commitinfo_getstats(ci);
  495   494 
  496   495 	fputs("<dl>\n", fp);
  497    -1 	fprintf(fp, "<dt>commit</dt><dd><a href=\"%scommit/%s.html\">%s</a></dd>\n",
  498    -1 			relpath, ci->oid, ci->oid);
   -1   496 	fprintf(fp, "<dt>commit</dt><dd><a href=\"\">%s</a></dd>\n", ci->oid);
  499   497 	if (ci->parentoid[0])
  500    -1 		fprintf(fp, "<dt>parent</dt><dd><a href=\"%scommit/%s.html\">%s</a></dd>\n",
  501    -1 			relpath, ci->parentoid, ci->parentoid);
   -1   498 		fprintf(fp, "<dt>parent</dt><dd><a href=\"%s.html\">%s</a></dd>\n",
   -1   499 			ci->parentoid, ci->parentoid);
  502   500 	if (ci->author) {
  503   501 		fputs("<dt>Author</dt><dd>", fp);
  504   502 		xmlencode(fp, ci->author->name, strlen(ci->author->name));
@@ -568,7 +566,7 @@ write_log_line(FILE *fp, struct commitinfo *ci)
  568   566 {
  569   567 	fputs("<tr><td>", fp);
  570   568 	if (ci->author) {
  571    -1 		fprintf(fp, "<a href=\"%scommit/%s.html\">", relpath, ci->oid);
   -1   569 		fprintf(fp, "<a href=\"commit/%s.html\">", ci->oid);
  572   570 		printtimeshort(fp, &(ci->author->when));
  573   571 		fputs("</a>", fp);
  574   572 	}
@@ -817,14 +815,12 @@ process_commits(FILE *fp_log, FILE *fp_atom, size_t m)
  817   815 		snprintf(path, sizeof(path), "commit/%s.html", oidstr);
  818   816 
  819   817 		if (force_commits || access(path, F_OK)) {
  820    -1 			relpath = "../";
  821   818 			mkdirp("commit");
  822   819 			fp_commit = efopen(path, "w");
  823    -1 			write_header(fp_commit, ci->summary);
   -1   820 			write_header(fp_commit, ci->summary, "../");
  824   821 			write_commit(fp_commit, ci);
  825   822 			write_footer(fp_commit);
  826   823 			fclose(fp_commit);
  827    -1 			relpath = "";
  828   824 		}
  829   825 
  830   826 		m -= 1;
@@ -908,10 +904,10 @@ main(int argc, char *argv[])
  908   904 	fp_log = efopen("log.html", "w");
  909   905 	fp_atom = efopen("atom.xml", "w");
  910   906 
  911    -1 	write_header(fp_index, "Files");
   -1   907 	write_header(fp_index, "Files", "");
  912   908 	write_files_header(fp_index);
  913   909 
  914    -1 	write_header(fp_log, "Log");
   -1   910 	write_header(fp_log, "Log", "");
  915   911 	write_log_header(fp_log);
  916   912 
  917   913 	write_atom_header(fp_atom);