stagit

allow to specify clone url, displayed in header

Hiltjo Posthuma contact@arjunchoudhary.com

commit: 360728d parent: b17b3f0
1 files changed, 24 insertions(+), 1 deletions(-)
Murmoms.c+24-1
M · urmoms.c +24, -1
 1@@ -44,6 +44,7 @@ static const char *repodir;
 2 
 3 static char name[255];
 4 static char description[255];
 5+static char cloneurl[1024];
 6 static int hasreadme, haslicense;
 7 
 8 void
 9@@ -232,7 +233,15 @@ writeheader(FILE *fp)
10 	xmlencode(fp, name, strlen(name));
11 	fputs("</h1><span class=\"desc\">", fp);
12 	xmlencode(fp, description, strlen(description));
13-	fputs("</span></td></tr><tr><td></td><td>\n", fp);
14+	fputs("</span></td></tr>", fp);
15+	if (cloneurl[0]) {
16+		fputs("<tr class=\"url\"><td></td><td>git clone <a href=\"", fp);
17+		xmlencode(fp, cloneurl, strlen(cloneurl));
18+		fputs("\">", fp);
19+		xmlencode(fp, cloneurl, strlen(cloneurl));
20+		fputs("</a></td></tr>", fp);
21+	}
22+	fputs("<tr><td></td><td>\n", fp);
23 	fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
24 	fprintf(fp, "<a href=\"%sfiles.html\">Files</a>", relpath);
25 	if (hasreadme)
26@@ -730,6 +739,20 @@ main(int argc, char *argv[])
27 		fclose(fpread);
28 	}
29 
30+	/* read url or .git/url */
31+	snprintf(path, sizeof(path), "%s%s%s",
32+		repodir, repodir[strlen(repodir)] == '/' ? "" : "/", "url");
33+	if (!(fpread = fopen(path, "r"))) {
34+		snprintf(path, sizeof(path), "%s%s%s",
35+			repodir, repodir[strlen(repodir)] == '/' ? "" : "/", ".git/url");
36+		fpread = fopen(path, "r");
37+	}
38+	if (fpread) {
39+		if (!fgets(cloneurl, sizeof(cloneurl), fpread))
40+			cloneurl[0] = '\0';
41+		fclose(fpread);
42+	}
43+
44 	/* check LICENSE */
45 	haslicense = !git_revparse_single(&obj, repo, "HEAD:LICENSE");
46 	git_object_free(obj);