public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Usman Akinyemi <usmanakinyemi202@gmail•com>
To: git@vger•kernel.org, christian.couder@gmail•com
Cc: gitster@pobox•com, johncai86@gmail•com, me@ttaylorr•com,
	ps@pks•im, shejialuo@gmail•com, phillip.wood123@gmail•com,
	sunshine@sunshineco•com,
	Christian Couder <chriscool@tuxfamily•org>
Subject: [PATCH 1/1] builtin/update-server-info: remove unnecessary if statement
Date: Tue,  8 Apr 2025 01:28:41 +0530	[thread overview]
Message-ID: <20250407195850.299348-2-usmanakinyemi202@gmail.com> (raw)
In-Reply-To: <20250407195850.299348-1-usmanakinyemi202@gmail.com>

Since we already teach the `repo_config()` in "f29f1990b5
(config: teach repo_config to allow `repo` to be NULL, 2025-03-08)"
to allow `repo` to be NULL, no need to check if `repo` is NULL
before calling `repo_config()`.

Mentored-by: Christian Couder <chriscool@tuxfamily•org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail•com>
---
 builtin/update-server-info.c | 4 ++--
 t/t1517-outside-repo.sh      | 7 +++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c
index d7467290a8..ba702d30ef 100644
--- a/builtin/update-server-info.c
+++ b/builtin/update-server-info.c
@@ -20,8 +20,8 @@ int cmd_update_server_info(int argc,
 		OPT_END()
 	};
 
-	if (repo)
-		repo_config(repo, git_default_config, NULL);
+	repo_config(repo, git_default_config, NULL);
+
 	argc = parse_options(argc, argv, prefix, options,
 			     update_server_info_usage, 0);
 	if (argc > 0)
diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index dbd8cd6906..6824581317 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -107,4 +107,11 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 	test_grep "^error: remote-curl" actual
 '
 
+test_expect_success 'update-server-info does not crash with -h' '
+	test_expect_code 129 git update-server-info -h >usage &&
+	test_grep "[Uu]sage: git update-server-info " usage &&
+	test_expect_code 129 nongit git update-server-info -h >usage &&
+	test_grep "[Uu]sage: git update-server-info " usage
+'
+
 test_done
-- 
2.49.0


      reply	other threads:[~2025-04-07 19:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-29 11:59 [PATCH 0/1] remove unnecessary if statement Usman Akinyemi
2025-03-29 11:59 ` [PATCH 1/1] builtin/update-server-info: " Usman Akinyemi
2025-03-31  7:16   ` Patrick Steinhardt
2025-04-06 12:14 ` [PATCH v2 0/1] " Usman Akinyemi
2025-04-06 12:14   ` [PATCH v2 1/1] builtin/update-server-info: " Usman Akinyemi
2025-04-07  0:24     ` Eric Sunshine
2025-04-07 15:49       ` Junio C Hamano
2025-04-07 19:58   ` [PATCH v2 0/1] " Usman Akinyemi
2025-04-07 19:58     ` Usman Akinyemi [this message]

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=20250407195850.299348-2-usmanakinyemi202@gmail.com \
    --to=usmanakinyemi202@gmail$(echo .)com \
    --cc=chriscool@tuxfamily$(echo .)org \
    --cc=christian.couder@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=johncai86@gmail$(echo .)com \
    --cc=me@ttaylorr$(echo .)com \
    --cc=phillip.wood123@gmail$(echo .)com \
    --cc=ps@pks$(echo .)im \
    --cc=shejialuo@gmail$(echo .)com \
    --cc=sunshine@sunshineco$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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