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 31296 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 15c6149c; Mon, 17 Oct 2022 11:50:29 +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 a83e1623 for ; Mon, 17 Oct 2022 11:50:27 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29H8qTw4019042; Mon, 17 Oct 2022 11:50:26 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=JsACjwI92ACeDimsXDwIRpROlCzK1QumsZSJsqkxT4w=; b=NGjOEujAgrVxQveAZV18jULlUswtWsLmUmOALQsWqIglwSrlKz7ZOTXhxeSHAdaixh4P bmYzwW3Vg5shBK3zphGuAsvumLHu9DN0gEBwfvtMzvvBELorpAUEEn6NPsoZbF2jWAJH m1KWj+srzX94jEBv6R1dsrhNB/3CFUrc/aocWNxyiddwyZnj2PUymOMTbESTXqMmjVqA aGTgr0Qzz/rZ1lXHM/SCj5C48Gsjsa/YFw3oVdegVp03tAHrntPStfqLqpXOCe/5DThb SeKBeowXdLC3vHiI4/PI8E11Fpc+HSKG1CE+6E763CO7AyZQ9u0b5Pf4qqRXpM6fWFIi Fw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7mtyud7y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 11:50:26 +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 29H8t5U4027613; Mon, 17 Oct 2022 11:50:25 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3k8hqx7kcn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 11:50:25 +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 29HBoICt030872; Mon, 17 Oct 2022 11:50:24 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-6; Mon, 17 Oct 2022 11:50:24 +0000 From: Vegard Nossum To: cgit@lists.zx2c4.com Cc: konstantin@linuxfoundation.org, Vegard Nossum Subject: [PATCH 5/6] cgit: add extra alternates Date: Mon, 17 Oct 2022 13:50:09 +0200 Message-Id: <20221017115010.21977-6-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: Kmng_2Pjw_i-y4Hqz2d_ggAZJz5eybaV X-Proofpoint-GUID: Kmng_2Pjw_i-y4Hqz2d_ggAZJz5eybaV 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" This allows you to specify additional alternate repositories to be used with the given repository to resolve trees and commits. The main use for this is to be able to view commits that are not really part of the current repository. In our setup, we have an "all.git" which is really just an empty (bare) git repository with objects/info/alternates pointing to every other relevant repository (mainline, stable, etc.) which we then reference with this new config option. This is not strictly necessary for notes support, but makes it easier to linkify certain SHA1s in the notes if those commits are not usually available from the currently selected repository. Signed-off-by: Vegard Nossum --- cgit.c | 10 ++++++++++ cgit.h | 1 + cgitrc.5.txt | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/cgit.c b/cgit.c index e64694b..e6a94e1 100644 --- a/cgit.c +++ b/cgit.c @@ -111,6 +111,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->notes_repo = xstrdup(value); else if (!strcmp(name, "notes_ref")) repo->notes_ref = xstrdup(value); + else if (!strcmp(name, "alternates")) + string_list_append(&repo->alternates, xstrdup(value)); else if (ctx.cfg.enable_filter_overrides) { if (!strcmp(name, "about-filter")) repo->about_filter = cgit_new_filter(value, ABOUT); @@ -578,6 +580,8 @@ static struct repository notes_repo; static void prepare_repo_env(int *nongit) { + struct string_list_item *alternates_path; + /* The path to the git repository. */ setenv("GIT_DIR", ctx.repo->path, 1); @@ -605,6 +609,12 @@ static void prepare_repo_env(int *nongit) } else { load_display_notes(NULL); } + + for_each_string_list_item(alternates_path, &ctx.repo->alternates) { + struct repository *extra_repo = malloc(sizeof(*extra_repo)); + if (repo_init(extra_repo, alternates_path->string, NULL) == 0) + add_to_alternates_memory(extra_repo->objects->odb->path); + } } static int prepare_repo_cmd(int nongit) diff --git a/cgit.h b/cgit.h index 50a5c73..de5cd3d 100644 --- a/cgit.h +++ b/cgit.h @@ -115,6 +115,7 @@ struct cgit_repo { int ignore; char *notes_repo; char *notes_ref; + struct string_list alternates; }; typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, diff --git a/cgitrc.5.txt b/cgitrc.5.txt index f3f31ee..1be1922 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -456,6 +456,14 @@ repo.about-filter:: Override the default about-filter. Default value: none. See also: "enable-filter-overrides". See also: "FILTER API". +repo.alternates:: + Include additional repository object databases. This allows the + current repository to resolve commits from other repositories + (without includings its tags and branches), which is useful if you + want a single path that can resolve SHA1s from multiple repositories. + This should be an absolute path to the .git directory of the other + repository. Default value: none. + repo.branch-sort:: Flag which, when set to "age", enables date ordering in the branch ref list, and when set to "name" enables ordering by branch name. Default -- 2.35.1.46.g38062e73e0