summaryrefslogtreecommitdiff
path: root/builtin-fsck.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2009-01-17 23:05:54 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-01-17 23:05:54 -0800
commit6af384ce73ad880253be5be7587f19f6fe3afcba (patch)
treec63418b88b19af0eb7ca37adfffa49408e57bc79 /builtin-fsck.c
parentMerge branch 'jc/maint-format-patch' (diff)
parentAllow cloning to an existing empty directory (diff)
downloadtgif-6af384ce73ad880253be5be7587f19f6fe3afcba.tar.xz
Merge branch 'ap/clone-into-empty'
* ap/clone-into-empty: Allow cloning to an existing empty directory add is_dot_or_dotdot inline function
Diffstat (limited to 'builtin-fsck.c')
-rw-r--r--builtin-fsck.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 5c4c77adaa..aecc8280a0 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -10,6 +10,7 @@
#include "tree-walk.h"
#include "fsck.h"
#include "parse-options.h"
+#include "dir.h"
#define REACHABLE 0x0001
#define SEEN 0x0002
@@ -395,19 +396,12 @@ static void fsck_dir(int i, char *path)
while ((de = readdir(dir)) != NULL) {
char name[100];
unsigned char sha1[20];
- int len = strlen(de->d_name);
- switch (len) {
- case 2:
- if (de->d_name[1] != '.')
- break;
- case 1:
- if (de->d_name[0] != '.')
- break;
+ if (is_dot_or_dotdot(de->d_name))
continue;
- case 38:
+ if (strlen(de->d_name) == 38) {
sprintf(name, "%02x", i);
- memcpy(name+2, de->d_name, len+1);
+ memcpy(name+2, de->d_name, 39);
if (get_sha1_hex(name, sha1) < 0)
break;
add_sha1_list(sha1, DIRENT_SORT_HINT(de));