git » git-arr » commit d7604da

write_tree: suppress double-slash in blob HTML filename

author Eric Sunshine
2014-12-31 09:50:06 UTC
committer Alberto Bertogli
2015-01-11 21:18:14 UTC
parent aaf2968538121f9443f1aea2156814fede5a5648

write_tree: suppress double-slash in blob HTML filename

When emitting a blob in the root tree of a commit, write_tree() composes
the blob's HTML filename with an extra slash before the "f=", like this:

    output/r/repo/b/master/t//f=README.txt.html

Although the double-slash is not harmful on Unix, it is unsightly, and
may be problematic for other platforms or filesystems which interpret
double-slash specially or disallow it. Therefore, suppress the extra
slash for blobs in the root tree.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

git-arr +3 -2

diff --git a/git-arr b/git-arr
index bd38324..6982b00 100755
--- a/git-arr
+++ b/git-arr
@@ -347,8 +347,9 @@ def generate(output, skip_index = False):
                 dirname = git.smstr(os.path.dirname(oname.raw))
                 fname = git.smstr(os.path.basename(oname.raw))
                 write_to(
-                    'r/%s/b/%s/t/%s/f=%s.html' %
-                        (str(r.name), str(bn), dirname.raw, fname.raw),
+                    'r/%s/b/%s/t/%s%sf=%s.html' %
+                        (str(r.name), str(bn),
+                         dirname.raw, '/' if dirname.raw else '', fname.raw),
                     blob, (r, bn, fname.url, dirname.url), mtime)
             else:
                 write_to('r/%s/b/%s/t/%s/index.html' %