From patchwork Mon Sep 30 17:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13816788 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 E9F1618FDC5 for ; Mon, 30 Sep 2024 17:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727718036; cv=none; b=sdihkn7RD7SV9iHT4EWxwU4et2eTsbb1rHaYfrANVF2Tfo0+Kgp45Nz0c45vcwhcbYoib6CrQD4vMScPdQc/iZu0Eun8MIfWGCCKwiKWKoW2jkoAO/nOadxZOks9IKNnEv52zP90/iFT35hevW31phT/ckgz8mos+m3r63fE9yY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727718036; c=relaxed/simple; bh=S6N1yg2cO5mWw6rdGwvAlb05NAInW1Z0B2rZhz2W51o=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=iQS980l/ftkEgrwKqP0A0hEnCTva2SiTfIZ07hIc68+JBtzWJnwdcy1h21KvTQ3djhmO6bmc3iIFTFaAOiUjIzUOVmhCrqH0+7nNDSzNnOfiaYKIQqPiwURiaRx0TXbq4/EHHRN3Ml7jY6uleiw0IGUazVPS1b+zW/tTsGBmNHE= 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=Dze5uSZb; arc=none smtp.client-ip=209.85.218.47 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="Dze5uSZb" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a8d100e9ce0so457600266b.2 for ; Mon, 30 Sep 2024 10:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727718033; x=1728322833; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=4oXg8mgs7dTAdfaN7mPgo20jGqeLbHnF7nqFkBF4t8w=; b=Dze5uSZbpTwKAupGEJdiRJc86j1MT6X0iUAi8LswJidSABHcxsPOEkugS8AeYlJcjE +8n7DhwmE3rudkEieepWqo7H9/xHRLq2FyA0QEl+wqTiSjXnp8vXJmC+Y+AwYOyVDUrF u81v68+pNvYbNmOXkN6jV+nPiEFyq/bq8hzrYq7uLi+jSqv56P4t4QGlYLVNLxIdN4mZ 0MSrVrPKx6ojnLtX6mKGp7XICnYxNvsJzINHugr2s6BvrGEkn06rD2fwPRYBRYIFHdCU Om1edt0VLnbChWGPrDfmGyk4di2FJ7uYSKsjpjUtMoGtKOjaXjvm/eVNPjeuV0P3qCWK Syeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727718033; x=1728322833; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4oXg8mgs7dTAdfaN7mPgo20jGqeLbHnF7nqFkBF4t8w=; b=EaJ2ZuE51lx3xs+JWzPXK5aVLPFQ+1PDNgvU7AVa81FgVtod9e1N+8tA8+SDFax/yf zyeSauRW0fFvbLVltXYBCaqXqZ1IoCZG3UM7xqa7vk9sl8biQtJgIbGqZABWCw4FEutQ P2cDiVX86RxMQE7b1mdowqXQahXE6W5qMRmRwM/6+aBK3VbTgJlVaAFO0JMGGGoWwtcC HAyMSAWgenoUZa1lUP364Yxeytmpw6K6l7vxlR5gJE8NK4ObiJXFvns+yd5dUfjNCAR3 4tAvicEafmM3y1S6Qa7uOleQt9zNmJvh0KVLYax1cTUPWq6kaHx5O8rT2+tDQ/kXqoD/ 638Q== X-Gm-Message-State: AOJu0YxQMUxB1AVnkCqzACtYjFYyrR1XeNVE8dXFbOuuZk4szxh5LG5/ M1SXCQ+e0zvjM+/yaBoceZLZYxuYygXSKsgM/fvqqnIfgDd0GFMXFyWxfw== X-Google-Smtp-Source: AGHT+IFyfbqQjN4hZsttYufkRVd9DfuLwqB5BKvFvJJoq/HdzS96zAVgjy+jlepHccu2sjgzQqXxbQ== X-Received: by 2002:a17:906:dac8:b0:a8d:4b02:334c with SMTP id a640c23a62f3a-a93c4c284b7mr1557420966b.64.1727718032564; Mon, 30 Sep 2024 10:40:32 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c297bb76sm572447066b.170.2024.09.30.10.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 10:40:32 -0700 (PDT) Message-Id: <5d72c31c6f3b97b7f5f7d3b4fa9a8b1587597670.1727718030.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 30 Sep 2024 17:40:27 +0000 Subject: [PATCH v2 1/4] git: pass in repo for RUN_SETUP_GENTLY Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: shejialuo , Patrick Steinhardt , John Cai , John Cai From: John Cai From: John Cai commands that have RUN_SETUP_GENTLY potentially need a repository. Modify the logic in run_builtin() to pass the repository to the builtin if a builtin has the RUN_SETUP_GENTLY property. Signed-off-by: John Cai --- git.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/git.c b/git.c index 2fbea24ec92..f58f169f3c7 100644 --- a/git.c +++ b/git.c @@ -443,7 +443,7 @@ static int handle_alias(int *argcp, const char ***argv) static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct repository *repo) { - int status, help; + int status, help, repo_exists; struct stat st; const char *prefix; int run_setup = (p->option & (RUN_SETUP | RUN_SETUP_GENTLY)); @@ -455,9 +455,13 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct if (run_setup & RUN_SETUP) { prefix = setup_git_directory(); + repo_exists = 1; } else if (run_setup & RUN_SETUP_GENTLY) { int nongit_ok; prefix = setup_git_directory_gently(&nongit_ok); + + if (!nongit_ok) + repo_exists = 1; } else { prefix = NULL; } @@ -480,7 +484,10 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct trace2_cmd_name(p->cmd); validate_cache_entries(repo->index); - status = p->fn(argc, argv, prefix, (p->option & RUN_SETUP)? repo : NULL); + status = p->fn(argc, + argv, + prefix, + repo_exists ? repo : NULL); validate_cache_entries(repo->index); if (status) From patchwork Mon Sep 30 17:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13816789 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 865D8193081 for ; Mon, 30 Sep 2024 17:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727718037; cv=none; b=MpZ+Z3XWPPvASZ9dJVqmktD67SpU2+Ox/14HjABDVRfsJAq2eN7mcS6utP78gvNEruT3HiKhDI9sOSHQbw3cFubdm5eajmf3LPG6qG2guvOuwT4uNtrM2ucrYFDuhEGJ3DnGtVVxb8HdA0F4Nd7z7hj+o8u4k05BW2TAmhQVuDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727718037; c=relaxed/simple; bh=RwSw2n0VGxAinrFutu8sBIvZqSbF0hYODfcduSUKH/E=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=PBwgsUDZc6YhJu9WuktnPGU7RbgsVG0zSgzcerxKVlfnKdEjxAozDnl8MWxoKKGa09ods/dl0GF4BNEA/DXPIyyGZQE6j6i6hLAbDR92N2nSZufGLxZ+7sQnJFq0ft7pPZTTzcY9KW4HNO7rnmMnaFBWzP9BQYfBPBkAYWhXh8k= 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=eRt2+0aE; arc=none smtp.client-ip=209.85.208.48 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="eRt2+0aE" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5c87ab540b3so6994130a12.1 for ; Mon, 30 Sep 2024 10:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727718033; x=1728322833; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=CvXWV3eIL+YO9QwpdbtM7lr2gqNwX9dCeM2yR1rvk+Y=; b=eRt2+0aEO36x12gtxpXEi8FzkUey4LduP72C3k9Dh1XOg/t6rI/29Nvz7Ae6FPJcQI jUYGpeX2sbiFWU3MGFcK5fLSSd26q3ciEYp46XlrpSdIhvFM68EBdSTl8HzqxrUitWSd iRDlg5DEH6t69yPTMdN6NjXgS2a3EBfsATT2FVLfynAZajWENOWj393dkJ88TWC4faoM 6uZ/8tlSkwaBsnFP2zDL9rcgsA2DL/WzMVoaQwroCq3ea72Dja2pLph7r00qX64yRMLF Xm8kB2jlovOzZMVuEppflHdM9AmwnraMw+yWRmEHQKP3qCdF2fLLoCOIYvFNTMfm8tFS DnFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727718033; x=1728322833; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CvXWV3eIL+YO9QwpdbtM7lr2gqNwX9dCeM2yR1rvk+Y=; b=Mnam85m0tGyyZ+ZWJoy4b7mWl3J+sOAzkEoIyEjtYZ1TlIeb4Gxc2bDdVbiSkBxzbt Cmk0nnuWswrVso8EkhAzMw4zGDFENCtcEKE1iT1vVm0j5zZSGWh/18memMzdcI3JX6Wn G/A/d0dHx1QBVTkPxdFWqapqjuUkA3rRYlY6uYVzxavqzj8h7/60AwNIQc3yfOBpOX5m aLtDQar80p3SMjaKXnmXZQHb0PqoRejXNrDVZJRWFAndwxwMP2K1LdRuaayeBRo9YBiu cslZt+fYj+yDaQN3SJNozRYnK4/das5Ohd5VPP53/JJOIaI+BkUIMOQEzojL5RGyjkiV +vUg== X-Gm-Message-State: AOJu0Yw/mACUJ9vVkcXKXGnf/yJ8VEsOXaW2aa1kX7TEkVF0y8JK9j/q l8GSs7hYhDaexH8C4KXUO1Sssz5CSVe8WtA5OlsYaXJrO0oX//gl4I+8hg== X-Google-Smtp-Source: AGHT+IGeyWQxz4wOAIdF7Khxe6gcVopjsxzJ2GYjkU/3Of+cEehkz3wSSGF4NzzefpGVNMQIKDriHg== X-Received: by 2002:a05:6402:1e88:b0:5c7:227f:3ebe with SMTP id 4fb4d7f45d1cf-5c8a2a0d2f9mr501993a12.5.1727718033272; Mon, 30 Sep 2024 10:40:33 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c88240a8e9sm4829822a12.36.2024.09.30.10.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 10:40:32 -0700 (PDT) Message-Id: <2a29d113815015b82d807d94f8d551c3f885cb9c.1727718031.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 30 Sep 2024 17:40:28 +0000 Subject: [PATCH v2 2/4] annotate: remove usage of the_repository global Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: shejialuo , Patrick Steinhardt , John Cai , John Cai From: John Cai From: John Cai Remove the the_repository with the repository argument that gets passed down through the builtin function. Signed-off-by: John Cai --- builtin/annotate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builtin/annotate.c b/builtin/annotate.c index a99179fe4dd..ce3dfaafb28 100644 --- a/builtin/annotate.c +++ b/builtin/annotate.c @@ -4,7 +4,6 @@ * Copyright (C) 2006 Ryan Anderson */ -#define USE_THE_REPOSITORY_VARIABLE #include "git-compat-util.h" #include "builtin.h" #include "strvec.h" @@ -12,7 +11,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { struct strvec args = STRVEC_INIT; int i; @@ -23,5 +22,5 @@ int cmd_annotate(int argc, strvec_push(&args, argv[i]); } - return cmd_blame(args.nr, args.v, prefix, the_repository); + return cmd_blame(args.nr, args.v, prefix, repo); } From patchwork Mon Sep 30 17:40:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13816791 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 B281D198E89 for ; Mon, 30 Sep 2024 17:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727718039; cv=none; b=aa1Wa1fMbeKkITSp1ZIbCVudQzkb041E6AEwjh+P4geUCmUfSh/lDxFFeozFAjPvDylsqJDfGr74y1hpea4iMU4bA4s8XtidbuM0ko5SHPukH8vFmb1Qyt6wTBJymyPVs+/6qyiowMuR+vQ1mzDvR2wrB5vj4CQAE39vDauTrpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727718039; c=relaxed/simple; bh=TkH0Jy/C2wq7XC9ZiU8UMdsetPfOA8Hy8vKnd6emoX0=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=Yi+9zx1aa0Vahg38toeuQvoUUHxQcwKJIcGHi8LAffsgGWtREea/jxnp4l2bUMJ/AcKgy9kPvPXz1W1jmQ0LrULsaEv4sv40jINN78F3eWf5K9w6QXCg8WQh1eJz3S4uw895QcUmw0iaNDIZyXbk+vSe8uSgQZulhdKeu3+OJ6Y= 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=FkL2cGk4; arc=none smtp.client-ip=209.85.208.172 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="FkL2cGk4" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2f75aaaade6so46547031fa.1 for ; Mon, 30 Sep 2024 10:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727718034; x=1728322834; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=G1lMFnQXIkx6Fd9qYyPeN7DpuZ/qTyN07CquJF0snKg=; b=FkL2cGk4QXdHPsxm+pHg0RcimaT5vYA0I21A8M3UpT8JH3dDDEnpKORkQx3DBG7FcP /WIIdV2CstXp9OLKTMjgjBhJnjexIQTtfE9UpoOs8znHvP2+Hm4t9n5ZXPSRVPFNVRlz GPZDQq6Qa3BOSaYzhMsv/dusx2k6Mc5bsmDJQ3alk6M7hNBoRL6W4kExdt9l+AJyy1gV jmdtAirbfykrqlRVLKyTp/HZjIBsxjRcfFJ4ZFv8QG6jw2h+2dLY1XzR8GFSfynzIkN1 aT5iUbRtOC9OaNoSOJmxDNCyYCQNNuQ85avO09dWQHMLLVCLIIE1vm11DyF1BeIui8SJ ENyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727718034; x=1728322834; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G1lMFnQXIkx6Fd9qYyPeN7DpuZ/qTyN07CquJF0snKg=; b=Z9jQoP315791Wxi5P4QyL9NTOdjkJxI/oleTb83u7be8gzc7Mvvj1DDMknTxTMPcfV kynkkbEWmpkwelJVcSz9IHiSsQDUr93c/zXv+t9WD/8DfiwaInWbD6QT1ikZ8aH+Xvh5 OFZDXCRb2lb1BbkrlMid0i5QAZwJlqVgxJY6+kqc3gmVE+SLRflRDNATxqugp2zHsHRc HN8N2ZDy0qi72QgP3R8oXzWARo6YfD8HdjPR+ei16811VlafI2M6o9zwwjk0jpcMV295 ANd6tQMHCucG4UxWxNn1XKffeNr5w6gmN+brD4CqG7e8PryOtMCWstHGSVTABgBFSoBu LobQ== X-Gm-Message-State: AOJu0YxQsf/lOso0D+0H9TjETzYTaqa+fqfOOlZIBD7OCI6DpdQ/QXtE wIFP6Xhgy/sxxt4rgGZcPZodBsUHYP+bgV7KFgT86KG+6t3Mvga1MZU9kg== X-Google-Smtp-Source: AGHT+IE0fL54aLaHzrhyIGvzI1/h71ygtOXl/b4TVXWjiWwAUMvGwrL6TDTs4fwPICwUSbFZEoz+lA== X-Received: by 2002:a2e:b895:0:b0:2f7:c76f:3c62 with SMTP id 38308e7fff4ca-2f9d3e56020mr69982891fa.24.1727718034000; Mon, 30 Sep 2024 10:40:34 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c882405ce6sm4800782a12.13.2024.09.30.10.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 10:40:33 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 30 Sep 2024 17:40:29 +0000 Subject: [PATCH v2 3/4] apply: remove the_repository global variable Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: shejialuo , Patrick Steinhardt , John Cai , John Cai From: John Cai From: John Cai Remove the_repository global variable in favor of the repository argument that gets passed in through the builtin function. Signed-off-by: John Cai --- builtin/apply.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/builtin/apply.c b/builtin/apply.c index 84f1863d3ac..d0bafbec7e4 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -1,4 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE #include "builtin.h" #include "gettext.h" #include "hash.h" @@ -12,14 +11,14 @@ static const char * const apply_usage[] = { int cmd_apply(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { int force_apply = 0; int options = 0; int ret; struct apply_state state; - if (init_apply_state(&state, the_repository, prefix)) + if (init_apply_state(&state, repo, prefix)) exit(128); /* @@ -28,8 +27,8 @@ int cmd_apply(int argc, * is worth the effort. * cf. https://lore.kernel.org/git/xmqqcypfcmn4.fsf@gitster.g/ */ - if (!the_hash_algo) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + if (!repo->hash_algo) + repo_set_hash_algo(repo, GIT_HASH_SHA1); argc = apply_parse_options(argc, argv, &state, &force_apply, &options, From patchwork Mon Sep 30 17:40:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13816790 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 1FAC2198A24 for ; Mon, 30 Sep 2024 17:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727718038; cv=none; b=mOhfJDuX+Ecd8Lg4QQiSkXTo6Ds4R8XywHiCY8c9un+THXmLWrNRTQxZPkEgN0+dfs5CuBP+PRfA9BzDYF3glJd7F8mQMOggGBIYBPEF40xf4lLwZNhlhfrtvmO08TGcvhisxQug9IN4Y6iAOJsUpb5/KHnDCgSsCQMP6aPW/NM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727718038; c=relaxed/simple; bh=4ufd+lnF/x/gbVvxt6igaQdaCfeXszeiZxur2NDEL3w=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=IcqlxJIz7grzt32N4DHC9ovuy5y1HX9qhcpoHScM5AC6kA4PxqnnAn+qHyu91LseeO/gsMnXzpSJ04+XkKx82a8I/uD5XkHLiszB5ymdhPkASSqFDntpeUM6XwoDOzkCA37f1Rme9i2kcTAyaMOw+Ev79jrPFbZqUFGhleO77jI= 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=Jp9fJAK9; arc=none smtp.client-ip=209.85.218.49 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="Jp9fJAK9" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a8d24f98215so724889666b.1 for ; Mon, 30 Sep 2024 10:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727718035; x=1728322835; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=e356y39zVXRBnY/Z3w2k2oq9FSHT+mnTZxHfqON7Uzk=; b=Jp9fJAK9/Vq8DnRu4AJ+Xza6mImAbgIhuTEhk0tRKZVabLFyiLhF6OVa8d4k24iY7i jMSC1Ok70OGXmDtYT9XWGE9mUeso14dVmF/GfcHKn+FPLAh4RqWWs4uqNgoS58Y1NcuL Jq9f5G2UM6kBI4AlIU6IoFUkj9/KNOGosflVXqUtNdtew3RSyVYTBSyHhNSkR0MsGGtO ZT/5Rt6BWPJSpJsJEE/Vimure0FP5C+wMtOFtgqP6RMDHOgVgRuamvoRm8Hno97fLZ66 jnc6+eKDV9iyxHq6EK84Icr3cMaa0204UXTb30GD7/yPrXd3hevbwRdhf8wZau0nwbFV Seog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727718035; x=1728322835; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e356y39zVXRBnY/Z3w2k2oq9FSHT+mnTZxHfqON7Uzk=; b=sKJRaZtel+XC5rOPW43F6oFOuTrCfKUU8rsw+mrDZ5V1k0GI2QY9nNvkL+tZQYMkrP 005jHRjUyBJ7lcHDMe01FqSoDPcLcll1fqXjw7sGI6pkzdjBjqzB4VNGJWB2rfBa3gsi 7NmeGUjGyqmx5e7O2NL+87q9fvp3zsIB8tUDtQKxgZ+BR5TJYeJ6+UXRHEtUyz0D+BIE BZ7o70yK1PWZQ9PWAhmx0F3KLchc7Cjm1mPCMJqzgZgXAFPkZuELftD8yXOOzkQ/8xbl cFQ56g4G1+SfbQ0ikEQIHG5Sbmj5c4NcI3sTQTxgDLWjkKtLD5hblwo12RCXFQnmiO83 BsTA== X-Gm-Message-State: AOJu0YxKYi63oPZHXuMh/4YBr34bCoErIsIuQOixZAdXEcqK4qoECdY/ aTZgYK1pYHUZdYE7koS6WcOvs50m9rJbHBU0U0TiB2V4buDBMlCXsF377Q== X-Google-Smtp-Source: AGHT+IEQcB71P25Mkaswj/ySvuZxcOnoKSmOUzvWj+KbtAisQoUKo8WrGtHzlCAZy+kB+FpqLa3iEw== X-Received: by 2002:a17:907:9488:b0:a90:b6e8:6919 with SMTP id a640c23a62f3a-a93c4a6700bmr1322032366b.48.1727718034741; Mon, 30 Sep 2024 10:40:34 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c299aca5sm565266766b.224.2024.09.30.10.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 10:40:34 -0700 (PDT) Message-Id: <857291d7f7dffdd1a63ce9268c8ac91a82f2bdb5.1727718031.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 30 Sep 2024 17:40:30 +0000 Subject: [PATCH v2 4/4] archive: remove the_repository global variable Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: shejialuo , Patrick Steinhardt , John Cai , John Cai From: John Cai From: John Cai Replace the_repository with the repository argument that gets passed down through the builtin function. Signed-off-by: John Cai --- builtin/archive.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builtin/archive.c b/builtin/archive.c index dc926d1a3df..13ea7308c8b 100644 --- a/builtin/archive.c +++ b/builtin/archive.c @@ -2,7 +2,6 @@ * Copyright (c) 2006 Franck Bui-Huu * Copyright (c) 2006 Rene Scharfe */ -#define USE_THE_REPOSITORY_VARIABLE #include "builtin.h" #include "archive.h" #include "gettext.h" @@ -79,7 +78,7 @@ static int run_remote_archiver(int argc, const char **argv, int cmd_archive(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { const char *exec = "git-upload-archive"; char *output = NULL; @@ -110,7 +109,7 @@ int cmd_archive(int argc, setvbuf(stderr, NULL, _IOLBF, BUFSIZ); - ret = write_archive(argc, argv, prefix, the_repository, output, 0); + ret = write_archive(argc, argv, prefix, repo, output, 0); out: free(output);