ctucx.git: stagit

ctucx' stagit fork

commit a396a52cee34ccad0eba418738915d1b3281fc74
parent 82b8f21627a1402e0de12b589008588b38a65804
Author: Leah (ctucx) <leah@ctu.cx>
Date: Sun, 22 May 2022 14:19:09 +0200

remove: atom-feed generators
1 file changed, 1 insertion(+), 126 deletions(-)
M
stagit.c
|
127
+------------------------------------------------------------------------------
diff --git a/stagit.c b/stagit.c
@@ -59,7 +59,6 @@ struct referenceinfo {
 
 static git_repository *repo;
 
-static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */
 static const char *relpath = "";
 static const char *repodir;
 

@@ -530,11 +529,6 @@ writeheader(FILE *fp, const char *title)
 	xmlencode(fp, description, strlen(description));
 	fprintf(fp, "</title>\n<link rel=\"icon\" type=\"image/svg+xml\" href=\"../%slogo.svg\" />\n", relpath);
 	fprintf(fp, "<link rel=\"alternate icon\" href=\"../%sfavicon.ico\" />\n", relpath);
-	fputs("<link rel=\"alternate\" type=\"application/atom+xml\" title=\"", fp);
-	xmlencode(fp, name, strlen(name));
-	fprintf(fp, " Atom Feed\" href=\"%satom.xml\" />\n", relpath);
-	fputs("<link rel=\"alternate\" type=\"application/atom+xml\" title=\"", fp);
-	fprintf(fp, " Atom Feed (tags)\" href=\"%stags.xml\" />\n", relpath);
 	fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"../%sstyle.css\" />\n", relpath);
 	fputs("</head>\n<body>\n<div id=\"head\"><table><tr><td>", fp);
 	fprintf(fp, "<a class=\"logo\" href=\"../%s\"><img src=\"../%slogo.svg\" alt=\"\" width=\"32\" height=\"32\" /></a>",

@@ -865,109 +859,6 @@ err:
 }
 
 void
-printcommitatom(FILE *fp, struct commitinfo *ci, const char *tag)
-{
-	fputs("<entry>\n", fp);
-
-	fprintf(fp, "<id>%s</id>\n", ci->oid);
-	if (ci->author) {
-		fputs("<published>", fp);
-		printtimez(fp, &(ci->author->when));
-		fputs("</published>\n", fp);
-	}
-	if (ci->committer) {
-		fputs("<updated>", fp);
-		printtimez(fp, &(ci->committer->when));
-		fputs("</updated>\n", fp);
-	}
-	if (ci->summary) {
-		fputs("<title type=\"text\">", fp);
-		if (tag && tag[0]) {
-			fputs("[", fp);
-			xmlencode(fp, tag, strlen(tag));
-			fputs("] ", fp);
-		}
-		xmlencode(fp, ci->summary, strlen(ci->summary));
-		fputs("</title>\n", fp);
-	}
-	fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"%scommit/%s.html\" />\n",
-	        baseurl, ci->oid);
-
-	if (ci->author) {
-		fputs("<author>\n<name>", fp);
-		xmlencode(fp, ci->author->name, strlen(ci->author->name));
-		fputs("</name>\n<email>", fp);
-		xmlencode(fp, ci->author->email, strlen(ci->author->email));
-		fputs("</email>\n</author>\n", fp);
-	}
-
-	fputs("<content type=\"text\">", fp);
-	fprintf(fp, "commit %s\n", ci->oid);
-	if (ci->parentoid[0])
-		fprintf(fp, "parent %s\n", ci->parentoid);
-	if (ci->author) {
-		fputs("Author: ", fp);
-		xmlencode(fp, ci->author->name, strlen(ci->author->name));
-		fputs(" &lt;", fp);
-		xmlencode(fp, ci->author->email, strlen(ci->author->email));
-		fputs("&gt;\nDate:   ", fp);
-		printtime(fp, &(ci->author->when));
-		putc('\n', fp);
-	}
-	if (ci->msg) {
-		putc('\n', fp);
-		xmlencode(fp, ci->msg, strlen(ci->msg));
-	}
-	fputs("\n</content>\n</entry>\n", fp);
-}
-
-int
-writeatom(FILE *fp, int all)
-{
-	struct referenceinfo *ris = NULL;
-	size_t refcount = 0;
-	struct commitinfo *ci;
-	git_revwalk *w = NULL;
-	git_oid id;
-	size_t i, m = 100; /* last 'm' commits */
-
-	fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-	      "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n<title>", fp);
-	xmlencode(fp, strippedname, strlen(strippedname));
-	fputs(", branch HEAD</title>\n<subtitle>", fp);
-	xmlencode(fp, description, strlen(description));
-	fputs("</subtitle>\n", fp);
-
-	/* all commits or only tags? */
-	if (all) {
-		git_revwalk_new(&w, repo);
-		git_revwalk_push_head(w);
-		for (i = 0; i < m && !git_revwalk_next(&id, w); i++) {
-			if (!(ci = commitinfo_getbyoid(&id)))
-				break;
-			printcommitatom(fp, ci, "");
-			commitinfo_free(ci);
-		}
-		git_revwalk_free(w);
-	} else if (getrefs(&ris, &refcount) != -1) {
-		/* references: tags */
-		for (i = 0; i < refcount; i++) {
-			if (git_reference_is_tag(ris[i].ref))
-				printcommitatom(fp, ris[i].ci,
-				                git_reference_shorthand(ris[i].ref));
-
-			commitinfo_free(ris[i].ci);
-			git_reference_free(ris[i].ref);
-		}
-		free(ris);
-	}
-
-	fputs("</feed>\n", fp);
-
-	return 0;
-}
-
-void
 writeblobraw(const git_blob *blob, const char *fpath, const char *filename, git_off_t filesize)
 {
 	char tmp[PATH_MAX] = "";

@@ -1280,7 +1171,7 @@ void
 usage(char *argv0)
 {
 	fprintf(stderr, "%s [-c cachefile | -l commits] "
-	        "[-u baseurl] repodir\n", argv0);
+	        " repodir\n", argv0);
 	exit(1);
 }
 

@@ -1319,10 +1210,6 @@ 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)

@@ -1531,18 +1418,6 @@ main(int argc, char *argv[])
 	checkfileerror(fp, "refs.html", 'w');
 	fclose(fp);
 
-	/* Atom feed */
-	fp = efopen("atom.xml", "w");
-	writeatom(fp, 1);
-	checkfileerror(fp, "atom.xml", 'w');
-	fclose(fp);
-
-	/* Atom feed for tags / releases */
-	fp = efopen("tags.xml", "w");
-	writeatom(fp, 0);
-	checkfileerror(fp, "tags.xml", 'w');
-	fclose(fp);
-
 	/* rename new cache file on success */
 	if (cachefile && head) {
 		if (rename(tmppath, cachefile))