git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3][GSOC] fsck: use is_dot_or_dotdot() instead of strcmp()

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2014, 22:39 UTC
Message-ID
<xmqqtxawa1r5.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1395091825-8330-3-git-send-email-sh19910711@gmail.com>
Hiroyuki Sano <sh19910711@gmail.com> writes:
Show 33 quoted lines
> 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';
Previous: Hiroyuki SanoNext: Junio C Hamano
Message 4 of 8 in “[GSOC] diff: rename read_directory() to get_directory_list()”
  1. 1/3 [GSOC] diff: rename read_directory() to get_directory_list()Hiroyuki Sano, Mar 17, 2014
  2. 2/3 [GSOC] diff: use is_dot_or_dotdot() instead of strcmp()Hiroyuki Sano, Mar 17, 2014
  3. 3/3 [GSOC] fsck: use is_dot_or_dotdot() instead of strcmp()Hiroyuki Sano, Mar 17, 2014
  4. Junio C HamanoMar 17, 2014
  5. Junio C HamanoMar 17, 2014
  6. Junio C HamanoMar 19, 2014
  7. Junio C HamanoMar 19, 2014
  8. Eric SunshineMar 19, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.