From patchwork Thu Oct 10 21:13:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13831147 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 74464198E9B for ; Thu, 10 Oct 2024 21:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728594834; cv=none; b=md6TIIf19Y2KHpUgD8px6yP0qGKe5XbNqVRjXPWxiv8BrdTZrZfERK1AU/72nmwmfshcXz+38sCR1HEmMmEfEe7cHWuQlKbzFAn7Ku8afOrmiA1oF8SwUEj0gmD2tpsNFrUF5n2MqGmYD2lU87dknDm9irAQuIPXaNi871BAcjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728594834; c=relaxed/simple; bh=Vcvb0nR92lOFed98s8bI4oiZkqRzSbPwumLQW+uwlwU=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=MzSonaVrlyhxzpxcxijNPkPuDNyz/COaOrRMe/zjUumYLRJC+LqZrpp1jKpVIhDGAIpGR8O7covhStuXW7MZh2ME/r1x8y25bWgO2vkhSonRfZ1KEpUUU5r1QiViNGTAiKiuRNlieJSTgsEIhgbDZaln9q8iK7frpZqukBFdIGw= 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=WdKSP8UE; arc=none smtp.client-ip=209.85.218.41 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="WdKSP8UE" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a9932aa108cso214326066b.2 for ; Thu, 10 Oct 2024 14:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728594830; x=1729199630; 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=/NldXoQFsMKP5XRjZG3Zqfga+bbRSOVsK8atZ/eWris=; b=WdKSP8UE+MJmSKQoks7hv5ul49wH91tuSo/AiKfJ4XjN/6wx6i9ZZLwiV/R+VFIaq8 srYAMyHxMsjhitxOfTWTcZzzwYoYewZtO+S9URVnl3//BVgqFebWnmCFFKlxxZCJM+M/ L+eFEg5x/w/mMYPj3A1GOkgbpn1YBOvUf10jh20Of5LwEFhww0z5EwpME6B4couZzukI sBTDRUU1dtIzv/cuZhWN5wXfFbfHM+iKrl3IjWGkmyEGYO+WJhLM+4Tnn69B+uz0jSXn lX7xbjaGGtIYQ5Oityni8uh7SOaLIL78JUcBeeP5qhmO8OqMTQHnlPIM3p1VQ7gzhGYe oGgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728594830; x=1729199630; 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=/NldXoQFsMKP5XRjZG3Zqfga+bbRSOVsK8atZ/eWris=; b=baJrO7BkbDHLCA9cafT7sUihXw+EIzub/TGmEdaMjAcRqHGbhq1IPl8wiKlkjSAoed BVmhf+xpnP5lgaP34mm1SFcJp0HtTWlSMGjF+H75YlOYozZsVByQk7jfwSgpWzDHLukl +SW6bVyj+CHnBb5RrfYvy44SR+UsSdN6Z+j4kWkO+XK/UMCWaJHXWMnrSe0S2Yk/1Z3q KT0JYiGlqXl+O+CvlXhyRTSv7yb6H+waftvsJympZZNXr+LxYT3gL+4khv8tKnAClesa v4+8JhsnhPhURdOAUuY8jlMvsHeSWINwZbHg7zMGVfU+WZFrXAYQH+f7zTY3oJuI6iR3 dRYg== X-Gm-Message-State: AOJu0Yx0iYUbNtZ3hiSPRq/rqPcFPHzPZp8QbzPKEV4/Vk23PKT2pyH1 9kXSIdq7iwwToz2iYAA3uHqFNAgKwZ2DvqF49b7imTfL7vnQSgYXn6YKRw== X-Google-Smtp-Source: AGHT+IFrdHq0EMD7kFc1Y9iUjWyDErRy86dvJ8gs9IuR4wkgghLgIAbi3pk8POS6kgLXWByxz0ViZA== X-Received: by 2002:a17:907:f797:b0:a99:7c14:919d with SMTP id a640c23a62f3a-a99b96ad6b6mr24653066b.50.1728594830126; Thu, 10 Oct 2024 14:13:50 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80dc679sm137001166b.167.2024.10.10.14.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 14:13:49 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 10 Oct 2024 21:13:46 +0000 Subject: [PATCH v4 1/3] git: pass in repo to builtin based on setup_git_directory_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 The current code in run_builtin() passes in a repository to the builtin based on whether cmd_struct's option flag has RUN_SETUP. This is incorrect, however, since some builtins that only have RUN_SETUP_GENTLY can potentially take a repository. setup_git_directory_gently() tells us whether or not a command is being run inside of a repository. Use the output of setup_git_directory_gently() to help determine whether or not there is a repository to pass to the builtin. If not, then we just pass NULL. As part of this patch, we need to modify add to check for a NULL repo before calling repo_git_config(), since add -h can be run outside of a repository. Signed-off-by: John Cai --- builtin/add.c | 3 ++- git.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 773b7224a49..7d353077921 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -385,7 +385,8 @@ int cmd_add(int argc, char *ps_matched = NULL; struct lock_file lock_file = LOCK_INIT; - repo_config(repo, add_config, NULL); + if (repo) + repo_config(repo, add_config, NULL); argc = parse_options(argc, argv, prefix, builtin_add_options, builtin_add_usage, PARSE_OPT_KEEP_ARGV0); diff --git a/git.c b/git.c index 2fbea24ec92..47741be3e4c 100644 --- a/git.c +++ b/git.c @@ -444,6 +444,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 no_repo = 1; struct stat st; const char *prefix; int run_setup = (p->option & (RUN_SETUP | RUN_SETUP_GENTLY)); @@ -455,9 +456,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct if (run_setup & RUN_SETUP) { prefix = setup_git_directory(); + no_repo = 0; } else if (run_setup & RUN_SETUP_GENTLY) { - int nongit_ok; - prefix = setup_git_directory_gently(&nongit_ok); + prefix = setup_git_directory_gently(&no_repo); } else { prefix = NULL; } @@ -480,7 +481,7 @@ 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, no_repo ? NULL : repo); validate_cache_entries(repo->index); if (status) From patchwork Thu Oct 10 21:13:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13831148 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 ED11F1D0481 for ; Thu, 10 Oct 2024 21:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728594834; cv=none; b=u1niz3tGsbPwaqz9cDoH27X+JmTAmej3ZZGT5bOYi0SNDoG71JVIqNZHY9Z0V0+Dz5JOsB5+UUSy5unDOOqfK6FNQ9ui8L7Oi7ktpIJuAWL2pqXaizWH9fdaQ/V7siyS/WsrmUD6INS/KwiK0wKzufkPXe5+hrUTiLi75Fl8EHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728594834; c=relaxed/simple; bh=2kb1vsm+R+++B/q6UnLA9rEbnoDN9TQlf0q22rqwDqs=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=SuJ2N+JTtNf4LW4va6Xj/uBXNyMYwH9edBt1wrVjx6T8iOmepbXSAAN1FUq4TcEBdUa4hmxjajLoGrHA0feMtWALnNT8Xx0deuz6UnZ69KoGKHIE2L3CMSl2qhrK6jfxFgtvSKV1fUXpPxTqZQS5cibZJAnD5QZDtKhptVBJTAA= 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=jpFcvmK8; arc=none smtp.client-ip=209.85.218.53 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="jpFcvmK8" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a993f6916daso238502266b.1 for ; Thu, 10 Oct 2024 14:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728594831; x=1729199631; 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=kWXY86I7ez8lQdjI7XiobjMqZstrrZZ+RegZvkK3Jco=; b=jpFcvmK8AF816ROyPgly2w1rvJsMKZ0AHtGbJIfIoj2/ISMl5N98PNWFH9DBHHJzxE tYPj3ePaq538ktiLElBxiEPGy/Dv71NjOJMrL1nBopWLuhJwXaQoksDikhlqtE/vn1fN yrTgxgMXnAlChwkKcoM4qnpsoL1LMTon/BdQ0jmZ3PHpOJuQ5fNf/+37Ka7yiOp96P+2 gR9BQwFgvQmT3AA2jarH4DRZllRl3elAJWgVQLQviMM4wRVNzCW8aq1zyhW/PAFQL1gr DALVXjabUGuY2FYm7U545CvtBoW4dNViiJa5WujfHwMFuuYKaAMgoUUEbaOSzCgded88 e93Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728594831; x=1729199631; 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=kWXY86I7ez8lQdjI7XiobjMqZstrrZZ+RegZvkK3Jco=; b=aaxcmnWVl4nQoZF9BimbnVFJ9OgYEHk4UDwIwh2hlBVPofYZ0iJQhw9Y1QPH0LaShI /n7Wyjs0DbLin8SS4XMMiVwi2Y3USpe9zuU6HFlNy40porXtZcX6nUkie7ONAIzPgcKX rgbd9avYuiffdRNqUe+ShKb3MZP06K1w4JEO1xolv7JkWL8ghV576VDeqShuHC5jQgzj ctMzZHJvnvf50d9mXv50aD5UjEdMQIBlYODqyuw2gk4s2psgqEKoetjs4jCpbOD+tYGD r4gKgo/mIrtVPOgg/fpvIz7dXDNhA67W7kwChtJ5aI5pjrDwsBUDEAbqSJCyX/JjZHwY yV5g== X-Gm-Message-State: AOJu0YzO01pSTLK116cUsQl3DqEgo+BGHUpLJM3N+/FzUIOKu2qt3cl7 7vOClnCAJyNCcttFtqUU220LLKPTTeMVgihBicvLEbW/n6HxgAIfv8Jc6A== X-Google-Smtp-Source: AGHT+IGGq2JQCinkdJ63jNm/QOwDG9cEEaYpg/zTLY8+kiMVUdWj2dNQD006dXzHAFqJ3dbegbrEdA== X-Received: by 2002:a17:906:c10d:b0:a99:4879:ec2d with SMTP id a640c23a62f3a-a99b9307195mr24225066b.5.1728594830915; Thu, 10 Oct 2024 14:13:50 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80f2928sm136479766b.214.2024.10.10.14.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 14:13:50 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 10 Oct 2024 21:13:47 +0000 Subject: [PATCH v4 2/3] 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 As part of the effort to get rid of global state due to the_repository variable, 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 Thu Oct 10 21:13:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13831149 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 5DE061E32D4 for ; Thu, 10 Oct 2024 21:13:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728594836; cv=none; b=nDaaZACoCYMRMgUj6pDrMJ1O9eI2iB4CpJYVc3QTLZtXMkHB4wPdQhIWjoIy48LuIHzc7owGOmyClF+/pJnwUfOirbEOvkxY7uc9J5iFMpjSznHkJ/xE5qlMv21SJ4xr/Ue/hApWX2bpoFUJYmIXyFOQRslFb2jzfgdw2DLf93I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728594836; c=relaxed/simple; bh=MkOCFaT5SwqBGLC85ctmkoRHDeyTur94B15a1M6h3UQ=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=utGncO8tcdGV7oiRCG0DzZ6B5fgkWNrsktCsAWi9DvPcGThKXhHqXAsmF4kZF0JQM9KMF77AuqUYWLk57DsQLCvD8LazCtJ7E9xp33hPhVq9ew0ADNC+Xty54A+RZO7d1sFTN8GYfnUF2TF6xIpZye8eWOvmo9URjvg5aYEDWNg= 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=alAKg3fv; arc=none smtp.client-ip=209.85.218.53 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="alAKg3fv" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a9960371b62so151242566b.3 for ; Thu, 10 Oct 2024 14:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728594832; x=1729199632; 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=oPK0M/mrxeFlpFHSSPKKGePzxVSY9keAdsUPttS8i5A=; b=alAKg3fvE6gKjyf1kbdGUB7zKTJGFSc6N8yP0b4g8dSuSmxyyhhfQt6nTNzVkfUw6H 6E9wT7tp1D23RlgMMUzpR8iEbNrJUh3rrZm2xKiuUqEYIEVURogONMhkAx4/G/90o0Gq Zh/y3aUzsVw5al7bxX8sxqI7a941l2LcIKgy+sdF8QZhac56/nPWbVDtCxCOVzN+5IL7 /LfoJllGhQ+/wbEE1RtlqsTSXjYJeCgo5fEZBhYZ83uhsdzUZt6MDriTljkeoTEEkehw IWA4P64l6FPhiH2KlZFJJkTc7C+wJtCDd3c3Qp0WTCbNonCaKuMglJcOFSO2lSC3HQ4U BRXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728594832; x=1729199632; 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=oPK0M/mrxeFlpFHSSPKKGePzxVSY9keAdsUPttS8i5A=; b=jKpkbNeiXtxuX25uxQ70p3H86VlUX0Xc8gaX/s11FgfRkBvDvKFkGfADvE1tcS7z/W 5I/S9rpzHF5yo5IweWlaav5ePo1jcxjKzRNPmtkNEaGtjjeZ6bmgcLxPggw8El8IA+oZ OBL19uyPvy6xQZxUWpeFeQO/LoO6pRE2Bmd8dGBT0+1zv+VYMYdz5if0BOLUytP447FC BZXAwZ7ANr2CnNVTo05xhIMOgc8b78WyfEw+PciZqksbBy6SFEfsLSN3n+HuTKsJAyAc O0PZ+wBYX86LsvzgAXS9fHOnxuc3MYjsS4focz6c5CVTdmrFhRadlDbllHxUD6RVN/MW 8iEw== X-Gm-Message-State: AOJu0YyUfmYtUmbHS30vbIq53E7yDcdFvu8q4jdlByP2JqF489Ubem89 tdXV+Q2fz0PkJCNAbQS/92/+NgNGIhJLlZn+ftzsZuteyc2qX8YX36RRog== X-Google-Smtp-Source: AGHT+IGEOfrEL0R6ojKeVtm9Qdv6TjMh8aVqy1HJw27qxvH3WB9PGJvhsFuXWuPxxMn3Tp8dDlmDQQ== X-Received: by 2002:a17:907:e60c:b0:a8b:2604:1da3 with SMTP id a640c23a62f3a-a99b945c9dfmr27860566b.17.1728594832038; Thu, 10 Oct 2024 14:13:52 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80dcd03sm138350466b.174.2024.10.10.14.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 14:13:51 -0700 (PDT) Message-Id: <736212f34b5806de2fc12f5ebc5030bc71884cc7.1728594828.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 10 Oct 2024 21:13:48 +0000 Subject: [PATCH v4 3/3] 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 As part of the effort to get rid of global state due to the global the_repository variable, replace the_repository with the repository argument that gets passed down through the builtin function. The repo might be NULL, but we should be safe in write_archive() because it detects if we are outside of a repository and calls setup_git_directory() which will error. 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);