Dynamic relpath for blob pages
authorEivind Uggedal <eivind@uggedal.com>
Fri, 11 Dec 2015 10:03:19 +0000 (10:03 +0000)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 11 Dec 2015 11:36:17 +0000 (12:36 +0100)
urmoms.c

index de496366f71d63999a288a94bb144d4a51df6aa5..b1c2aff05c7428c0397069b580cacc991ba61861 100644 (file)
--- a/urmoms.c
+++ b/urmoms.c
@@ -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;
 
@@ -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);