{"thread":{"id":"36232","subject":"[PATCH v5] fsck.c: fsck_tree() now use is_dot_or_dotdot().","startedAt":"2014-03-19T16:08:10Z","lastAt":"2014-03-19T17:51:58Z","messageCount":2,"participants":["Andrei Dinu","Matthieu Moy"],"isPatch":true,"patchVersion":5,"patchTotal":null},"messages":[{"id":"237082","messageId":"1395245290-6677-1-git-send-email-mandrei.dinu@gmail.com","threadId":"36232","inReplyTo":null,"subject":"[PATCH v5] fsck.c: fsck_tree() now use is_dot_or_dotdot().","fromName":"Andrei Dinu","fromEmail":"mandrei.dinu@gmail.com","sentAt":"2014-03-19T16:08:10Z","receivedAt":"2014-03-19T16:08:10Z","isPatch":true,"sender":{"key":"mandrei.dinu@gmail.com","avatar":null},"body":"Rewrite fsck_tree() to use is_dot_or_dotdot() from \"dir.h\".\n\nSigned-off-by: Andrei Dinu <mandrei.dinu@gmail.com>\n\n\n---\n I try to find other sites that can use id_dot_or_dotdot() function.\n\n fsck.c |   11 +++++++----\n 1 file changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/fsck.c b/fsck.c\nindex 64bf279..82a55ab 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -6,6 +6,7 @@\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"fsck.h\"\n+#include \"dir.h\"\n \n static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data)\n {\n@@ -171,10 +172,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)\n \t\t\thas_full_path = 1;\n \t\tif (!*name)\n \t\t\thas_empty_name = 1;\n-\t\tif (!strcmp(name, \".\"))\n-\t\t\thas_dot = 1;\n-\t\tif (!strcmp(name, \"..\"))\n-\t\t\thas_dotdot = 1;\n+\t\tif (is_dot_or_dotdot(name)) {\n+            if (name[1] == '\\0')\n+\t\t\t    has_dot = 1;\n+            else\n+\t\t\t    has_dotdot = 1;\n+        }\n \t\tif (!strcmp(name, \".git\"))\n \t\t\thas_dotgit = 1;\n \t\thas_zero_pad |= *(char *)desc.buffer == '0';\n-- \n1.7.9.5\n"},{"id":"237093","messageId":"vpq61nadqkh.fsf@anie.imag.fr","threadId":"36232","inReplyTo":"1395245290-6677-1-git-send-email-mandrei.dinu@gmail.com","subject":"Re: [PATCH v5] fsck.c: fsck_tree() now use is_dot_or_dotdot().","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-03-19T17:51:58Z","receivedAt":"2014-03-19T17:51:58Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Andrei Dinu <mandrei.dinu@gmail.com> writes:\n\n> ---\n>  I try to find other sites that can use id_dot_or_dotdot() function.\n\nThis should also have been sent in the same series.\n\n> @@ -171,10 +172,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)\n>  \t\t\thas_full_path = 1;\n>  \t\tif (!*name)\n>  \t\t\thas_empty_name = 1;\n> -\t\tif (!strcmp(name, \".\"))\n> -\t\t\thas_dot = 1;\n> -\t\tif (!strcmp(name, \"..\"))\n> -\t\t\thas_dotdot = 1;\n> +\t\tif (is_dot_or_dotdot(name)) {\n> +            if (name[1] == '\\0')\n> +\t\t\t    has_dot = 1;\n> +            else\n> +\t\t\t    has_dotdot = 1;\n> +        }\n\nThe indentation is wrong. Configure your text editor to show you tabs\nand spaces differently (e.g. M-x whitespace-mode RET in Emacs). Git uses\ntabs to indent, and only that.\n\nI find the old code much clearer than the new one. This \"name[1] ==\n'\\0'\" looks weird to test if name is the string \".\".\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}