no log per branch
rename log.html to log/HEAD.html, small code cleanup
1 files changed, 14 insertions(+), 40 deletions(-) | |||
---|---|---|---|
M | stagit.c | +14 | -40 |
1@@ -22,8 +22,8 @@ struct commitinfo {
2 char parentoid[GIT_OID_HEXSZ + 1];
3
4 const git_signature *author;
5- const char *summary;
6- const char *msg;
7+ const char *summary;
8+ const char *msg;
9
10 git_diff_stats *stats;
11 git_diff *diff;
12@@ -263,7 +263,7 @@ writeheader(FILE *fp)
13 fputs("</a></td></tr>", fp);
14 }
15 fputs("<tr><td></td><td>\n", fp);
16- fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
17+ fprintf(fp, "<a href=\"%slog/HEAD.html\">Log</a> | ", relpath);
18 fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath);
19 fprintf(fp, "<a href=\"%srefs.html\">Refs/branches</a>", relpath);
20 if (hasreadme)
21@@ -698,15 +698,15 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path)
22
23 count = git_tree_entrycount(tree);
24 for (i = 0; i < count; i++) {
25- if (!(entry = git_tree_entry_byindex(tree, i)))
26- return -1;
27- if (git_tree_entry_to_object(&obj, repo, entry))
28+ if (!(entry = git_tree_entry_byindex(tree, i)) ||
29+ git_tree_entry_to_object(&obj, repo, entry))
30 return -1;
31 filename = git_tree_entry_name(entry);
32 switch (git_object_type(obj)) {
33 case GIT_OBJ_BLOB:
34 break;
35 case GIT_OBJ_TREE:
36+ /* NOTE: recurses */
37 ret = writefilestree(fp, (git_tree *)obj, branch,
38 filename);
39 git_object_free(obj);
40@@ -722,7 +722,6 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path)
41 path, filename);
42 filename = filepath;
43 }
44-
45 filesize = git_blob_rawsize((git_blob *)obj);
46
47 fputs("<tr><td>", fp);
48@@ -757,12 +756,9 @@ writefiles(FILE *fp, const char *branch)
49 if (git_revparse_single(&obj, repo, branch))
50 goto err;
51 id = git_object_id(obj);
52- if (git_commit_lookup(&commit, repo, id))
53- goto err;
54- if (git_commit_tree(&tree, commit)) {
55- git_commit_free(commit);
56+ if (git_commit_lookup(&commit, repo, id) ||
57+ git_commit_tree(&tree, commit))
58 goto err;
59- }
60 ret = writefilestree(fp, tree, branch, "");
61
62 err:
63@@ -820,11 +816,9 @@ writebranches(FILE *fp)
64
65 relpath = "";
66
67- fputs("<tr><td><a href=\"log-", fp);
68- xmlencode(fp, branchname, strlen(branchname));
69- fputs(".html\">", fp);
70+ fputs("<tr><td>", fp);
71 xmlencode(fp, branchname, strlen(branchname));
72- fputs("</a></td><td>", fp);
73+ fputs("</td><td>", fp);
74 if (ci->author)
75 printtimeshort(fp, &(ci->author->when));
76 fputs("</td><td>", fp);
77@@ -963,10 +957,6 @@ int
78 main(int argc, char *argv[])
79 {
80 git_object *obj = NULL;
81- git_branch_iterator *it = NULL;
82- git_branch_t branch;
83- git_reference *ref = NULL;
84- const char *branchname = NULL;
85 const git_error *e = NULL;
86 FILE *fp, *fpread;
87 char path[PATH_MAX], *p;
88@@ -1028,31 +1018,15 @@ main(int argc, char *argv[])
89 git_object_free(obj);
90
91 /* log for HEAD */
92- fp = efopen("log.html", "w");
93+ mkdir("log", 0755);
94+ fp = efopen("log/HEAD.html", "w");
95+ relpath = "../";
96 writeheader(fp);
97+ relpath = "";
98 writelog(fp, "HEAD");
99 writefooter(fp);
100 fclose(fp);
101
102- /* log for local branches */
103- if (git_branch_iterator_new(&it, repo, GIT_BRANCH_LOCAL))
104- err(1, "git_branch_iterator_new");
105-
106- while (!git_branch_next(&ref, &branch, it)) {
107- if (git_branch_name(&branchname, ref))
108- continue;
109-
110- snprintf(path, sizeof(path), "log-%s.html", branchname);
111-
112- fp = efopen(path, "w");
113- writeheader(fp);
114- writelog(fp, branchname);
115- writefooter(fp);
116- fclose(fp);
117- }
118- git_reference_free(ref);
119- git_branch_iterator_free(it);
120-
121 /* files for HEAD */
122 fp = efopen("files.html", "w");
123 writeheader(fp);