4

I would like to serve a collection of git repositories over HTTP, to be browsed by humans, and possibly checked-out (read-only). I'm aware of the existence of cgit for this purpose, but the only problem I have with cgit is that it is a dynamic program. This can pose performance issues (and indeed I have seen it use 100% in some situations, when working with huge files if I remember correctly, or when cache was not properly configured), and more importantly can be a security vulnerability. I would prefer to serve only static HTML on my website.

Of course this would mean that some features would become unreasonable, like selective diffing between pairs of revisions, or support for the smart HTTP checkout protocol. However it seems to me like there should exist some tool to prepare a static HTML browsable version of a git repository. (Ideally, such a tool should be able to update the HTML with a hook whenever the repository is pushed to.) Yet while looking around I haven't seen anything that approaches this.

Are you aware of such a tool? If not, what would be the best approximation?

0

3 Answers 3

2

The only one I'm aware of is git2html, a bash script. (Note that the canonical git2html repository is here, but that seems to have been down for a few days.)

2
  • Ah, this seems to be what I wanted. Pity the output seems to be much uglier than that of cgit, though. Thanks!
    – a3nm
    Commented Jan 11, 2017 at 18:13
  • Hi, just stumbled across this and that first link goes to my Web site. Note that some of the stuff there, like my git2html fork, can churn, e.g. I've been playing with git2html recently to reduce its space usage. You're welcome to clone it, but you may want to stick to a particular commit, or fork off you own changes :)
    – Warbo
    Commented Mar 19, 2017 at 17:49
0

I would suggest that you could simply use git clone --bare your_actual_repository_url repo_name.git from the web server followed by zipping the resulting repository and adding to to a directory structure at a location that is pointed to by a static web page(s) on the site.

This would allow you to 'serve' the full git repository from a static web site but would not allow users to clone from git on the command line.

You could use the git log --pretty=fuller --stat -p or the git log --pretty=format commands as documented here to produce a text file to process into a page for each check - in complete with links to parents, children & with changes detailed - possibly with a little python processing to format it into the web pages that you require. More powerfully you could gather the data using the Python Dulwich library.

Updates can be synced via a chron task or could be triggered via a post commit hook and a server side script.

5
  • Thanks for your answer! The solution of using the git daemon is not OK, because it's not static, so it still has performance and security implications. Doing a zip of the repository plus an export is nice but I'd also like to make it possible for users to look at the log of commits, old versions of the trees, and the diffs for each commit.
    – a3nm
    Commented Dec 20, 2016 at 9:22
  • They can look at the entire history once they have done a download - one of the nice things about git. Otherwise you are looking at a huge set of web pages to generate. Commented Dec 20, 2016 at 11:02
  • 1
    My intention is for the history etc. to be browseable directly online (e.g., like GitLab or Github) -- otherwise, yes, of course people can just download the entire repository and do so locally. I don't think the set of pages would be so huge, it should be basically one page per version of each file and one page per commit.
    – a3nm
    Commented Dec 20, 2016 at 17:32
  • Do you intend to allow them to download snapshots at a specific revision or just a zip of the repository? Commented Dec 20, 2016 at 19:20
  • Probably just a git checkout of the repository, maybe a zip of the current version, but then only browsing the previous versions. One complete zip per revision would probably make the disk usage too high. (Serving all versions of all files looks more manageable, because revisions usually only touch a few files.)
    – a3nm
    Commented Dec 21, 2016 at 0:17
0

There is a new project that does this: stagit. It is maintained and works fine for my purposes (https://a3nm.net/git).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.