From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Mon, 6 Mar 2017 23:35:25 +0000 Subject: cgit and symlinks In-Reply-To: <08c0a64a-7df9-9b24-f40e-87eea9d53f77@schinagl.nl> References: <08c0a64a-7df9-9b24-f40e-87eea9d53f77@schinagl.nl> Message-ID: <20170306233525.GD2102@john.keeping.me.uk> On Mon, Mar 06, 2017 at 11:42:14AM +0100, Olliver Schinagl wrote: > Having said that, I was playing around with a simple script and noticed > wget gave 404's on symlinks. > > As an example: > > http://git.schinagl.nl/debootstrap.git/plain/scripts/stretch > > at the very least I would expect the content of the link as for example > github shows: > https://raw.githubusercontent.com/oliv3r/debootstrap/master/scripts/stretch > > having said that, even github handles it wrong imo, as I would expect > the webserver to 'get' a symlink and thus just follow the symlink and > thus get the content of the file (in raw/plain mode). > > I have tried googeling and checked cgitrc for my 0.12 but have not found > anything yet. > > Did I simply miss something configuration wise? Nope, it looks like we simply ignore symlinks in the plain UI. Below is a patch to fix this by printing the content in the same we as in the tree UI. We can't reliably follow the link because there is no guarantee that the target lies within the repository and I don't know what we would output for the case where we can't display the target. -- >8 -- Subject: [PATCH] ui-plain: print symlink content We currently ignore symlinks in ui-plain, leading to a 404. In ui-tree we print the content of the blob (that is, the path to the target of the link), so it makes sense to do the same here. Signed-off-by: John Keeping --- ui-plain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-plain.c b/ui-plain.c index 8d541e3..01e8b36 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -135,7 +135,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base, struct walk_tree_context *walk_tree_ctx = cbdata; if (base->len == walk_tree_ctx->match_baselen) { - if (S_ISREG(mode)) { + if (S_ISREG(mode) || S_ISLNK(mode)) { if (print_object(sha1, pathname)) walk_tree_ctx->match = 1; } else if (S_ISDIR(mode)) { -- 2.12.0.377.gf910686b23.dirty