worktree: fix worktree add race
[gitweb.git] / builtin / replace.c
index affcdfb4169899c2affee51593f0453d5d9b9add..5b80b7f21141d6f85d8444d669dffe289f3a60f5 100644 (file)
@@ -295,7 +295,7 @@ static int import_object(struct object_id *oid, enum object_type type,
                        close(fd);
                        return -1;
                }
-               if (index_fd(&the_index, oid, fd, &st, type, NULL, flags) < 0)
+               if (index_fd(the_repository->index, oid, fd, &st, type, NULL, flags) < 0)
                        return error(_("unable to write object to database"));
                /* index_fd close()s fd for us */
        }