From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26035 invoked from network); 10 Jan 2022 09:19:53 -0000 Received: from lists.zx2c4.com (165.227.139.114) by inbox.vuxu.org with ESMTPUTF8; 10 Jan 2022 09:19:53 -0000 Received: by lists.zx2c4.com (OpenSMTPD) with ESMTP id 35135486; Mon, 10 Jan 2022 09:19:36 +0000 (UTC) Return-Path: Received: from mx.mylinuxtime.de (mx.mylinuxtime.de [2a01:4f8:13a:16c2::25]) by lists.zx2c4.com (OpenSMTPD) with ESMTPS id cf425864 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Mon, 10 Jan 2022 09:19:35 +0000 (UTC) Received: from leda.eworm.de (p5085a9aa.dip0.t-ipconnect.de [80.133.169.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx.mylinuxtime.de (Postfix) with ESMTPSA id 9ED4E1B1349; Mon, 10 Jan 2022 10:19:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eworm.de; s=mail; t=1641806374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=nJcnslM9olMFWsTZFb/IBGT9t4nhH3PQiSnj9OTr4fE=; b=b2Tjd0s51CobMo6C9y2lWzp1h8QuAsvFLjO2RflF+YV3MzAdTEQiv17S9w/veWxEAjOKFe 3mtYyxPvJEtgPWBCgWJPt2yY9ATV0YV+93cY5jyFVThDf4/UbebPqupPrRwGbBTUt4G8R0 qd0rCgtkACDqfdqsIZ6AZAKd4p2Bx98= Received: by leda.eworm.de (Postfix, from userid 1000) id 244EB1A29F4; Mon, 10 Jan 2022 10:19:04 +0100 (CET) From: Christian Hesse To: cgit@lists.zx2c4.com Cc: Christian Hesse Subject: [PATCH 1/1] about: allow to give head from query Date: Mon, 10 Jan 2022 10:18:55 +0100 Message-Id: <20220110091855.22394-1-list@eworm.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: mx.mylinuxtime.de; auth=pass smtp.auth=smtp-only@eworm.de smtp.mailfrom=eworm@leda.eworm.de X-Rspamd-Server: mx X-Stat-Signature: w3owg67npp6s5zy6n388masyn1cdimew X-Rspamd-Queue-Id: 9ED4E1B1349 X-Spamd-Result: default: False [-1.80 / 15.00]; ARC_NA(0.00)[]; GENERIC_REPUTATION(0.00)[-0.86804641338431]; URIBL_BLOCKED(0.00)[eworm.de:email]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[eworm.de:s=mail]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; FORGED_SENDER(0.30)[list@eworm.de,eworm@leda.eworm.de]; RCVD_COUNT_ZERO(0.00)[0]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:3320, ipnet:80.128.0.0/12, country:DE]; FROM_NEQ_ENVFROM(0.00)[list@eworm.de,eworm@leda.eworm.de]; BAYES_HAM(-3.00)[99.99%] X-BeenThere: cgit@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: List for cgit developers and users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cgit-bounces@lists.zx2c4.com Sender: "CGit" From: Christian Hesse Reading the README from repository used to be limited to default branch or a branch given in configuration. Let's allow a branch from query if not specified explicitly. --- cgit.c | 8 +++++--- cgitrc.5.txt | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cgit.c b/cgit.c index 08d81a1..c06379c 100644 --- a/cgit.c +++ b/cgit.c @@ -507,9 +507,11 @@ static inline void parse_readme(const char *readme, char **filename, char **ref, /* Check if the readme is tracked in the git repo. */ colon = strchr(readme, ':'); if (colon && strlen(colon) > 1) { - /* If it starts with a colon, we want to use - * the default branch */ - if (colon == readme && repo->defbranch) + /* If it starts with a colon, we want to use head given + * from query or the default branch */ + if (colon == readme && ctx.qry.head) + *ref = xstrdup(ctx.qry.head); + else if (colon == readme && repo->defbranch) *ref = xstrdup(repo->defbranch); else *ref = xstrndup(readme, colon - readme); diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 33a6a8c..d9eb3b0 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -579,11 +579,11 @@ repo.readme:: verbatim as the "About" page for this repo. You may also specify a git refspec by head or by hash by prepending the refspec followed by a colon. For example, "master:docs/readme.mkd". If the value begins - with a colon, i.e. ":docs/readme.rst", the default branch of the - repository will be used. Sharing any file will expose that entire - directory tree to the "/about/PATH" endpoints, so be sure that there - are no non-public files located in the same directory as the readme - file. Default value: . + with a colon, i.e. ":docs/readme.rst", the head giving in query or + the default branch of the repository will be used. Sharing any file + will expose that entire directory tree to the "/about/PATH" endpoints, + so be sure that there are no non-public files located in the same + directory as the readme file. Default value: . repo.section:: Override the current section name for this repository. Default value: -- 2.34.1