@matheusbsbs / matheus-bagliano / commits / a08c53a119
Fork 0

fsck: Don't require tmp_obj_ file names are 14 bytes in length

Not all temporary file creation routines will ensure 14 bytes are used to generate the temporary file name. In C Git this may be true, but alternate implementations such as jgit are not always able to generate a temporary file name with a specific prefix and also ensure the file name length is 14 bytes long. Since temporary files in a directory we are fsck'ing should be uncommon (as they are short lived only long enough for an active writer to finish writing the file and rename it) we shouldn't see these show up very often. Always using a prefixcmp() call and ignoring the length opens up room for other implementations to use different name generation schemes. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shawn O. Pearce committed Jul 26, 2008 at 21:33 UTC a08c53a119999df5b76e405195fa6c5e7d4b689f
1 file changed +2 -4
builtin-fsck.c
+2 -4
@@ -377,10 +377,6 @@ static void fsck_dir(int i, char *path)
377 if (de->d_name[0] != '.')
378 break;
379 continue;
380 - case 14:
381 - if (prefixcmp(de->d_name, "tmp_obj_"))
382 - break;
383 - continue;
380 case 38:
381 sprintf(name, "%02x", i);
382 memcpy(name+2, de->d_name, len+1);
@@ -389,6 +385,8 @@ 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_"))
389 + continue;
390 fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
391 }
392 closedir(dir);