List for cgit developers and users
 help / color / mirror / Atom feed
From: john at keeping.me.uk (John Keeping)
Subject: cgit and symlinks
Date: Mon, 6 Mar 2017 23:35:25 +0000	[thread overview]
Message-ID: <20170306233525.GD2102@john.keeping.me.uk> (raw)
In-Reply-To: <08c0a64a-7df9-9b24-f40e-87eea9d53f77@schinagl.nl>

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 <john at keeping.me.uk>
---
 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



  reply	other threads:[~2017-03-06 23:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-06 10:42 oliver+cgit
2017-03-06 23:35 ` john [this message]
2017-03-08 11:38   ` i
2017-03-08 12:30     ` john
2017-03-08 13:28       ` i
2017-03-09  0:15         ` john
2017-03-09  7:58           ` i
2017-03-12 14:18             ` john
2017-03-13  8:59               ` i
2017-03-21  4:56               ` dlcampbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170306233525.GD2102@john.keeping.me.uk \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).