stagit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 6bc3afb31ec7aa01d9a09d904e52890385db9053
parent 92cee02f1217f19a19d872d857f6e617ed3e0eec
Author: Jakukyo Friel <weakish@gmail.com>
Date:   Sun Dec 18 16:19:27 +0800

Support README with extensions.

Diffstat:
stagit.c | 42++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+), 0 deletions(-)
diff --git a/stagit.c b/stagit.c @@ -61,6 +61,7 @@ static char *strippedname; static char description[255]; static char cloneurl[1024]; static int haslicense, hasreadme, hassubmodules; +static char* readmeextension = ""; /* cache */ static git_oid lastoid; @@ -365,7 +366,16 @@ writeheader(FILE *fp, const char *title) if (hassubmodules) fprintf(fp, " | <a href=\"%sfile/.gitmodules.html\">Submodules</a>", relpath); if (hasreadme) + { fprintf(fp, " | <a href=\"%sfile/README.html\">README</a>", relpath); + } + else + { + if (readmeextension != '\0') + { + fprintf(fp, " | <a href=\"%sfile/README.%s.html\">README</a>", relpath, readmeextension); + } + } if (haslicense) fprintf(fp, " | <a href=\"%sfile/LICENSE.html\">LICENSE</a>", relpath); fputs("</td></tr></table>\n<hr/>\n<div id=\"content\">\n", fp); @@ -1094,6 +1104,38 @@ main(int argc, char *argv[]) git_object_type(obj) == GIT_OBJ_BLOB); git_object_free(obj); + if (!hasreadme) + { + char* readme_extensions[16] = { + "markdown", "mdown", "mkdn", "md", + "textile", + "rdoc", + "org", + "creole", + "mediawiki", "wiki", + "rst", + "asciidoc", "adoc", "asc", + "pod", + "txt" + }; + for (int i = 0; i < 16; i++) + { + char lookup_head[30 + 1]; + snprintf(lookup_head, 30, "HEAD:README.%s", readme_extensions[i]); + if (!git_revparse_single(&obj, repo, lookup_head) && + git_object_type(obj) == GIT_OBJ_BLOB) + { + git_object_free(obj); + readmeextension = readme_extensions[i]; + break; + } + else + { + git_object_free(obj); + } + } + } + hassubmodules = (!git_revparse_single(&obj, repo, "HEAD:.gitmodules") && git_object_type(obj) == GIT_OBJ_BLOB); git_object_free(obj);
This page is a snapshot of ZeroNet. Start your own ZeroNet for complete experience. Learn More