stagit

submodule support

- detect .gitmodules file for submodules, add a link "submodules" to the top menu.
- link each submodule to the .gitmodules file in HEAD.
- revert the special style for modules, but list it as a file "m---------", don't show
  the line/filesize though, it is not a file.

Hiltjo Posthuma contact@arjunchoudhary.com

commit: 3b0d8ec parent: 8616579
2 files changed, 9 insertions(+), 19 deletions(-)
Mstagit.c+9-15
Mstyle.css+0-4
M · stagit.c +9, -15
 1@@ -46,7 +46,7 @@ static char *name = "";
 2 static char *stripped_name;
 3 static char description[255];
 4 static char cloneurl[1024];
 5-static int hasreadme, haslicense;
 6+static int haslicense, hasreadme, hassubmodules;
 7 
 8 void
 9 commitinfo_free(struct commitinfo *ci)
10@@ -251,6 +251,8 @@ writeheader(FILE *fp, const char *title)
11 	fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
12 	fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath);
13 	fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath);
14+	if (hassubmodules)
15+		fprintf(fp, " | <a href=\"%sfile/.gitmodules.html\">Submodules</a>", relpath);
16 	if (hasreadme)
17 		fprintf(fp, " | <a href=\"%sfile/README.html\">README</a>", relpath);
18 	if (haslicense)
19@@ -654,7 +656,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path)
20 {
21 	const git_tree_entry *entry = NULL;
22 	git_submodule *module = NULL;
23-	const char *entryname, *moduleurl;
24+	const char *entryname;
25 	char filepath[PATH_MAX], entrypath[PATH_MAX];
26 	git_object *obj = NULL;
27 	git_off_t filesize;
28@@ -709,21 +711,11 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path)
29 				fprintf(fp, "%juB", (uintmax_t)filesize);
30 			fputs("</td></tr>\n", fp);
31 		} else if (!git_submodule_lookup(&module, repo, entryname)) {
32-			fputs("<tr><td>m---------</td><td>", fp);
33-			if ((moduleurl = git_submodule_url(module))) {
34-				fprintf(fp, "<a class=\"module\" href=\"%s\">",
35-				        moduleurl);
36-			}
37+			fprintf(fp, "<tr><td>m------</td><td><a href=\"%sfile/.gitmodules.html\">",
38+				relpath);
39 			xmlencode(fp, entrypath, strlen(entrypath));
40-			if (moduleurl) {
41-				fputs(" @", fp);
42-				xmlencode(fp, moduleurl, strlen(moduleurl));
43-				fputs("</a>", fp);
44-			}
45-			fprintf(fp, "</td><td class=\"num\">0%c",
46-				showlinecount ? 'L' : 'B');
47 			git_submodule_free(module);
48-			fputs("</td></tr>\n", fp);
49+			fputs("</a></td><td class=\"num\"></td></tr>\n", fp);
50 		}
51 	}
52 
53@@ -963,6 +955,8 @@ main(int argc, char *argv[])
54 	/* check README */
55 	hasreadme = !git_revparse_single(&obj, repo, "HEAD:README");
56 	git_object_free(obj);
57+	hassubmodules = !git_revparse_single(&obj, repo, "HEAD:.gitmodules");
58+	git_object_free(obj);
59 
60 	/* log for HEAD */
61 	fp = efopen("log.html", "w");
M · style.css +0, -4
 1@@ -58,10 +58,6 @@ table td {
 2 	white-space: normal;
 3 }
 4 
 5-a.module {
 6-	color: #000;
 7-}
 8-
 9 td.num {
10 	text-align: right;
11 }