* [PATCH v5] fsck.c: fsck_tree() now use is_dot_or_dotdot().
@ 2014-03-19 16:08 Andrei Dinu
2014-03-19 17:51 ` Matthieu Moy
0 siblings, 1 reply; 2+ messages in thread
From: Andrei Dinu @ 2014-03-19 16:08 UTC (permalink / raw)
To: git; +Cc: Andrei Dinu
Rewrite fsck_tree() to use is_dot_or_dotdot() from "dir.h".
Signed-off-by: Andrei Dinu <mandrei.dinu@gmail.com>
---
I try to find other sites that can use id_dot_or_dotdot() function.
fsck.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/fsck.c b/fsck.c
index 64bf279..82a55ab 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] == '\0')
+ has_dot = 1;
+ else
+ has_dotdot = 1;
+ }
if (!strcmp(name, ".git"))
has_dotgit = 1;
has_zero_pad |= *(char *)desc.buffer == '0';
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v5] fsck.c: fsck_tree() now use is_dot_or_dotdot().
2014-03-19 16:08 [PATCH v5] fsck.c: fsck_tree() now use is_dot_or_dotdot() Andrei Dinu
@ 2014-03-19 17:51 ` Matthieu Moy
0 siblings, 0 replies; 2+ messages in thread
From: Matthieu Moy @ 2014-03-19 17:51 UTC (permalink / raw)
To: Andrei Dinu; +Cc: git
Andrei Dinu <mandrei.dinu@gmail.com> writes:
> ---
> I try to find other sites that can use id_dot_or_dotdot() function.
This should also have been sent in the same series.
> @@ -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] == '\0')
> + has_dot = 1;
> + else
> + has_dotdot = 1;
> + }
The indentation is wrong. Configure your text editor to show you tabs
and spaces differently (e.g. M-x whitespace-mode RET in Emacs). Git uses
tabs to indent, and only that.
I find the old code much clearer than the new one. This "name[1] ==
'\0'" looks weird to test if name is the string ".".
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-19 17:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-19 16:08 [PATCH v5] fsck.c: fsck_tree() now use is_dot_or_dotdot() Andrei Dinu
2014-03-19 17:51 ` Matthieu Moy
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).