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=DKIMWL_WL_MED,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 31278 invoked from network); 17 Oct 2022 11:50:42 -0000 Received: from lists.zx2c4.com (165.227.139.114) by inbox.vuxu.org with ESMTPUTF8; 17 Oct 2022 11:50:42 -0000 Received: by lists.zx2c4.com (OpenSMTPD) with ESMTP id 57760fd5; Mon, 17 Oct 2022 11:50:24 +0000 (UTC) Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lists.zx2c4.com (OpenSMTPD) with ESMTP id 02de6e4d for ; Mon, 17 Oct 2022 11:50:23 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29HBHJmZ016592; Mon, 17 Oct 2022 11:50:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=cWTSO5mhKZx/ZZT+tOEhBAa61hXRJ+omcz83moUoqbw=; b=Wljsir+OVNpJ4hMa9NfzPLoBWqKWp8WEM8zt06iy4J9dpzCpUMrcqhmn+BlG9q5ZYoUi 535aRuOvrhHwta11Kt5OWTaw9Jr3BGcviTVN8BmqXura50HDlTzU403MJFSLcS6vQcG7 8CePfst0KVuSE9YXM68so9GXHVCFN86d35mSeypxxNSlu7lwJEzLkyVZzBVivASfBH52 KqV90ez2H15Y49B3vDLHFkCxgekc8MsJye8M6ApIxR5YhmhpgkwzXDlppz23Nm1Hqxhd I6vCG4dDMOxdYqKqgUE69Ze7zNJlAonSN5QmdXMEinmVk7awqTRxIfUmE+0Eyp7xp4kE PA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k8jt2hgc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 11:50:20 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29H8t5U2027613; Mon, 17 Oct 2022 11:50:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3k8hqx7k8b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 11:50:18 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29HBoICl030872; Mon, 17 Oct 2022 11:50:18 GMT Received: from t460.home (dhcp-10-175-3-136.vpn.oracle.com [10.175.3.136]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3k8hqx7k5g-2; Mon, 17 Oct 2022 11:50:18 +0000 From: Vegard Nossum To: cgit@lists.zx2c4.com Cc: konstantin@linuxfoundation.org, Vegard Nossum Subject: [PATCH 1/6] Support notes from external repositories Date: Mon, 17 Oct 2022 13:50:05 +0200 Message-Id: <20221017115010.21977-2-vegard.nossum@oracle.com> X-Mailer: git-send-email 2.35.1.46.g38062e73e0 In-Reply-To: <20221017115010.21977-1-vegard.nossum@oracle.com> References: <20221017115010.21977-1-vegard.nossum@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-17_09,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170068 X-Proofpoint-ORIG-GUID: gDM9fmKg-fRAnEfeJsU3oCuOjj9x0QD5 X-Proofpoint-GUID: gDM9fmKg-fRAnEfeJsU3oCuOjj9x0QD5 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" Before this commit, all git notes had to be part of the repository that the notes are displayed for. This adds an option to display notes from an external repository. Signed-off-by: Vegard Nossum --- cgit.c | 27 ++++++++++++++++++++++++++- cgit.h | 2 ++ cgitrc.5.txt | 8 ++++++++ shared.c | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/cgit.c b/cgit.c index 08d81a1..dc6b491 100644 --- a/cgit.c +++ b/cgit.c @@ -107,6 +107,10 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->hide = atoi(value); else if (!strcmp(name, "ignore")) repo->ignore = atoi(value); + else if (!strcmp(name, "notes_repo")) + repo->notes_repo = xstrdup(value); + else if (!strcmp(name, "notes_ref")) + repo->notes_ref = xstrdup(value); else if (ctx.cfg.enable_filter_overrides) { if (!strcmp(name, "about-filter")) repo->about_filter = cgit_new_filter(value, ABOUT); @@ -570,6 +574,8 @@ static void print_no_repo_clone_urls(const char *url) html("\n"); } +static struct repository notes_repo; + static void prepare_repo_env(int *nongit) { /* The path to the git repository. */ @@ -579,7 +585,26 @@ static void prepare_repo_env(int *nongit) * load local configuration from the git repository, so we do them both while * the HOME variables are unset. */ setup_git_directory_gently(nongit); - load_display_notes(NULL); + + if (ctx.repo->notes_repo) { + if (repo_init(¬es_repo, ctx.repo->notes_repo, NULL) == 0) + add_to_alternates_memory(notes_repo.objects->odb->path); + } + + if (ctx.repo->notes_ref) { + struct display_notes_opt notes_opt; + + init_display_notes(¬es_opt); + notes_opt.use_default_notes = 0; + + if (ctx.repo->notes_repo) + notes_opt.repo = ¬es_repo; + + string_list_append(¬es_opt.extra_notes_refs, ctx.repo->notes_ref); + load_display_notes(¬es_opt); + } else { + load_display_notes(NULL); + } } static int prepare_repo_cmd(int nongit) diff --git a/cgit.h b/cgit.h index 69b5c13..50a5c73 100644 --- a/cgit.h +++ b/cgit.h @@ -113,6 +113,8 @@ struct cgit_repo { struct string_list submodules; int hide; int ignore; + char *notes_repo; + char *notes_ref; }; typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 33a6a8c..f3f31ee 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -562,6 +562,14 @@ repo.max-stats:: repo.name:: The value to show as repository name. Default value: . +repo.notes_ref:: + A ref or glob similar to the "notes.displayRef" git config option. + Default value: none. + +repo.notes_repo:: + If you want to use notes from an external repository, set this + option to the path of the repository. Default value: none. + repo.owner:: A value used to identify the owner of the repository. Default value: none. diff --git a/shared.c b/shared.c index 8115469..d3d0fa0 100644 --- a/shared.c +++ b/shared.c @@ -79,6 +79,8 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->clone_url = ctx.cfg.clone_url; ret->submodules.strdup_strings = 1; ret->hide = ret->ignore = 0; + ret->notes_repo = NULL; + ret->notes_ref = NULL; return ret; } -- 2.35.1.46.g38062e73e0