Skip to content

Commit a4880b2

Browse files
peffgitster
authored andcommitted
repack: expand error message for missing pack files
If pack-objects tells us it generated pack $hash, we expect to find .tmp-$$-pack-$hash.pack, .idx, .rev, and so on. Some of these files are optional, but others are not. For the required ones, we'll bail with an error if any of them is missing. The error message is just "missing required file", which is a bit vague. We should be more clear that it is not the user's fault, but rather that the sub-pgoram we called is not operating as expected. In practice, nobody should ever see this message, as it would generally only be caused by a bug in Git. It probably doesn't make sense to convert this to a BUG(), though, as there are other (unlikely) possibilities, such as somebody else racily deleting the files, filesystem errors causing stat() to fail, and so on. A nice side effect here is that we stop relying on fname_old in this code path, which will let us deal with it only in the first part of the conditional. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b639606 commit a4880b2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/repack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
10301030
if (rename(fname_old, fname))
10311031
die_errno(_("renaming '%s' failed"), fname_old);
10321032
} else if (!exts[ext].optional)
1033-
die(_("missing required file: %s"), fname_old);
1033+
die(_("pack-objects did not write a '%s' file for pack %s-%s"),
1034+
exts[ext].name, packtmp, item->string);
10341035
else if (unlink(fname) < 0 && errno != ENOENT)
10351036
die_errno(_("could not unlink: %s"), fname);
10361037

0 commit comments

Comments
 (0)