]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-file: don't special-case missing source file in collision check
authorPatrick Steinhardt <ps@pks.im>
Mon, 6 Jan 2025 09:24:26 +0000 (10:24 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Jan 2025 15:57:17 +0000 (07:57 -0800)
In 0ad3d65652 (object-file: fix race in object collision check,
2024-12-30) we have started to ignore ENOENT when opening either the
source or destination file of the collision check. This was done to
handle races more gracefully in case either of the potentially-colliding
disappears.

The fix is overly broad though: while the destination file may indeed
vanish racily, this shouldn't ever happen for the source file, which is
a temporary object file (either loose or in packfile format) that we
have just created. So if any concurrent process would have removed that
temporary file it would indicate an actual issue.

Stop treating ENOENT specially for the source file so that we always
bubble up this error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-file.c

index e2fa1be303cce35259e9fab1c3ad8c11c84b0aa6..c1bd746d9e238e0cf4a9b8d9a6153d001380dd34 100644 (file)
@@ -1982,8 +1982,7 @@ static int check_collision(const char *source, const char *dest)
 
        fd_source = open(source, O_RDONLY);
        if (fd_source < 0) {
-               if (errno != ENOENT)
-                       ret = error_errno(_("unable to open %s"), source);
+               ret = error_errno(_("unable to open %s"), source);
                goto out;
        }