stagit

treat an empty repo (without a HEAD) as valid

and create the standard files. Disable caching if there is no HEAD.

Hiltjo Posthuma contact@arjunchoudhary.com

commit: f80364a parent: 259ea1e
1 files changed, 10 insertions(+), 5 deletions(-)
Mstagit.c+10-5
M · stagit.c +10, -5
 1@@ -1038,11 +1038,14 @@ main(int argc, char *argv[])
 2 	}
 3 
 4 	/* find HEAD */
 5-	if (git_revparse_single(&obj, repo, "HEAD"))
 6-		return 1;
 7-	head = git_object_id(obj);
 8+	if (!git_revparse_single(&obj, repo, "HEAD"))
 9+		head = git_object_id(obj);
10 	git_object_free(obj);
11 
12+	/* don't cache if there is no HEAD */
13+	if (!head)
14+		cachefile = NULL;
15+
16 	/* use directory name as name */
17 	if ((name = strrchr(repodirabs, '/')))
18 		name++;
19@@ -1138,7 +1141,8 @@ main(int argc, char *argv[])
20 		}
21 		fclose(wcachefp);
22 	} else {
23-		writelog(fp, head);
24+		if (head)
25+			writelog(fp, head);
26 	}
27 
28 	fputs("</tbody></table>", fp);
29@@ -1148,7 +1152,8 @@ main(int argc, char *argv[])
30 	/* files for HEAD */
31 	fp = efopen("files.html", "w");
32 	writeheader(fp, "Files");
33-	writefiles(fp, head, "HEAD");
34+	if (head)
35+		writefiles(fp, head, "HEAD");
36 	writefooter(fp);
37 	fclose(fp);
38