]> git.armaanb.net Git - stagit.git/commitdiff
Generate raw file if htmlized
authorArmaan Bhojwani <me@armaanb.net>
Tue, 6 Apr 2021 18:38:37 +0000 (14:38 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Tue, 6 Apr 2021 18:38:37 +0000 (14:38 -0400)
src/stagit.c

index c39e9ba54b0b6881a275fd5e9cd44308d4e76038..b71eeda0db64c440eceda86eb7940ded010f574f 100644 (file)
@@ -848,7 +848,6 @@ writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t fi
        fputs("<p> ", fp);
        xmlencode(fp, filename, strlen(filename));
        fprintf(fp, " (%s)", convertbytes((int)filesize));
        fputs("<p> ", fp);
        xmlencode(fp, filename, strlen(filename));
        fprintf(fp, " (%s)", convertbytes((int)filesize));
-
        fputs("</p><hr/>", fp);
 
        if (git_blob_is_binary((git_blob *)obj)) {
        fputs("</p><hr/>", fp);
 
        if (git_blob_is_binary((git_blob *)obj)) {
@@ -857,6 +856,15 @@ writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t fi
                writeblobhtml(filename, fp, (git_blob *)obj);
                if (ferror(fp))
                        err(1, "fwrite");
                writeblobhtml(filename, fp, (git_blob *)obj);
                if (ferror(fp))
                        err(1, "fwrite");
+               else if (htmlized) {
+                       /* NOTE: recurses */
+                       char newfpath[PATH_MAX];
+                       strcat(newfpath, fpath);
+                       char newfilename[PATH_MAX];
+                       strcat(newfilename, filename);
+                       writeblob(obj, strcat(newfpath, "-raw"), strcat(newfilename, "-raw"), filesize);
+                       // TODO: Add view-raw button
+               }
        }
 
        writefooter(fp);
        }
 
        writefooter(fp);