Skip to content

Commit b5f9211

Browse files
authored
gvfs: clear DIE_IF_CORRUPT in streaming incore fallback (#873)
The upstream refactoring in 4c89d31 (streaming: rely on object sources to create object stream, 2025-11-23) changed how istream_source() discovers objects. Previously, it called odb_read_object_info_extended() with flags=0 to locate the object, then tried the source-specific opener (e.g. open_istream_loose). If that failed (e.g. corrupt loose object), it fell back to open_istream_incore which re-read the object — by which time the read-object hook had already re-fetched a clean copy. After the refactoring, istream_source() iterates over sources directly. When a corrupt loose object is found, odb_source_loose_read_object_stream fails and the loop continues to the next source. When no source has the object, it falls through to open_istream_incore, which calls odb_read_object_info_extended with OBJECT_INFO_DIE_IF_CORRUPT. This encounters the same corrupt loose file still on disk and dies before the read-object hook gets a chance to re-download a clean replacement. Fix this by clearing OBJECT_INFO_DIE_IF_CORRUPT in open_istream_incore when GVFS_MISSING_OK is set, matching the existing pattern in odb_read_object. This fixes the GitCorruptObjectTests functional test failures (GitRequestsReplacementForAllNullObject, GitRequestsReplacementForObjectCorruptedWithBadData, GitRequestsReplacementForTruncatedObject) that appeared when upgrading from v2.50.1.vfs.0.1 to v2.53.0.vfs.0.0. This is a companion to #782 (which predates 4c89d31, though, therefore it is not _exactly_ an omission of that PR).
2 parents e586f99 + df1cca4 commit b5f9211

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

odb/streaming.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "environment.h"
88
#include "repository.h"
99
#include "object-file.h"
10+
#include "gvfs.h"
1011
#include "odb.h"
1112
#include "odb/streaming.h"
1213
#include "replace-object.h"
@@ -158,13 +159,14 @@ static int open_istream_incore(struct odb_read_stream **out,
158159
.base.read = read_istream_incore,
159160
};
160161
struct odb_incore_read_stream *st;
162+
unsigned flags = gvfs_config_is_set(odb->repo, GVFS_MISSING_OK) ?
163+
0 : OBJECT_INFO_DIE_IF_CORRUPT;
161164
int ret;
162165

163166
oi.typep = &stream.base.type;
164167
oi.sizep = &stream.base.size;
165168
oi.contentp = (void **)&stream.buf;
166-
ret = odb_read_object_info_extended(odb, oid, &oi,
167-
OBJECT_INFO_DIE_IF_CORRUPT);
169+
ret = odb_read_object_info_extended(odb, oid, &oi, flags);
168170
if (ret)
169171
return ret;
170172

0 commit comments

Comments
 (0)