Teach fsck and prune that tmp_obj_ file names may not be 14 bytes long
As Shawn pointed out, not all temporary file creation routines can ensure that the generated temporary file is of a certain length. e.g. Java's createTempFile(prefix, suffix). So just depend on the prefix 'tmp_obj_' for detection. Update prune, and fix the "fix" introduced by a08c53a1 :) Signed-off-by: Brandon "appendixless" Casey <casey@nrlssc.navy.mil> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Casey committed
Aug 5, 2008 at 13:01 UTC
3d32a46b247222a97007419fa865efce959b002d
2 files changed
+5
-6
builtin-fsck.c
+1
-1
@@ -385,7 +385,7 @@ static void fsck_dir(int i, char *path)
385
add_sha1_list(sha1, DIRENT_SORT_HINT(de));
386
continue;
387
}
388
- if (prefixcmp(de->d_name, "tmp_obj_"))
388
+ if (!prefixcmp(de->d_name, "tmp_obj_"))
389
continue;
390
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
391
}
builtin-prune.c
+4
-5
@@ -69,11 +69,6 @@ static int prune_dir(int i, char *path)
69
if (de->d_name[0] != '.')
70
break;
71
continue;
72
- case 14:
73
- if (prefixcmp(de->d_name, "tmp_obj_"))
74
- break;
75
- prune_tmp_object(path, de->d_name);
76
- continue;
72
case 38:
73
sprintf(name, "%02x", i);
74
memcpy(name+2, de->d_name, len+1);
@@ -90,6 +85,10 @@ static int prune_dir(int i, char *path)
85
prune_object(path, de->d_name, sha1);
86
continue;
87
}
88
+ if (!prefixcmp(de->d_name, "tmp_obj_")) {
89
+ prune_tmp_object(path, de->d_name);
90
+ continue;
91
+ }
92
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
93
}
94
if (!show_only)