* [PATCH] MyFirstObjectWalk: remove unnecessary conditional statement
@ 2020-03-28 15:19 Johannes Schindelin via GitGitGadget
2020-03-30 18:07 ` Emily Shaffer
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2020-03-28 15:19 UTC (permalink / raw)
To: git; +Cc: Emily Shaffer, Johannes Schindelin, Johannes Schindelin
From: Johannes Schindelin <johannes.schindelin@gmx.de>
In the given example, `commit` cannot be `NULL` (because this is the
loop condition: if it was `NULL`, the loop body would not be entered at
all). It took this developer a moment or two to see that this is
therefore dead code.
Let's remove it, to avoid puzzling future readers.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
MyFirstObjectWalk: remove unnecessary conditional statement
Our introductory documentation made me scratch my head because our
example contains dead code. I'd like to remove it lest we confuse future
contributors.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-589%2Fdscho%2Fgit-walken-head-scratcher-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-589/dscho/git-walken-head-scratcher-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/589
Documentation/MyFirstObjectWalk.txt | 3 ---
1 file changed, 3 deletions(-)
diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
index aa828dfdc44..c3f2d1a831e 100644
--- a/Documentation/MyFirstObjectWalk.txt
+++ b/Documentation/MyFirstObjectWalk.txt
@@ -357,9 +357,6 @@ static void walken_commit_walk(struct rev_info *rev)
...
while ((commit = get_revision(rev))) {
- if (!commit)
- continue;
-
strbuf_reset(&prettybuf);
pp_commit_easy(CMIT_FMT_ONELINE, commit, &prettybuf);
puts(prettybuf.buf);
base-commit: 3bab5d56259722843359702bc27111475437ad2a
--
gitgitgadget
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] MyFirstObjectWalk: remove unnecessary conditional statement
2020-03-28 15:19 [PATCH] MyFirstObjectWalk: remove unnecessary conditional statement Johannes Schindelin via GitGitGadget
@ 2020-03-30 18:07 ` Emily Shaffer
2020-03-30 18:26 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Emily Shaffer @ 2020-03-30 18:07 UTC (permalink / raw)
To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin
On Sat, Mar 28, 2020 at 03:19:13PM +0000, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> In the given example, `commit` cannot be `NULL` (because this is the
> loop condition: if it was `NULL`, the loop body would not be entered at
> all). It took this developer a moment or two to see that this is
> therefore dead code.
Nice catch. Thanks.
>
> Let's remove it, to avoid puzzling future readers.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Emily Shaffer <emilyshaffer@google.com>
> ---
> MyFirstObjectWalk: remove unnecessary conditional statement
>
> Our introductory documentation made me scratch my head because our
> example contains dead code. I'd like to remove it lest we confuse future
> contributors.
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-589%2Fdscho%2Fgit-walken-head-scratcher-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-589/dscho/git-walken-head-scratcher-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/589
>
> Documentation/MyFirstObjectWalk.txt | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
> index aa828dfdc44..c3f2d1a831e 100644
> --- a/Documentation/MyFirstObjectWalk.txt
> +++ b/Documentation/MyFirstObjectWalk.txt
> @@ -357,9 +357,6 @@ static void walken_commit_walk(struct rev_info *rev)
> ...
>
> while ((commit = get_revision(rev))) {
> - if (!commit)
> - continue;
> -
> strbuf_reset(&prettybuf);
> pp_commit_easy(CMIT_FMT_ONELINE, commit, &prettybuf);
> puts(prettybuf.buf);
>
> base-commit: 3bab5d56259722843359702bc27111475437ad2a
> --
> gitgitgadget
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MyFirstObjectWalk: remove unnecessary conditional statement
2020-03-30 18:07 ` Emily Shaffer
@ 2020-03-30 18:26 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2020-03-30 18:26 UTC (permalink / raw)
To: Emily Shaffer
Cc: Johannes Schindelin via GitGitGadget, git, Johannes Schindelin
Emily Shaffer <emilyshaffer@google.com> writes:
> On Sat, Mar 28, 2020 at 03:19:13PM +0000, Johannes Schindelin via GitGitGadget wrote:
>> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>>
>> In the given example, `commit` cannot be `NULL` (because this is the
>> loop condition: if it was `NULL`, the loop body would not be entered at
>> all). It took this developer a moment or two to see that this is
>> therefore dead code.
>
> Nice catch. Thanks.
>
>>
>> Let's remove it, to avoid puzzling future readers.
>>
>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> Reviewed-by: Emily Shaffer <emilyshaffer@google.com>
Thanks, both.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-30 18:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-28 15:19 [PATCH] MyFirstObjectWalk: remove unnecessary conditional statement Johannes Schindelin via GitGitGadget
2020-03-30 18:07 ` Emily Shaffer
2020-03-30 18:26 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).