From: Junio C Hamano Date: Sun, 18 Jan 2009 07:05:54 +0000 (-0800) Subject: Merge branch 'ap/clone-into-empty' X-Git-Tag: v1.6.2-rc0~137 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6af384ce73ad880253be5be7587f19f6fe3afcba?ds=inline;hp=-c Merge branch 'ap/clone-into-empty' * ap/clone-into-empty: Allow cloning to an existing empty directory add is_dot_or_dotdot inline function --- 6af384ce73ad880253be5be7587f19f6fe3afcba diff --combined builtin-fsck.c index 5c4c77adaa,79b87edaf9..aecc8280a0 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@@ -10,6 -10,7 +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 +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)); @@@ -628,7 -622,7 +622,7 @@@ int cmd_fsck(int argc, const char **arg } heads = 0; - for (i = 1; i < argc; i++) { + for (i = 0; i < argc; i++) { const char *arg = argv[i]; if (!get_sha1(arg, head_sha1)) { struct object *obj = lookup_object(head_sha1);