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@xxxxxxxxxxx> --- Brandon Casey <casey@xxxxxxxxxxxxxxx> wrote: > Since 5723fe7e, temporary objects are now created in their final destination > directories, rather than in .git/objects/. Teach fsck to recognize and > ignore the temporary objects it encounters, and teach prune to remove them. jgit can't exactly follow the 14 character naming rule. This should be a safe way around it. builtin-fsck.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/builtin-fsck.c b/builtin-fsck.c index 7a4a4f1..6eb7da8 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -377,10 +377,6 @@ static void fsck_dir(int i, char *path) if (de->d_name[0] != '.') break; continue; - case 14: - if (prefixcmp(de->d_name, "tmp_obj_")) - break; - continue; case 38: sprintf(name, "%02x", i); memcpy(name+2, de->d_name, len+1); @@ -389,6 +385,8 @@ static void fsck_dir(int i, char *path) add_sha1_list(sha1, DIRENT_SORT_HINT(de)); continue; } + if (prefixcmp(de->d_name, "tmp_obj_")) + continue; fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name); } closedir(dir); -- 1.6.0.rc0.182.gb96c7 -- Shawn. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html