From patchwork Fri Feb 14 22:57:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usman Akinyemi X-Patchwork-Id: 13975709 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D69E81FC0F7 for ; Fri, 14 Feb 2025 23:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574142; cv=none; b=Kh2wMQ6RPSFbL+4pnXJ7qg5UFgOFju0MhcfsyyCXnQzNb/ZH8Cq+wAxsZC6afTzmQKljbtvffz34PUeFax9+fZowNarwy7DdTRicodW4sABy8btdoYWfeWeVCROIWm5QNLtkma+tsMX+6gLVujNZX9YKncHmYLyA3BiKOPwd3u8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574142; c=relaxed/simple; bh=wNs/pXh7+EomLLeCkHUXKI64X1x5QFlLZuJRc17gUHk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EoQV3K3Ak+92mLYddYFdbQt3q9tluQBgP8IFGnk7qSH9VoDLSHzxYp8N0wEZel3l0emK94lmcVGx7OYcniWrLcxFuOSnG8DiPR8GlySv4/vL+3UGbo28v+hL4r0OPUZWkAinlrQs80ym+FLHR8uvK4Aaz2rajNJXfbqOsCqvP9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ji29uSXi; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ji29uSXi" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2f9b91dff71so3820195a91.2 for ; Fri, 14 Feb 2025 15:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739574140; x=1740178940; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oCyQeLEBW6sUEDFsr3ceeRqDPL5FZQ4g5iEkea1rkCM=; b=ji29uSXipsXh/dlQ9oS++9P+3lvLL+sl9O9lntYaQYyeXOjmTKSeEP4A0185Tt3pb2 gOvuMxZPwPbjOt5T7+vSr82LvhB2dFY3IrVP3LOruUoUS/gzK7klTfJdHERtxNImMUvJ AWSMvTe4/UlqWWvKBuvvLMswDLxp5BHnQnEErm3erBOHHBJFyJC4yHCgwU2kfBy5ypF1 9PdeSnoeTZ67ZmuMSUj5/PP3uaRaIcIzSFgEzoGWD7iHg+FbZMwkHSKd8NQg4AnyMxwg xmYR8O3zOEj8zrh7jtkS5+ZVQsB8o+Q+0L35heuzQmOcBRxI043QmO2R09QtaeaJKlmC M9GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739574140; x=1740178940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oCyQeLEBW6sUEDFsr3ceeRqDPL5FZQ4g5iEkea1rkCM=; b=UMKYRfmJWFkGgF3xn7OHgRgMzexXKNGF1eu4j30tBCgPfs30dk2Vk2sy0iKGOIjG5p +9tNFVhwv33jlK5aYGnkJFezR7aJxHa31pb+LFVgnwXWLALclEw0SgZF2T14OIiyBKIH FJPZ2U0NL24VmhThlBCTZaAfPx14ngXgRk/4fiuewRQ+ywCmcZZSLssKck4oBK+Ozfz2 2u2R5mHQCAfShhreErtHwOpiCu8bBNVxfK+YpWx4Bqle8KpF6Ek/uPLlGzyRVBw6qnsv 4jynSJbiMTOJZtJMnYOEVl6MPwTJqiwMTcHz0UBXhfgPsnQS/SAV+fE1c68RFpR8rjxK LaMA== X-Gm-Message-State: AOJu0YzoAf+FZWEtSx/aNMywV/ifQl2wr1LkjBGjlh5dtPahfMXcOZTt aMYguujbzw/TEcYtHM4uQMkNsODEU3IPmEVr0vJTZkuUzXXs2r1SYwLUPeaU X-Gm-Gg: ASbGncskkVPOrTyEcUnIhBrSX0WRLQWfL+5oOwl044etlTVAtnWhRRKOKdFf/hurHz9 lgJ5kcdkVtSLHkyfOu1CXtmynTbVru+t6VwbO/J36QN+pAJM/f0hc4is88c2RfnJRMMJbZWucuC c5PSglcGnY5xbLknqJyzDw7yUdL5SCB1HmoXS34/DvRH2YOrdGKdo15ZXLz/ZOEgHqBw5csEjV8 sUtAD1jGZZOYkG5Q6LIpi4AmlUcgBQjMD1VsaVLE5UID0UyU0J5UG5aBgaBNGGv00tYlq5SdZ2l 6bQncJacn5BSV0IaRzO9m6F0qV5dNuKcoxCILHeG X-Google-Smtp-Source: AGHT+IE2Giwv2fkbYhvZ8S13aEc2//6ABufpRQjEOxE/HaJzrHSMumuN4trVHyasMh/MzRtdPVoXeg== X-Received: by 2002:a17:90b:2f85:b0:2ee:e317:69ab with SMTP id 98e67ed59e1d1-2fc407915f8mr1692716a91.0.1739574139708; Fri, 14 Feb 2025 15:02:19 -0800 (PST) Received: from archlinux.plaksha.edu.in ([182.75.25.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22105174c73sm1495245ad.216.2025.02.14.15.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 15:02:19 -0800 (PST) From: Usman Akinyemi To: git@vger.kernel.org Cc: chriscool@tuxfamily.org, christian.couder@gmail.com, johncai86@gmail.com, ps@pks.im, shejialuo@gmail.com Subject: [PATCH 1/7] builtin/verify-tag: stop using `the_repository` Date: Sat, 15 Feb 2025 04:27:17 +0530 Message-ID: <20250214230210.1460111-2-usmanakinyemi202@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> References: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/verify-tag.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_verify_tag()` function with `repo` set to NULL and then early in the function, `parse_options()` call will give the options help and exit, without having to consult much of the configuration file. So it is safe to omit reading the config when `repo` argument the caller gave us is NULL. Mentored-by: Christian Couder Signed-off-by: Usman Akinyemi --- builtin/verify-tag.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c index f6b97048a5..990e967af3 100644 --- a/builtin/verify-tag.c +++ b/builtin/verify-tag.c @@ -5,7 +5,6 @@ * * Based on git-verify-tag.sh */ -#define USE_THE_REPOSITORY_VARIABLE #include "builtin.h" #include "config.h" #include "gettext.h" @@ -23,7 +22,7 @@ static const char * const verify_tag_usage[] = { int cmd_verify_tag(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { int i = 1, verbose = 0, had_error = 0; unsigned flags = 0; @@ -35,7 +34,8 @@ int cmd_verify_tag(int argc, OPT_END() }; - git_config(git_default_config, NULL); + if (repo) + repo_config(repo, git_default_config, NULL); argc = parse_options(argc, argv, prefix, verify_tag_options, verify_tag_usage, PARSE_OPT_KEEP_ARGV0); @@ -56,7 +56,7 @@ int cmd_verify_tag(int argc, struct object_id oid; const char *name = argv[i++]; - if (repo_get_oid(the_repository, name, &oid)) { + if (repo_get_oid(repo, name, &oid)) { had_error = !!error("tag '%s' not found.", name); continue; } From patchwork Fri Feb 14 22:57:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usman Akinyemi X-Patchwork-Id: 13975710 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DE721C84AC for ; Fri, 14 Feb 2025 23:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574145; cv=none; b=oaPjk9WJCdFnCJUau3fdZ4g1AbWggNM2UNDiYIzrCPUtGbX0qthlIvEnLyHkdYE8r7ntM8fi61x7AAfJZEJzou5TQLPa/cJTJW5p40a+X/f746iACqEDFDMSXja6cRhuUs1YW/NpgCujDnVhBLlIhS9DlcFUkFUZ5uyQ9++ntEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574145; c=relaxed/simple; bh=4aWowCXeM8KyGxQcAgI62Q78R9y6POq9UX85r/lKQb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IBIrlV/WKsHBGF3mK4Oncxy1eJY7M9d/0HWDO+HPNwetTOnBkx+0318iPq7LQ1j17tjBnS9CifbgK3FC4jUGbZCgVPLZDaCBg8yRWm63QEIFedCoIxAYGRaPm/Ij5aZq6D0WkhPlYQp6y4h7S2A3U9HHPzVo63Zz5AmF22mIaA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ROtrINnf; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ROtrINnf" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-220d398bea9so37153365ad.3 for ; Fri, 14 Feb 2025 15:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739574143; x=1740178943; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OjEfJ9D6FJVw+0rAxPOQyAKkoS5Fm0gi3EJkP22V0t4=; b=ROtrINnfEteaICR1WxpwuuC+T8b3e1Oolql+RqBlBGuzlPAWtXpikpMVogwyWT3qeE WSqQNJPkzDyAywuhAUgPgftZqHC2OaPAdL2/xmpOWFzGZza1YqVYe0LJOjhEy4VG6g31 xm8xB6SCV1vKspPG82WmLK+AcCzqkA7Mmd6cJWLuQfrmvTX/SPSrKnLTiQ1k+lkiaxFs vz2dHyrVadukt0+DVjtJ96nsqCZoQy09XUsfECMQ7fs02c3NdPPqXFy+McZWom+hKD+f +4dqeMjGXNcdYnSom+8t4U9TpDkZF99uSm9YYFWbZWP9OwZ6zcoCZHR5zBk/pNCRI1Jt DObg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739574143; x=1740178943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OjEfJ9D6FJVw+0rAxPOQyAKkoS5Fm0gi3EJkP22V0t4=; b=jpq5JCb3J7IygGoJvT2fvrcUjTq8SOE5oPFa+4C51YNzHEk+7Vg16WJCnv2HpphHLY UUCJLcEQP93o0tlyezuZRLzwfCmHCGQvFZsUYiT9iRGcOC/ewyVGhZYfTh14l7N8aALp oMFy+5ytgw0+CTTN0woa9XAzWjOnno7YxYHlgubZRALcabbFzb8EacMkK2v8lpeHWUkT Vc+E40ENohq8lkOXjen9rVhFEIcze182rbUpR5VFCHE+P5C1FUCq6ZqN4nSWutmoAey0 RusTTRZzypG9B/m9bwfjr6bCzSaiSCWJlcJUosiKsRsD3U2Vu17FI09PFXcJ9dR3eUFW Ymfg== X-Gm-Message-State: AOJu0YyB3UXR6IMIlq9K2DKvm0P6t0XZvzDM9kggaFlxrZkKeVRecqxE 3m5OXru3dKO8Unh/og4z7tuWfILj5qXzsByesWaT1f7kujysDGL8mxanRnm1 X-Gm-Gg: ASbGncueqeEMks1C2AmzvxPtZHWt5cq44US1CWrB8CuaoLDeRUFdWzv34cXw+Iz2FwD PImzM6Y8zdgu1t5G0kw9HRKcwMpF2kg5qDnzTvTu7xbSlix0p+IcztPQ5i6v8xGYv26DN7XBIGN nWK6LKQPPevp+3ISIYOkrq+J4UzpNIQZPjWoRgn17mC7E+QD3EJyrRorNTwYVgXyWQDHiyOIb4/ sE0TlvzsJ4c0pFu813XynlXvf20orPvDg/E1k8KVnNUlJn2mZHTQ1Me8Y4NllUfhORTutAMhQ39 HU+JPm4ZM/uiiNUTj4Akgldbj0Lzazw4pbUB3skA X-Google-Smtp-Source: AGHT+IEVdYiWlzMegLjX1SW6MAYHuKS4VsCdlhtERx053TZMPRlmhcuyyeg+BQDgfm+Ow4m/bSY6Iw== X-Received: by 2002:a17:902:e841:b0:21f:4144:a06f with SMTP id d9443c01a7336-22103f14b7cmr16643875ad.13.1739574143482; Fri, 14 Feb 2025 15:02:23 -0800 (PST) Received: from archlinux.plaksha.edu.in ([182.75.25.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22105174c73sm1495245ad.216.2025.02.14.15.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 15:02:23 -0800 (PST) From: Usman Akinyemi To: git@vger.kernel.org Cc: chriscool@tuxfamily.org, christian.couder@gmail.com, johncai86@gmail.com, ps@pks.im, shejialuo@gmail.com Subject: [PATCH 2/7] builtin/verify-commit.c: stop using `the_repository` Date: Sat, 15 Feb 2025 04:27:18 +0530 Message-ID: <20250214230210.1460111-3-usmanakinyemi202@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> References: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/verify-tag.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_verify_commit()` function with `repo` set to NULL and then early in the function, `parse_options()` call will give the options help and exit, without having to consult much of the configuration file. So it is safe to omit reading the config when `repo` argument the caller gave us is NULL. Let's pass `repository` argument to `verify_commit()` function to remove it's dependency on the global `the_repository` variable. Mentored-by: Christian Couder Signed-off-by: Usman Akinyemi --- builtin/verify-commit.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c index 779b7988ca..50f56d296c 100644 --- a/builtin/verify-commit.c +++ b/builtin/verify-commit.c @@ -5,7 +5,6 @@ * * Based on git-verify-tag */ -#define USE_THE_REPOSITORY_VARIABLE #include "builtin.h" #include "config.h" #include "gettext.h" @@ -33,15 +32,15 @@ static int run_gpg_verify(struct commit *commit, unsigned flags) return ret; } -static int verify_commit(const char *name, unsigned flags) +static int verify_commit(struct repository *repo, const char *name, unsigned flags) { struct object_id oid; struct object *obj; - if (repo_get_oid(the_repository, name, &oid)) + if (repo_get_oid(repo, name, &oid)) return error("commit '%s' not found.", name); - obj = parse_object(the_repository, &oid); + obj = parse_object(repo, &oid); if (!obj) return error("%s: unable to read file.", name); if (obj->type != OBJ_COMMIT) @@ -54,7 +53,7 @@ static int verify_commit(const char *name, unsigned flags) int cmd_verify_commit(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { int i = 1, verbose = 0, had_error = 0; unsigned flags = 0; @@ -64,7 +63,8 @@ int cmd_verify_commit(int argc, OPT_END() }; - git_config(git_default_config, NULL); + if (repo) + repo_config(repo, git_default_config, NULL); argc = parse_options(argc, argv, prefix, verify_commit_options, verify_commit_usage, PARSE_OPT_KEEP_ARGV0); @@ -78,7 +78,7 @@ int cmd_verify_commit(int argc, * was received in the process of writing the gpg input: */ signal(SIGPIPE, SIG_IGN); while (i < argc) - if (verify_commit(argv[i++], flags)) + if (verify_commit(repo, argv[i++], flags)) had_error = 1; return had_error; } From patchwork Fri Feb 14 22:57:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usman Akinyemi X-Patchwork-Id: 13975711 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A5951C84AC for ; Fri, 14 Feb 2025 23:02:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574149; cv=none; b=ZUd8kaBSzYMahHyH6Vylov3oqikDknMLkA8Dj88a66YNq62LlyNaF/XWVP9K+mcRy2IYxQ0RvXTd9RzleAHXmqhdwt/ViDW097dfa87FH86Ap3X2Sp52rO9CUWhpEYN5JRsVnRZuiZ7ivFnDNZEjdPLlko45WzwRIhCKvi5GbT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574149; c=relaxed/simple; bh=CLWf79hCHXa18PmnRPt2IGiNK/+7FwWGqABZYxUludM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WqkKSzRxDmgFzu3ndlO2ZCQuUZ8ZAKOWwsSD4FffG/Gb6NdaSZn0PbyUPoaLtPwrrdmQEgC9uduhdO6f7W3NuDnZnhPd75ctDDLpLWqxa6XbSfs9J+363r/bGbdHuB0FFOEOao66QoESl+5Fa/39BtYLeBxQWWo/HnlfkP/VeNM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kQlRMX/C; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kQlRMX/C" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-220dc3831e3so35252675ad.0 for ; Fri, 14 Feb 2025 15:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739574147; x=1740178947; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tGLpxZcYuMveJD8YK4VAdO4MrBe3t2WT0pyBflisuAY=; b=kQlRMX/CuadTVQ4jBkkKn/vb7pQJDnkSLeIWTwPSpN/JgmdICyinyxFyhNdQPOaWFB hoXLQR7oeP4+6Y7BQ9Zxhfio7C6pZ/eFe+xm+YQZTn36UDp1usqCdcurDydNTzyuGS64 W+35bV7VNtyUzshYSujvofJIazyjX+gAqhK+wd0sqcsfTy12m92FvRRFPmOKxhR0cYc9 Co9dq/YRv4i5IcuiZJmLIatGoyNTHenPB4w+GcIw+b4VAdtCZ9IHhpO6CclHXPJn7MP0 o+21EH5YlmD1aqrt7tkTmE0BOQmpMHqB2XlhTdNIoQPx2GHNKqkW2g3iNXcjV8zw1kIz rgVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739574147; x=1740178947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tGLpxZcYuMveJD8YK4VAdO4MrBe3t2WT0pyBflisuAY=; b=L/8s0ViSGIOAwrl42UNZXd3Hl/oDZekWCoSE5ekMh70JAh8mp0qFHhyVp+ck8PNox4 hHpQYenzzyWGiTU3IsUsh7S8eZA2dBJwhPvXlLctrweEOdmRrRiNKGxkrZp6hbSyXsr6 TdEj9VTaYuzmIca8qUXmHxu2vdoIPlxn7RAUzqOA6rvu5k1TnVFqgAL46q22l4booFbD yyI4wLPxd4Kj6UYhIPcdI12gfomWvz5bX26xFwU+qfQJXtF15B3II3Ahktd+J0aOZ/Q0 uhiP6CG+s5Eg178LAbuspAuQcR15vSq/xa9mxzNLs7LxITCo/YrsoAyc74NAqrzJKJJO 2EAg== X-Gm-Message-State: AOJu0YzNh4XuHc4ddSDV1YTSpAN6DcNFfMn6FqkVTOKDXoWfLpXFll4A koFgQM6qagO6rJjYV2+QVuFMlXdjNzrQD2fiIro30okADn5eyj5R34Q8+FOg X-Gm-Gg: ASbGncsKm9o4qqrnSRlFyRoPClUlMQLReeXW8LmP3GFEYgkTHBI4l6nyQGK0bAcuFE6 WSP0fUNhCb4+LJr3yBoOIXxHQycJLTSazvguJxqk05wZir/mflXagMBli5B2qIyFyBUizuh+ytA x6R/hvD8CuwjdV9MrlXd5SBe5laaojMe6kaKsVnAVpG156e5ImDtWC4dDWTYxLi8/rqivCog21p BU07wBzc7GK9bM8z0nluCLpGreCtON2mXn66oGmh9Cv6HRMEwECHVgnuOMdhVl26TetN8nXNbSh eABGK+0wZ7B7XMwjCPen1kgMny5yVP191Rb88iCB X-Google-Smtp-Source: AGHT+IGk+A6I7OAoq2hkT7zfg8qRZRdDj/+acqwdCXLy/xduaHfnA2vl2DNhyIca9L7I2EuT+ifLQA== X-Received: by 2002:a17:903:22cd:b0:21f:6d63:6f4f with SMTP id d9443c01a7336-220d33a5098mr127828825ad.2.1739574146613; Fri, 14 Feb 2025 15:02:26 -0800 (PST) Received: from archlinux.plaksha.edu.in ([182.75.25.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22105174c73sm1495245ad.216.2025.02.14.15.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 15:02:26 -0800 (PST) From: Usman Akinyemi To: git@vger.kernel.org Cc: chriscool@tuxfamily.org, christian.couder@gmail.com, johncai86@gmail.com, ps@pks.im, shejialuo@gmail.com Subject: [PATCH 3/7] builtin/send-pack.c: stop using `the_repository` Date: Sat, 15 Feb 2025 04:27:19 +0530 Message-ID: <20250214230210.1460111-4-usmanakinyemi202@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> References: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/send-pack.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_send_pack()` function with `repo` set to NULL and then early in the function, `parse_options()` call will give the options help and exit, without having to consult much of the configuration file. So it is safe to omit reading the config when `repo` argument the caller gave us is NULL. Mentored-by: Christian Couder Signed-off-by: Usman Akinyemi --- builtin/send-pack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/send-pack.c b/builtin/send-pack.c index 8d461008e2..737b93e4a8 100644 --- a/builtin/send-pack.c +++ b/builtin/send-pack.c @@ -1,4 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE #include "builtin.h" #include "config.h" #include "hex.h" @@ -151,7 +150,7 @@ static int send_pack_config(const char *k, const char *v, int cmd_send_pack(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { struct refspec rs = REFSPEC_INIT_PUSH; const char *remote_name = NULL; @@ -212,7 +211,8 @@ int cmd_send_pack(int argc, OPT_END() }; - git_config(send_pack_config, NULL); + if (repo) + repo_config(repo, send_pack_config, NULL); argc = parse_options(argc, argv, prefix, options, send_pack_usage, 0); if (argc > 0) { dest = argv[0]; @@ -317,7 +317,7 @@ int cmd_send_pack(int argc, set_ref_status_for_push(remote_refs, args.send_mirror, args.force_update); - ret = send_pack(the_repository, &args, fd, conn, remote_refs, &extra_have); + ret = send_pack(repo, &args, fd, conn, remote_refs, &extra_have); if (helper_status) print_helper_status(remote_refs); From patchwork Fri Feb 14 22:57:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usman Akinyemi X-Patchwork-Id: 13975712 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAE281C84AC for ; Fri, 14 Feb 2025 23:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574152; cv=none; b=cAR4p2ICmu93NO1SNIbk84/ulR4xKjlOFZnJ3tVcoFPrL8qA6rJhICHFcbcfBi1xyVEydF7YiGOfhjl1oBvKwJl7xWrTkgxNXa2+iK+2ts7CwxsF/BotN4j0l5Bg8r3NXiUC4P1ueqk5rowvH862lmIKbHAuuRfIE0IJaLKRVOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574152; c=relaxed/simple; bh=X7xjuDEfAOz86RnuoIVN5/mhhZuj0sVqm9b9mwWcSUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oCtyC8fZ9MJB1AHbHbjI1e5TC6U+BzvGC6k1gy2YRZsjY0cdlhQ2NgqPklMICMUIvGMJ8Ah/C5YASby//Hz2beca01ju/Pxr6VBAzdm5B9+XPOFCJNNLrfoOW+VVftIJTluiJi5zfvXT9aIFJ0WRg8n63LMRF1rOQGS+VtG1Xvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fMP6T07u; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fMP6T07u" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-21f2339dcfdso40368015ad.1 for ; Fri, 14 Feb 2025 15:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739574150; x=1740178950; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RENv/JkGIHtFGSPxuODKhFNXAHbrnX0mE10E35XZaIk=; b=fMP6T07u/+gk92VfswIpKXb+HpBL3fr1MoYLezeCe72HomNUXlKuaaltb47qPEUkWC LBrhedyD6usaiLglajcx+NuEvXnayhx0TqGci9gI10uPJuCqM77xkDFlgPq86HfFdJl5 py1OtptUxG56rf2A1DTqMioESijnWpjoog5JwkHR36fbcBUdEYAKzLofz+Gggo9oQlz0 ptQ66Q/uksrwu5yR7a/VwDSwrP25BvUELr5e4L1GE3iZFxR9EwMJtrKYXw1EJX4RRHpT 80o+CdsZGj70+dhoibx5HQVp6wIxloy4magZp/Wb4T8hA7Y0J5hRqfVusP8ttQhFonUV wUFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739574150; x=1740178950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RENv/JkGIHtFGSPxuODKhFNXAHbrnX0mE10E35XZaIk=; b=s83fyvwArvicxNW73GCJbXv1X2NDKKHYRg/E1IjYEZ1xJ6cwMnQSWHln648Ilsge20 jaHCTWCy/KRT/hdOKZuUhtOxiAxGdrppjZ2VNhXqTkzCFRwGTd0g2xXIUWdEXk1Uc0dg rmWMcu5azMUkpVN2t96p5L7YEzaEMzUYoUmdH8gm8g8OypWD7cWdW0H/2EJMzjekB2Dx bePZyXgjyVeBMEsBqfatbr9znmoEQ4NVF3wF6HjcuKK7tGX3+v2s/qkZwiyPaItZRYLo sguZ9A0Oaw2x5i8UoURDla1bs/zk9Dgct3UPRWGmBHohKR1uZz86u8I2wC23mgXi/RxX Jh/A== X-Gm-Message-State: AOJu0Yx8BkYMdEpxFa0AI/BXbZA6O1koWAhKDKhoEfy5HyRGjS13UZKz eWXRMS5y0rFyAMI7LnIA/AsHGZkcCpVe5lvzs3D7Yn8UzmLsXDJ59T1iFaaa X-Gm-Gg: ASbGncsjOTR67eoiCtd/9GjFsAV/5wdn2QHLh1xwBIqnvVvZKvGlKY5j2wfDyhre+6+ Fz3sCoDnWuY3xUbPWluZxkd7gopGh+SfMLUfRtHI7+dWGG5pfBM3r688fdG4NbUpUqV4vYMoOwg fBmd0hm2qPOOKV4gOSi9tShwtKinnAtyb+MoFhvZe5jrdZY/XEPkQmuHhtWsLYV2qI7wN1sbL1T P4dUl8Ht8/QmghKf/vkXJv/YEd+Msdmwr7EW3hUsxm8iqGS89tH6sNZbsz25hSCzGiYBKPxhenC cue+DfnHDwInhVZ9vK2NnIXijJmncNl7HSF2eO8S X-Google-Smtp-Source: AGHT+IFxO1xiimFo9yIYfVJlzSYGbEsXpHoygvFotvXf6LqK4SkBiUhZd4FmKaBbvRYtL798kiDYkA== X-Received: by 2002:a17:902:ce89:b0:216:5db1:5dc1 with SMTP id d9443c01a7336-221043951fbmr15616865ad.1.1739574149522; Fri, 14 Feb 2025 15:02:29 -0800 (PST) Received: from archlinux.plaksha.edu.in ([182.75.25.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22105174c73sm1495245ad.216.2025.02.14.15.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 15:02:29 -0800 (PST) From: Usman Akinyemi To: git@vger.kernel.org Cc: chriscool@tuxfamily.org, christian.couder@gmail.com, johncai86@gmail.com, ps@pks.im, shejialuo@gmail.com Subject: [PATCH 4/7] builtin/pack-refs: stop using `the_repository` Date: Sat, 15 Feb 2025 04:27:20 +0530 Message-ID: <20250214230210.1460111-5-usmanakinyemi202@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> References: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/pack-refs.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_pack_refs()` function with `repo` set to NULL and then early in the function, `parse_options()` call will give the options help and exit, without having to consult much of the configuration file. So it is safe to omit reading the config when `repo` argument the caller gave us is NULL. Mentored-by: Christian Couder Signed-off-by: Usman Akinyemi --- builtin/pack-refs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/builtin/pack-refs.c b/builtin/pack-refs.c index 4fdd68880e..5c18230b6d 100644 --- a/builtin/pack-refs.c +++ b/builtin/pack-refs.c @@ -1,5 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE - #include "builtin.h" #include "config.h" #include "gettext.h" @@ -15,7 +13,7 @@ static char const * const pack_refs_usage[] = { int cmd_pack_refs(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { struct ref_exclusions excludes = REF_EXCLUSIONS_INIT; struct string_list included_refs = STRING_LIST_INIT_NODUP; @@ -39,7 +37,8 @@ int cmd_pack_refs(int argc, N_("references to exclude")), OPT_END(), }; - git_config(git_default_config, NULL); + if (repo) + repo_config(repo, git_default_config, NULL); if (parse_options(argc, argv, prefix, opts, pack_refs_usage, 0)) usage_with_options(pack_refs_usage, opts); @@ -52,7 +51,7 @@ int cmd_pack_refs(int argc, if (!pack_refs_opts.includes->nr) string_list_append(pack_refs_opts.includes, "refs/tags/*"); - ret = refs_pack_refs(get_main_ref_store(the_repository), &pack_refs_opts); + ret = refs_pack_refs(get_main_ref_store(repo), &pack_refs_opts); clear_ref_exclusions(&excludes); string_list_clear(&included_refs, 0); From patchwork Fri Feb 14 22:57:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usman Akinyemi X-Patchwork-Id: 13975713 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D31C1FCFF4 for ; Fri, 14 Feb 2025 23:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574154; cv=none; b=k1n2Ql1v1vQfm9sISfJe0YuxPqWAtml8f5k4vTRhFlRrl5VEU9CvDVasRj7Z5VPDx7XEIjxraavCbzJ82VfsdblIaH1ME/MEpLkNe7pLcXO+a1XN9T+SVHmtu5Lzo3kqVjeg8QqYwqbmUzEsdqQFbZSDzmSGJtbc5k2r6Zf43ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574154; c=relaxed/simple; bh=J3wC5ZXGdblCld5rDLoTStJYamB3Hs4zbaGx/iv7R/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LuGNR/HSXBVKtBesPvvCMDaxqvoJHwsuvulbgzVyB31R8AO/w3u1flTUEWKIe4quY6udnZkavF+icbq3tD2LF1zM9nWRLPo9RYdv+THU1LMP4DSL6Jt511dtWdMeOgzSpdpiQeflYe0iIZAcSvM2glvrqbSN1TG0gat/48h0Rm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Lm/CGzHh; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lm/CGzHh" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-220c8f38febso48497215ad.2 for ; Fri, 14 Feb 2025 15:02:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739574152; x=1740178952; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t8TGV13f6sFXc6mps+LdzE6uvrjJNOO8zye/UIvmsWs=; b=Lm/CGzHhYfi7QWnNghcGa/tIyIYRvkV9owLNWBclwGX/1X0jXWdJARYZ2AnurQc/Op oHDjEoxPlmHPS2J6Z+90mqh15Muv5T8kPRCVEOe1lpwvjuX0Vt71PcNLys2+7L4ho9kk Ena0EgFMXwKp9ygRjFgeqJhYLcPDNWUdMPikk6HpHgjUmGDS7y3y32/PP8nqG+1E0Ci6 6IMixwx76gVfQRo8G31tz4G3KZVjjWiqvh6Y1q7T/vmp+oh2G5xNIlHneSunfZHPfeun rrhQ/ZqOJ9bH1LcX74dMycMpgUQ+9FIJPoVpU9awk5jCabid81uv/WY26r4iNJLyz94U 6QHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739574152; x=1740178952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t8TGV13f6sFXc6mps+LdzE6uvrjJNOO8zye/UIvmsWs=; b=QUEGDdCB1FmW8ILoTSvMiLVe0Oe+lhL5wWxDU/HUapF/Fo+0wZ4lOM9LrrxNzrPwpi RVINW0r788L6lbkeW4No8kkDOPozCEAwjph6kcHR/DIOV2MxHIrAUpl/87BZ9QlTbuli X1OPYkTrAqYy9+/K4NJJAQIajY45jeYKXmuYnwRZNOmKq2FFhAy5UDjwofGe5wlsIRWD EsMx2ev6KxuMPsZv7nwbvZWqxu66cyx70gZZkhgFmxN4of1+ZD+v/WCDAGhoUediDcGO d1+WxNuelgwGntO5L/M5CdIvBKLw4Z3EU3bsmmDHDu2l/vSkhOD22XqIDn0JzHWLNeHO 52+w== X-Gm-Message-State: AOJu0YyqpUq/SCX0fM5DSHWAnQjvX/o7vTtWNkjOwN0EB0ZcLrbYIjmP aptfa4gq4mxxet971cczKWCO17arFBE4YhlUWNMRAWEDNmfTs/MLCRkN976g X-Gm-Gg: ASbGncupZcZmL8JQBOztlhPZvbgEpayiiBMo2xsp3wIHh45GpChwFrnfLeM6Pg3CRay Pj4riNOPbRKgaQvMyqimlYE2Ik6F6KLTf/yhha/26YIctsbPuAgCs3d9nyaDO9HmTWXslZz4Ei7 hlI2R69Hx+tBgrdnYNAkX6S01wz/vYCdoR22PcZLH/9abrpnD6cm5j/6NezkgdZ8ONXPcH1sKml FtZIXJa/hANoNhG6e4aoYvETegSjfLykZBL7UXqBKK0tqgzN/W/ulIAkoWHRAPka4sjXxeNM7yL xmhDqSKvhhaSjmXBKuKqIy08BNJuAYxL2YKRsdlU X-Google-Smtp-Source: AGHT+IF2ofo/7gxSTf+EKQmrcMtvhIWTrhLKZtJ/srd9tfcMk9J/syP3CLHDGzqPNRtdVdgTfmFw9A== X-Received: by 2002:a17:902:ef49:b0:212:63c0:d9e7 with SMTP id d9443c01a7336-22103c5f3bamr18042965ad.0.1739574152472; Fri, 14 Feb 2025 15:02:32 -0800 (PST) Received: from archlinux.plaksha.edu.in ([182.75.25.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22105174c73sm1495245ad.216.2025.02.14.15.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 15:02:32 -0800 (PST) From: Usman Akinyemi To: git@vger.kernel.org Cc: chriscool@tuxfamily.org, christian.couder@gmail.com, johncai86@gmail.com, ps@pks.im, shejialuo@gmail.com Subject: [PATCH 5/7] builtin/ls-files: stop using `the_repository` Date: Sat, 15 Feb 2025 04:27:21 +0530 Message-ID: <20250214230210.1460111-6-usmanakinyemi202@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> References: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/ls-files.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_ls_files()` function with `repo` set to NULL and then early in the function, `show_usage_with_options_if_asked()` call will give the options help and exit, without having to consult much of the configuration file. Let's pass `repository` argument to `expand_objectsize()`, `show_ru_info()` functions to remove their dependency on the global `the_repository` variable. Mentored-by: Christian Couder Signed-off-by: Usman Akinyemi --- builtin/ls-files.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/builtin/ls-files.c b/builtin/ls-files.c index a4431429b7..70a377e9c0 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -6,7 +6,6 @@ * Copyright (C) Linus Torvalds, 2005 */ -#define USE_THE_REPOSITORY_VARIABLE #define DISABLE_SIGN_COMPARE_WARNINGS #include "builtin.h" @@ -245,12 +244,13 @@ static void show_submodule(struct repository *superproject, repo_clear(&subrepo); } -static void expand_objectsize(struct strbuf *line, const struct object_id *oid, +static void expand_objectsize(struct repository *repo, struct strbuf *line, + const struct object_id *oid, const enum object_type type, unsigned int padded) { if (type == OBJ_BLOB) { unsigned long size; - if (oid_object_info(the_repository, oid, &size) < 0) + if (oid_object_info(repo, oid, &size) < 0) die(_("could not get object info about '%s'"), oid_to_hex(oid)); if (padded) @@ -283,10 +283,10 @@ static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce, else if (skip_prefix(format, "(objecttype)", &format)) strbuf_addstr(&sb, type_name(object_type(ce->ce_mode))); else if (skip_prefix(format, "(objectsize:padded)", &format)) - expand_objectsize(&sb, &ce->oid, + expand_objectsize(repo, &sb, &ce->oid, object_type(ce->ce_mode), 1); else if (skip_prefix(format, "(objectsize)", &format)) - expand_objectsize(&sb, &ce->oid, + expand_objectsize(repo, &sb, &ce->oid, object_type(ce->ce_mode), 0); else if (skip_prefix(format, "(stage)", &format)) strbuf_addf(&sb, "%d", ce_stage(ce)); @@ -348,7 +348,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir, } } -static void show_ru_info(struct index_state *istate) +static void show_ru_info(struct repository *repo, struct index_state *istate) { struct string_list_item *item; @@ -370,7 +370,7 @@ static void show_ru_info(struct index_state *istate) if (!ui->mode[i]) continue; printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i], - repo_find_unique_abbrev(the_repository, &ui->oid[i], abbrev), + repo_find_unique_abbrev(repo, &ui->oid[i], abbrev), i + 1); write_name(path); } @@ -567,7 +567,7 @@ static int option_parse_exclude_standard(const struct option *opt, int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix, - struct repository *repo UNUSED) + struct repository *repo) { int require_work_tree = 0, show_tag = 0, i; char *max_prefix; @@ -647,15 +647,15 @@ int cmd_ls_files(int argc, show_usage_with_options_if_asked(argc, argv, ls_files_usage, builtin_ls_files_options); - prepare_repo_settings(the_repository); - the_repository->settings.command_requires_full_index = 0; + prepare_repo_settings(repo); + repo->settings.command_requires_full_index = 0; prefix = cmd_prefix; if (prefix) prefix_len = strlen(prefix); - git_config(git_default_config, NULL); + repo_config(repo, git_default_config, NULL); - if (repo_read_index(the_repository) < 0) + if (repo_read_index(repo) < 0) die("index file corrupt"); argc = parse_options(argc, argv, prefix, builtin_ls_files_options, @@ -724,7 +724,7 @@ int cmd_ls_files(int argc, max_prefix = common_prefix(&pathspec); max_prefix_len = get_common_prefix_len(max_prefix); - prune_index(the_repository->index, max_prefix, max_prefix_len); + prune_index(repo->index, max_prefix, max_prefix_len); /* Treat unmatching pathspec elements as errors */ if (pathspec.nr && error_unmatch) @@ -748,13 +748,13 @@ int cmd_ls_files(int argc, */ if (show_stage || show_unmerged) die(_("options '%s' and '%s' cannot be used together"), "ls-files --with-tree", "-s/-u"); - overlay_tree_on_index(the_repository->index, with_tree, max_prefix); + overlay_tree_on_index(repo->index, with_tree, max_prefix); } - show_files(the_repository, &dir); + show_files(repo, &dir); if (show_resolve_undo) - show_ru_info(the_repository->index); + show_ru_info(repo, repo->index); if (ps_matched && report_path_error(ps_matched, &pathspec)) { fprintf(stderr, "Did you forget to 'git add'?\n"); From patchwork Fri Feb 14 22:57:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usman Akinyemi X-Patchwork-Id: 13975714 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 350EC1FDA6B for ; Fri, 14 Feb 2025 23:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574159; cv=none; b=bc+Cr0z+T9eoE1yzXwM4Rjz3X024GIwVcgQz2cONsRq/3ZRKucQ7f4Z4LllneYFi4KyoqGfpLCF/pRpvqBXJliEBI24GB57aiwMLSFJPJml+YIZnrF9ZsfBjLc3ZNYfEQkRjT8TVpoOTp3Vbj2war5Yx8jB3b2gLli1x+nC7cBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574159; c=relaxed/simple; bh=fES0sLVgmO8X/iKwKMYcyCWo4tXnIZMNKhSX5kTNmmY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dAkeYCUbRVd8BzXKwgvZpbjgg3zBHMTqM97iDN6Iuj6+67ToKgVhfsZDTCp8Z1cbcg1jFuS4+0Eu3DWTG07/03qVYRrAMB7+eDXBrCjR0XDgJ1exWLjnXUB6bzCiQrsp9hLEsQ1Bg3CYCkMJkA89TphDl+zymTiU92NmVP6ISao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eawzWggK; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eawzWggK" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-220e6028214so38738495ad.0 for ; Fri, 14 Feb 2025 15:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739574155; x=1740178955; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2GYQuJnhBN0yvMzA1EcZP0GVgXte4QrdClxq6a7RjPY=; b=eawzWggK2vKkfZQYQ5syPhIgLHh0A0mIDUClJkPJIvRKM+CeTjSBho22jyZA6MzaNe 0fVP/NWvWc+y4mlaVihsrHFoMCU98AxKuzZgm6AR4qTpqKy2rvL9vZkolDUVqDhNfI24 SCC+5HnBPtrSxIwmlkXWthNVdlBxoBAHZvRvQRPeTDaT16xsTT+b5EZgy5a4jPn4cvhg qgjWNPSdkhYwwsMjrxrPqYjPEK8UTmxrjRTeHtqy9YueK5pkLna1WpLTcDFsT4iYBR8W 1qq+9FBInTjM3eLoC82Ran8bHOM6fIYpI9CJW7PyM0eMFzr6tut5eJyuVVkCxfIOqyrf fSZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739574155; x=1740178955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2GYQuJnhBN0yvMzA1EcZP0GVgXte4QrdClxq6a7RjPY=; b=xKBxiDpjPejox2TrrP1TgYyons7LuhdsU6ockeaIL2fY+QaU2cZrQODsm1pEqFCQ51 D4Td/Rg5L6HYHmK5MfyAFyfXPOnC64mHU9VI41BA9IpOy/6cT95Ht4uzyiFU5VLJTx2r 6yLdX9wm+DWQcls/PLZ/+Gw2kyZC7RxHGUDOonuH/+tDxWz6s8XjFWCCGl4M7wAC+fbd dkfqK5kVwJgLG8yhIY14Wr6+CYgyQfavfOMo5uOj0avo9tIVFZsCSLITPuFx+lDslaUG R+ySJAPZ+KbVv86OnKOzmIiVCQEd1XKOk2RHJiAmSkie7FFyIkMUfQIwcHauAzY1yCht 2xsg== X-Gm-Message-State: AOJu0Yyu7NhU0WVVzf8dLrF6+yxhtQ8UVkIu12mEVCqNL5jwZKAUl0+V Fi9yFu3feKtqyabIWK7QDGxFJe2plQuTN6CKEDLTazr7fDxO3xNTt0YTnWS0 X-Gm-Gg: ASbGnctF9AQNtJ28whQ+0KPJCo4hEH6pcw7uFKC/T14FMA4DuLsurRUdH8OjiVM+0Iu vR3q39+lRMjyuKSoVDoaBc8xfyHlW5IJohbg7DVYZuP8n4RQ4JFx/pu2/KscCMO2mfh/Oww3rk0 C9ZOUp9AsQMXPT3gq2QhSsowuKcn708I+npEJrA+dleWjeJQ7nljpLQTa7mGtEAjBjKK49URTch 6z5t8yr5RMZySZGXR3sBI55KXmNv800H49hEYmHw9Z9JvLOw6ZM/PoRPIREVNhrTLd5YkKOIL7A fOwKrYjwV+G5z/abgwfARRhCMiHgJepFka6Qhob1 X-Google-Smtp-Source: AGHT+IGYeezf+EwceGhDOxmtRKFj7CuhL9HQM/O9XytWc4XbMtbVd8OHt4aPCqh70Vji+uldpFWwsQ== X-Received: by 2002:a17:903:41c3:b0:220:eade:d77e with SMTP id d9443c01a7336-221040a8e2cmr17988815ad.40.1739574155285; Fri, 14 Feb 2025 15:02:35 -0800 (PST) Received: from archlinux.plaksha.edu.in ([182.75.25.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22105174c73sm1495245ad.216.2025.02.14.15.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 15:02:35 -0800 (PST) From: Usman Akinyemi To: git@vger.kernel.org Cc: chriscool@tuxfamily.org, christian.couder@gmail.com, johncai86@gmail.com, ps@pks.im, shejialuo@gmail.com Subject: [PATCH 6/7] builtin/for-each-ref: stop using `the_repository` Date: Sat, 15 Feb 2025 04:27:22 +0530 Message-ID: <20250214230210.1460111-7-usmanakinyemi202@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> References: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/for-each-ref.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_for_each_ref()` function with `repo` set to NULL and then early in the function, `parse_options()` call will give the options help and exit, without having to consult much of the configuration file. So it is safe to omit reading the config when `repo` argument the caller gave us is NULL. Mentored-by: Christian Couder Signed-off-by: Usman Akinyemi --- builtin/for-each-ref.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 8085ebd8fe..0e9b126605 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -1,4 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE #include "builtin.h" #include "commit.h" #include "config.h" @@ -20,7 +19,7 @@ static char const * const for_each_ref_usage[] = { int cmd_for_each_ref(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { struct ref_sorting *sorting; struct string_list sorting_options = STRING_LIST_INIT_DUP; @@ -63,7 +62,8 @@ int cmd_for_each_ref(int argc, format.format = "%(objectname) %(objecttype)\t%(refname)"; - git_config(git_default_config, NULL); + if (repo) + repo_config(repo, git_default_config, NULL); /* Set default (refname) sorting */ string_list_append(&sorting_options, "refname"); From patchwork Fri Feb 14 22:57:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usman Akinyemi X-Patchwork-Id: 13975715 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20A5F1DE2B4 for ; Fri, 14 Feb 2025 23:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574160; cv=none; b=Fndw23NiGcr7f/z6PIDvn9ERf85F9pOgz178HhdIpszXEOrS8JPQdP/q84/8yUki9M8HpIECermaUKA6BsVMrY1vk3yRdjXtMphqGAw1bO5Bmspd264IWaE6Y9cCCOdMXQxRgjTp6ZGwA3wcbLsE4Ko9q0Mgel4NGKMQDyTGJyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739574160; c=relaxed/simple; bh=QirvhC/GcH9fB/4ExWC4PwOzK4tzDTsE4MUD+GHJMEY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KKAdi4rckXrHf8hciLxMhDSeNznwS8qeNS1MlvWplieEOCKM/khPeWOAB3sFIVvxaz/MWfJg1Hz3VtFgslWLlCf6kTve4zt/kQL82AdcJ0/QmKnGh68tgpJ+6J5f2NXep8uViSs5K42Qs05JmpPEyP7d1w2/517YwsJ4qACWJrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MdFc5M4Y; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MdFc5M4Y" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-220ecbdb4c2so37376125ad.3 for ; Fri, 14 Feb 2025 15:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739574158; x=1740178958; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L8cKSW/SlXPNJ5ybtVAZEcWFZty7EVG9+jJPYUZVC5U=; b=MdFc5M4YzXXs0vnceOawZu5d+5JesdDYmVwPPVX5/Kq27YS084Dhp+dS00n3qiQI8v qs/2FzDsQnPbeNkTIhMT+pzuiHcoiGd4Y+PkWap78GJXibIZs8xC16GctG8ve38L/bGL /UIfGwyK7BU7IhV5ZMDOCyFtJmvEm7LSNo70nSKqPyI7EznBQnn+iDpg8pwARvhlVK3N w0iteQTmixu8rauS1hE52MYP61ERxAPuzPiOEU+jFIfaB6RPgrSIDDr88oHc0PfRlyvM i2Q+ayZe7VIhonIbQ1/KSeCPjLs0ZTvUOvATvPTd4zplA0ofCTHp4Jr2CpauN8MB46Jl lz/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739574158; x=1740178958; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L8cKSW/SlXPNJ5ybtVAZEcWFZty7EVG9+jJPYUZVC5U=; b=qjg+OQG8p3k2z4ln0JMnecIyqFC+rI9ycp+KwrM8BnbFiik8622OqtkBF7bDDpGa8b pEEDAQdoa1Mly14W2iDIdcKVvmJC7WUITHq/Whi7RNDL59Ggobtai+cQYABtS/MpQ231 nteEklJ8CwD72+DLn6oUFtow4lIrW++4x/ajVFir04/DgCrWmJUjnVqctbhSs6yE3ZOk 50b3rxr7gLDCwSO6zaze9jXqqDCR+GwgykD73RVBhHSsifH71U5Y6cFSSV+scSu4mRY/ GrbzmZiuN2cwAiFRj50fv9+93/JeB3hUF2MDrAyDY/ZBqyNf5m/up5P/3xM+7vewDvTq reiA== X-Gm-Message-State: AOJu0Yz4XXDpJblNMDSP9g+tw02oG5y2MSr1jXdf208c263GTXamfPGR 8rjOjo/Q9/+E4V839MZRIJjhUHll8YqLUvxBPtwoPxP3bjgd2QzqJeyQ++6L X-Gm-Gg: ASbGncs+Y8+ZHiGVbxHiOGnyFcjLqpH4/pUUuLPyoTZKQXelv/ND+grODe1ITROV3Sf 1jWhBFl+2qgwZKp36EL+P5I5S5q/kpBDKZr4dJGtH7YoiJpe9j2y0Cz19+zMRXKIFsIR9eW8N+x wuTikVOXCHzbzgol7WJhnpJgqkHfEBYevz5kFB0dxXUkHizkcm7z5zyV5DIUfKgnJsVgDDo79Em XU0geFkjt4FMlcoBYurirX3ELy5K+vIpflyYZgwNSkDMgl7ZzamrJqm7wVLFtSCxYqpG0TeOwmY xH3W3YPCHtnwGb1i+YbhVq2hZknPG+uO4PBk1gOg X-Google-Smtp-Source: AGHT+IE9PDnsNa3pA1eMOmr9ikwAD6VJovUO/3Eh9zHY+FsaI2zimWYUZqZSokRAghD8I8lK3d1mGg== X-Received: by 2002:a17:902:d50d:b0:220:e896:54e1 with SMTP id d9443c01a7336-221040566e6mr16731165ad.26.1739574158023; Fri, 14 Feb 2025 15:02:38 -0800 (PST) Received: from archlinux.plaksha.edu.in ([182.75.25.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22105174c73sm1495245ad.216.2025.02.14.15.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 15:02:37 -0800 (PST) From: Usman Akinyemi To: git@vger.kernel.org Cc: chriscool@tuxfamily.org, christian.couder@gmail.com, johncai86@gmail.com, ps@pks.im, shejialuo@gmail.com Subject: [PATCH 7/7] builtin/checkout-index.c: stop using `the_repository` Date: Sat, 15 Feb 2025 04:27:23 +0530 Message-ID: <20250214230210.1460111-8-usmanakinyemi202@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> References: <20250214230210.1460111-1-usmanakinyemi202@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/checkout-index.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_checkout_index()` function with `repo` set to NULL and then early in the function, `show_usage_with_options_if_asked()` call will give the options help and exit, without having to consult much of the configuration file. Let's pass `repository` argument to `checkout_all()` and `checkout_file()` functions to remove their dependency on the global `the_repository` variable. Mentored-by: Christian Couder Signed-off-by: Usman Akinyemi --- builtin/checkout-index.c | 43 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index e30086c7d4..46035444eb 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -5,7 +5,6 @@ * */ -#define USE_THE_REPOSITORY_VARIABLE #define DISABLE_SIGN_COMPARE_WARNINGS #include "builtin.h" @@ -68,10 +67,10 @@ static void write_tempfile_record(const char *name, const char *prefix) } } -static int checkout_file(const char *name, const char *prefix) +static int checkout_file(struct repository *repo, const char *name, const char *prefix) { int namelen = strlen(name); - int pos = index_name_pos(the_repository->index, name, namelen); + int pos = index_name_pos(repo->index, name, namelen); int has_same_name = 0; int is_file = 0; int is_skipped = 1; @@ -81,8 +80,8 @@ static int checkout_file(const char *name, const char *prefix) if (pos < 0) pos = -pos - 1; - while (pos index->cache_nr) { - struct cache_entry *ce =the_repository->index->cache[pos]; + while (pos < repo->index->cache_nr) { + struct cache_entry *ce =repo->index->cache[pos]; if (ce_namelen(ce) != namelen || memcmp(ce->name, name, namelen)) break; @@ -137,13 +136,13 @@ static int checkout_file(const char *name, const char *prefix) return -1; } -static int checkout_all(const char *prefix, int prefix_length) +static int checkout_all(struct repository *repo, const char *prefix, int prefix_length) { int i, errs = 0; struct cache_entry *last_ce = NULL; - for (i = 0; i < the_repository->index->cache_nr ; i++) { - struct cache_entry *ce = the_repository->index->cache[i]; + for (i = 0; i < repo->index->cache_nr ; i++) { + struct cache_entry *ce = repo->index->cache[i]; if (S_ISSPARSEDIR(ce->ce_mode)) { if (!ce_skip_worktree(ce)) @@ -156,8 +155,8 @@ static int checkout_all(const char *prefix, int prefix_length) * first entry inside the expanded sparse directory). */ if (ignore_skip_worktree) { - ensure_full_index(the_repository->index); - ce = the_repository->index->cache[i]; + ensure_full_index(repo->index); + ce = repo->index->cache[i]; } } @@ -213,7 +212,7 @@ static int option_parse_stage(const struct option *opt, int cmd_checkout_index(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { int i; struct lock_file lock_file = LOCK_INIT; @@ -253,19 +252,19 @@ int cmd_checkout_index(int argc, show_usage_with_options_if_asked(argc, argv, builtin_checkout_index_usage, builtin_checkout_index_options); - git_config(git_default_config, NULL); + repo_config(repo, git_default_config, NULL); prefix_length = prefix ? strlen(prefix) : 0; - prepare_repo_settings(the_repository); - the_repository->settings.command_requires_full_index = 0; + prepare_repo_settings(repo); + repo->settings.command_requires_full_index = 0; - if (repo_read_index(the_repository) < 0) { + if (repo_read_index(repo) < 0) { die("invalid cache"); } argc = parse_options(argc, argv, prefix, builtin_checkout_index_options, builtin_checkout_index_usage, 0); - state.istate = the_repository->index; + state.istate = repo->index; state.force = force; state.quiet = quiet; state.not_new = not_new; @@ -285,8 +284,8 @@ int cmd_checkout_index(int argc, */ if (index_opt && !state.base_dir_len && !to_tempfile) { state.refresh_cache = 1; - state.istate = the_repository->index; - repo_hold_locked_index(the_repository, &lock_file, + state.istate = repo->index; + repo_hold_locked_index(repo, &lock_file, LOCK_DIE_ON_ERROR); } @@ -304,7 +303,7 @@ int cmd_checkout_index(int argc, if (read_from_stdin) die("git checkout-index: don't mix '--stdin' and explicit filenames"); p = prefix_path(prefix, prefix_length, arg); - err |= checkout_file(p, prefix); + err |= checkout_file(repo, p, prefix); free(p); } @@ -326,7 +325,7 @@ int cmd_checkout_index(int argc, strbuf_swap(&buf, &unquoted); } p = prefix_path(prefix, prefix_length, buf.buf); - err |= checkout_file(p, prefix); + err |= checkout_file(repo, p, prefix); free(p); } strbuf_release(&unquoted); @@ -334,7 +333,7 @@ int cmd_checkout_index(int argc, } if (all) - err |= checkout_all(prefix, prefix_length); + err |= checkout_all(repo, prefix, prefix_length); if (pc_workers > 1) err |= run_parallel_checkout(&state, pc_workers, pc_threshold, @@ -344,7 +343,7 @@ int cmd_checkout_index(int argc, return 1; if (is_lock_file_locked(&lock_file) && - write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK)) + write_locked_index(repo->index, &lock_file, COMMIT_LOCK)) die("Unable to write new index file"); return 0; }