tDynamic relpath for blob pages - stagit - static git page generator
 (HTM) git clone git://src.adamsgaard.dk/stagit
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f33bca44bdd4f6758b9045c02ddbab9adc7b97c0
 (DIR) parent 57d70b0a2d945470402b9a9a61ce72289025a36c
 (HTM) Author: Eivind Uggedal <eivind@uggedal.com>
       Date:   Fri, 11 Dec 2015 10:03:19 +0000
       
       Dynamic relpath for blob pages
       
       Diffstat:
         M urmoms.c                            |      10 +++++++++-
       
       1 file changed, 9 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/urmoms.c b/urmoms.c
       t@@ -555,6 +555,8 @@ writeblob(const git_index_entry *entry)
        {
                char fpath[PATH_MAX];
                char ref[PATH_MAX];
       +        char tmp[PATH_MAX] = "";
       +        char *p;
                git_object *obj = NULL;
                FILE *fp;
        
       t@@ -567,7 +569,13 @@ writeblob(const git_index_entry *entry)
                if (mkdirp(dirname(fpath)))
                        return 1;
        
       -        relpath = "../"; /* TODO: dynamic relpath based on number of /'s */
       +        p = fpath;
       +        while (*p) {
       +                if (*p == '/')
       +                        strlcat(tmp, "../", sizeof(tmp));
       +                p++;
       +        }
       +        relpath = tmp;
        
                fp = efopen(fpath, "w+b");
                writeheader(fp);