Commits

Anonymous committed 3d32a46

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>

  • Participants
  • Parent commits 1127c51

Comments (0)

Files changed (2)

File builtin-fsck.c

 			add_sha1_list(sha1, DIRENT_SORT_HINT(de));
 			continue;
 		}
-		if (prefixcmp(de->d_name, "tmp_obj_"))
+		if (!prefixcmp(de->d_name, "tmp_obj_"))
 			continue;
 		fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
 	}

File builtin-prune.c

 			if (de->d_name[0] != '.')
 				break;
 			continue;
-		case 14:
-			if (prefixcmp(de->d_name, "tmp_obj_"))
-				break;
-			prune_tmp_object(path, de->d_name);
-			continue;
 		case 38:
 			sprintf(name, "%02x", i);
 			memcpy(name+2, de->d_name, len+1);
 			prune_object(path, de->d_name, sha1);
 			continue;
 		}
+		if (!prefixcmp(de->d_name, "tmp_obj_")) {
+			prune_tmp_object(path, de->d_name);
+			continue;
+		}
 		fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
 	}
 	if (!show_only)