Git development
 help / color / mirror / Atom feed
From: Usman Akinyemi <usmanakinyemi202@gmail.com>
To: git@vger.kernel.org, christian.couder@gmail.com
Cc: ps@pks.im, shejialuo@gmail.com, johncai86@gmail.com,
	Christian Couder <chriscool@tuxfamily.org>
Subject: [Outreachy][PATCH v2] builtin/update-server-info: remove the_repository global variable
Date: Mon, 10 Feb 2025 23:40:30 +0530	[thread overview]
Message-ID: <20250210181103.3609495-1-usmanakinyemi202@gmail.com> (raw)
In-Reply-To: <20250210142820.3588250-1-usmanakinyemi202@gmail.com>

Remove the_repository global variable in favor of the repository
argument that gets passed in "builtin/update-server-info.c".

When `-h` is passed to the command outside a Git repository, the
`run_builtin()` will call the `cmd_update_server_info()` 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 <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 builtin/update-server-info.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c
index 47a3f0bdd9..d7467290a8 100644
--- a/builtin/update-server-info.c
+++ b/builtin/update-server-info.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "config.h"
 #include "gettext.h"
@@ -13,7 +12,7 @@ static const char * const update_server_info_usage[] = {
 int cmd_update_server_info(int argc,
 			   const char **argv,
 			   const char *prefix,
-			   struct repository *repo UNUSED)
+			   struct repository *repo)
 {
 	int force = 0;
 	struct option options[] = {
@@ -21,11 +20,12 @@ int cmd_update_server_info(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, options,
 			     update_server_info_usage, 0);
 	if (argc > 0)
 		usage_with_options(update_server_info_usage, options);
 
-	return !!update_server_info(the_repository, force);
+	return !!update_server_info(repo, force);
 }
-- 
2.48.1


  parent reply	other threads:[~2025-02-10 18:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-10 14:28 [Outreachy][PATCH] builtin/update-server-info: remove the_repository global variable Usman Akinyemi
2025-02-10 17:12 ` Junio C Hamano
2025-02-10 18:03   ` Usman Akinyemi
2025-02-10 18:10 ` Usman Akinyemi [this message]
2025-02-11  7:43   ` [Outreachy][PATCH v2] " Patrick Steinhardt
2025-02-11 16:35     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250210181103.3609495-1-usmanakinyemi202@gmail.com \
    --to=usmanakinyemi202@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johncai86@gmail.com \
    --cc=ps@pks.im \
    --cc=shejialuo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox