* [PATCH 0/1] remove unnecessary if statement
@ 2025-03-29 11:59 Usman Akinyemi
2025-03-29 11:59 ` [PATCH 1/1] builtin/update-server-info: " Usman Akinyemi
2025-04-06 12:14 ` [PATCH v2 0/1] " Usman Akinyemi
0 siblings, 2 replies; 9+ messages in thread
From: Usman Akinyemi @ 2025-03-29 11:59 UTC (permalink / raw)
To: git, christian.couder; +Cc: gitster, johncai86, me, ps, shejialuo, philip
In an earlier patch[1] which has been merged to the master,
We checked `repo` is not NULL before making call to `repo_config()`.
Later, in another patch series[2] which has been merged to master,
`repo_config()` was taught to allow `repo` to be NULL.
So there is not need for checking if the `repo` is NULL before calling
repo_config() in the earlier patch.
Also, Patrick suggested having the test inside the
"t1517-outside-repo.sh"[3] instead of having it in the individual test
files like[2] and I also think it is a good approach as we will
have all such tests in one place. So, for this patch, I added the
test inside the "t1517-outside-repo.sh". If this is accepted, I will
move the test for previous builtin cmd which has already been merged
to master to "t1517-outside-repo.sh" file.
[1] https://public-inbox.org/git/20250210181103.3609495-1-usmanakinyemi202@gmail.com/
[2] https://public-inbox.org/git/20250307233543.1721552-1-usmanakinyemi202@gmail.com/
[3] https://public-inbox.org/git/Z9vCDFRUG7IzU_AG@pks.im/
Usman Akinyemi (1):
builtin/update-server-info: remove unnecessary if statement
builtin/update-server-info.c | 4 ++--
t/t1517-outside-repo.sh | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1] builtin/update-server-info: remove unnecessary if statement
2025-03-29 11:59 [PATCH 0/1] remove unnecessary if statement Usman Akinyemi
@ 2025-03-29 11:59 ` Usman Akinyemi
2025-03-31 7:16 ` Patrick Steinhardt
2025-04-06 12:14 ` [PATCH v2 0/1] " Usman Akinyemi
1 sibling, 1 reply; 9+ messages in thread
From: Usman Akinyemi @ 2025-03-29 11:59 UTC (permalink / raw)
To: git, christian.couder
Cc: gitster, johncai86, me, ps, shejialuo, philip, Christian Couder
Since we already teach the `repo_config()` 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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/1] builtin/update-server-info: remove unnecessary if statement
2025-03-29 11:59 ` [PATCH 1/1] builtin/update-server-info: " Usman Akinyemi
@ 2025-03-31 7:16 ` Patrick Steinhardt
0 siblings, 0 replies; 9+ messages in thread
From: Patrick Steinhardt @ 2025-03-31 7:16 UTC (permalink / raw)
To: Usman Akinyemi
Cc: git, christian.couder, gitster, johncai86, me, shejialuo, philip,
Christian Couder
On Sat, Mar 29, 2025 at 05:29:25PM +0530, Usman Akinyemi wrote:
> Since we already teach the `repo_config()` to allow `repo`
> to be NULL, no need to check if `repo` is NULL before calling
> `repo_config()`.
Tiny nit: when you refer to changes made in a previous commit it makes
sense to reference that commit via `git log -1 --format=reference` so
that outside readers who aren't deeply familiar with the recent changes
know where to look.
Other than that this patch looks good to me, thanks!
Patrick
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 0/1] remove unnecessary if statement
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-04-06 12:14 ` Usman Akinyemi
2025-04-06 12:14 ` [PATCH v2 1/1] builtin/update-server-info: " Usman Akinyemi
2025-04-07 19:58 ` [PATCH v2 0/1] " Usman Akinyemi
1 sibling, 2 replies; 9+ messages in thread
From: Usman Akinyemi @ 2025-04-06 12:14 UTC (permalink / raw)
To: git, christian.couder
Cc: gitster, johncai86, me, ps, shejialuo, phillip.wood123
In an earlier patch[1] (1a764cdbdc (Merge branch
'ua/some-builtins-wo-the-repository', 2025-03-26))
which has been merged to the master, we checked `repo` is not NULL
before making call to `repo_config()`. Later, in another patch series[2]
which has been merged to master, `repo_config()` was taught to allow
`repo` to be NULL.
So there is not need for checking if the `repo` is NULL before calling
repo_config() in the earlier patch.
Also, Patrick suggested having the test inside the
"t1517-outside-repo.sh"[3] instead of having it in the individual test
files like[2] and I also think it is a good approach as we will
have all such tests in one place. So, for this patch, I added the
test inside the "t1517-outside-repo.sh". If this is accepted, I will
move the test for previous builtin cmd which has already been merged
to master to "t1517-outside-repo.sh" file.
[1] https://public-inbox.org/git/20250210181103.3609495-1-usmanakinyemi202@gmail.com/
[2] https://public-inbox.org/git/20250307233543.1721552-1-usmanakinyemi202@gmail.com/
[3] https://public-inbox.org/git/Z9vCDFRUG7IzU_AG@pks.im/
Changes since v1
================
- Make reference to the previous commit that this commit depends on
via "git log"
Usman Akinyemi (1):
builtin/update-server-info: remove unnecessary if statement
builtin/update-server-info.c | 4 ++--
t/t1517-outside-repo.sh | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)
Range-diff versus v1:
1: d6054cbc0b ! 1: 020b228eb1 builtin/update-server-info: remove unnecessary if statement
@@ Metadata
## Commit message ##
builtin/update-server-info: remove unnecessary if statement
- Since we already teach the `repo_config()` to allow `repo`
- to be NULL, no need to check if `repo` is NULL before calling
- `repo_config()`.
+ Since we already teach the `repo_config()` in "1a764cdbdc
+ (Merge branch 'ua/some-builtins-wo-the-repository', 2025-03-26)
+ 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>
--
2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/1] builtin/update-server-info: remove unnecessary if statement
2025-04-06 12:14 ` [PATCH v2 0/1] " Usman Akinyemi
@ 2025-04-06 12:14 ` Usman Akinyemi
2025-04-07 0:24 ` Eric Sunshine
2025-04-07 19:58 ` [PATCH v2 0/1] " Usman Akinyemi
1 sibling, 1 reply; 9+ messages in thread
From: Usman Akinyemi @ 2025-04-06 12:14 UTC (permalink / raw)
To: git, christian.couder
Cc: gitster, johncai86, me, ps, shejialuo, phillip.wood123,
Christian Couder
Since we already teach the `repo_config()` in "1a764cdbdc
(Merge branch 'ua/some-builtins-wo-the-repository', 2025-03-26)"
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/1] builtin/update-server-info: remove unnecessary if statement
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
0 siblings, 1 reply; 9+ messages in thread
From: Eric Sunshine @ 2025-04-07 0:24 UTC (permalink / raw)
To: Usman Akinyemi
Cc: git, christian.couder, gitster, johncai86, me, ps, shejialuo,
phillip.wood123, Christian Couder
On Sun, Apr 6, 2025 at 8:15 AM Usman Akinyemi
<usmanakinyemi202@gmail.com> wrote:
> Since we already teach the `repo_config()` in "1a764cdbdc
> (Merge branch 'ua/some-builtins-wo-the-repository', 2025-03-26)"
> to allow `repo` to be NULL, no need to check if `repo` is NULL
> before calling `repo_config()`.
Okay, makes sense. However...
By referencing only the merge commit in the above message, you force
reviewers and future readers to chase down and locate the actual
commit[*] which taught repo_config() to accept NULL for `repo`. To be
more friendly to those people, you should help them by instead
referencing the commit[*] itself.
[*]: f29f1990b5 (config: teach repo_config to allow `repo` to be NULL,
2025-03-08)
> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/1] builtin/update-server-info: remove unnecessary if statement
2025-04-07 0:24 ` Eric Sunshine
@ 2025-04-07 15:49 ` Junio C Hamano
0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2025-04-07 15:49 UTC (permalink / raw)
To: Eric Sunshine
Cc: Usman Akinyemi, git, christian.couder, johncai86, me, ps,
shejialuo, phillip.wood123, Christian Couder
Eric Sunshine <sunshine@sunshineco.com> writes:
> On Sun, Apr 6, 2025 at 8:15 AM Usman Akinyemi
> <usmanakinyemi202@gmail.com> wrote:
>> Since we already teach the `repo_config()` in "1a764cdbdc
>> (Merge branch 'ua/some-builtins-wo-the-repository', 2025-03-26)"
>> to allow `repo` to be NULL, no need to check if `repo` is NULL
>> before calling `repo_config()`.
>
> Okay, makes sense. However...
>
> By referencing only the merge commit in the above message, you force
> reviewers and future readers to chase down and locate the actual
> commit[*] which taught repo_config() to accept NULL for `repo`.
Thanks for raising this.
When referring to an entire long series as a whole, a reference to
the concluding merge might be more useful, as the topic name
(hopefully) concisely summarizes what the topic was. However,
referring to a single patch series, or a single step in a longer
topic, ...
> To be
> more friendly to those people, you should help them by instead
> referencing the commit[*] itself.
... this is a useful general advice.
> [*]: f29f1990b5 (config: teach repo_config to allow `repo` to be NULL,
> 2025-03-08)
>
>> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 0/1] remove unnecessary if statement
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 19:58 ` Usman Akinyemi
2025-04-07 19:58 ` [PATCH 1/1] builtin/update-server-info: " Usman Akinyemi
1 sibling, 1 reply; 9+ messages in thread
From: Usman Akinyemi @ 2025-04-07 19:58 UTC (permalink / raw)
To: git, christian.couder
Cc: gitster, johncai86, me, ps, shejialuo, phillip.wood123, sunshine
In an earlier patch[1] (f29f1990b5 (config:
teach repo_config to allow `repo` to be NULL, 2025-03-08))
which has been merged to the master, we checked `repo` is not NULL
before making call to `repo_config()`. Later, in another patch series[2]
which has been merged to master, `repo_config()` was taught to allow
`repo` to be NULL.
So there is not need for checking if the `repo` is NULL before calling
repo_config() in the earlier patch.
Also, Patrick suggested having the test inside the
"t1517-outside-repo.sh"[3] instead of having it in the individual test
files like[2] and I also think it is a good approach as we will
have all such tests in one place. So, for this patch, I added the
test inside the "t1517-outside-repo.sh". If this is accepted, I will
move the test for previous builtin cmd which has already been merged
to master to "t1517-outside-repo.sh" file.
[1] https://public-inbox.org/git/20250210181103.3609495-1-usmanakinyemi202@gmail.com/
[2] https://public-inbox.org/git/20250307233543.1721552-1-usmanakinyemi202@gmail.com/
[3] https://public-inbox.org/git/Z9vCDFRUG7IzU_AG@pks.im/
Changes since 2
================
- Make reference to commit that teaches repo_config() to be NULL instead
of the merge commit.
Usman Akinyemi (1):
builtin/update-server-info: remove unnecessary if statement
builtin/update-server-info.c | 4 ++--
t/t1517-outside-repo.sh | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)
Range-diff versus v2:
1: 020b228eb1 ! 1: cd359dafe8 builtin/update-server-info: remove unnecessary if statement
@@ Metadata
## Commit message ##
builtin/update-server-info: remove unnecessary if statement
- Since we already teach the `repo_config()` in "1a764cdbdc
- (Merge branch 'ua/some-builtins-wo-the-repository', 2025-03-26)
+ 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()`.
--
2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1] builtin/update-server-info: remove unnecessary if statement
2025-04-07 19:58 ` [PATCH v2 0/1] " Usman Akinyemi
@ 2025-04-07 19:58 ` Usman Akinyemi
0 siblings, 0 replies; 9+ messages in thread
From: Usman Akinyemi @ 2025-04-07 19:58 UTC (permalink / raw)
To: git, christian.couder
Cc: gitster, johncai86, me, ps, shejialuo, phillip.wood123, sunshine,
Christian Couder
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-04-07 19:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/1] builtin/update-server-info: " Usman Akinyemi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).