stagit-responsive

My mobile friendly fork of stagit
Log | Files | Refs | README | LICENSE

commit e90c870bd4fa2c3f65d710e2be5735daa8585ef1
parent bc63b5d390a989f3d15ee42764cc4093a80f5b52
Author: Yohanes Bandung Bondowoso <hi@ybbond.dev>
Date:   Sun, 21 Jun 2020 12:22:12 +0700

modify to check whether cc-license exists or not

Diffstat:
Mstagit.c | 13+++++++++++++

1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/stagit.c b/stagit.c
@@ -59,7 +59,9 @@ static char description[255];
 static char cloneurl[1024];
 static char *submodules;
 static char *licensefiles[] = { "HEAD:LICENSE", "HEAD:LICENSE.md", "HEAD:COPYING" };
+static char *cclicensefiles[] = { "HEAD:CC-LICENSE", "HEAD:CC-LICENSE.md" };
 static char *license;
+static char *cclicense;
 static char *readmefiles[] = { "HEAD:README", "HEAD:README.md" };
 static char *readme;
 static long long nlogcommits = -1; /* < 0 indicates not used */
@@ -385,6 +387,9 @@ writeheader(FILE *fp, const char *title)
   if (license)
     fprintf(fp, " | <a href=\"%sfile/%s.html\">LICENSE</a>",
             relpath, license);
+  if (cclicense)
+    fprintf(fp, " | <a href=\"%sfile/%s.html\">CC-LICENSE</a>",
+            relpath, cclicense);
   fputs("</td></tr></table>\n<hr/>\n<div id=\"content\">\n", fp);
 }
 
@@ -1173,6 +1178,14 @@ main(int argc, char *argv[])
     git_object_free(obj);
   }
 
+  /* check CC-LICENSE */
+  for (i = 0; i < sizeof(cclicensefiles) / sizeof(*cclicensefiles) && !cclicense; i++) {
+    if (!git_revparse_single(&obj, repo, cclicensefiles[i]) &&
+        git_object_type(obj) == GIT_OBJ_BLOB)
+      cclicense = cclicensefiles[i] + strlen("HEAD:");
+    git_object_free(obj);
+  }
+
   /* check README */
   for (i = 0; i < sizeof(readmefiles) / sizeof(*readmefiles) && !readme; i++) {
     if (!git_revparse_single(&obj, repo, readmefiles[i]) &&