From: Junio C Hamano <gitster@pobox•com>
To: Hiroyuki Sano <sh19910711@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH 3/3][GSOC] fsck: use is_dot_or_dotdot() instead of strcmp()
Date: Mon, 17 Mar 2014 15:39:26 -0700 [thread overview]
Message-ID: <xmqqtxawa1r5.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1395091825-8330-3-git-send-email-sh19910711@gmail.com> (Hiroyuki Sano's message of "Tue, 18 Mar 2014 06:30:25 +0900")
Hiroyuki Sano <sh19910711@gmail•com> writes:
> The is_dot_or_dotdot() is used to check if the string is either "." or "..".
>
> Signed-off-by: Hiroyuki Sano <sh19910711@gmail•com>
> ---
> fsck.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/fsck.c b/fsck.c
> index b3022ad..c9d7784 100644
> --- a/fsck.c
> +++ b/fsck.c
> @@ -6,6 +6,7 @@
> #include "commit.h"
> #include "tag.h"
> #include "fsck.h"
> +#include "dir.h"
>
> static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data)
> {
> @@ -171,10 +172,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
> has_full_path = 1;
> if (!*name)
> has_empty_name = 1;
> - if (!strcmp(name, "."))
> - has_dot = 1;
> - if (!strcmp(name, ".."))
> - has_dotdot = 1;
> + if (is_dot_or_dotdot(name)) {
> + if (!name[1])
> + has_dot = 1;
> + else
> + has_dotdot = 1;
> + }
In what way is this an improvement?
This looks like "because I was told to", not "because the resulting
code is better" to me.
The other patch on diff-no-index looked sensible, though.
> if (!strcmp(name, ".git"))
> has_dotgit = 1;
> has_zero_pad |= *(char *)desc.buffer == '0';
next prev parent reply other threads:[~2014-03-17 22:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-17 21:30 [PATCH 1/3][GSOC] diff: rename read_directory() to get_directory_list() Hiroyuki Sano
2014-03-17 21:30 ` [PATCH 2/3][GSOC] diff: use is_dot_or_dotdot() instead of strcmp() Hiroyuki Sano
2014-03-17 21:30 ` [PATCH 3/3][GSOC] fsck: " Hiroyuki Sano
2014-03-17 22:39 ` Junio C Hamano [this message]
2014-03-17 22:37 ` [PATCH 1/3][GSOC] diff: rename read_directory() to get_directory_list() Junio C Hamano
2014-03-19 17:22 ` Junio C Hamano
2014-03-19 18:48 ` Junio C Hamano
2014-03-19 10:04 ` Eric Sunshine
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=xmqqtxawa1r5.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=sh19910711@gmail$(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