@@ -1357,6 +1357,9 @@ static int want_found_object(const struct object_id *oid, int exclude,
1357
1357
if (incremental )
1358
1358
return 0 ;
1359
1359
1360
+ if (!is_pack_valid (p ))
1361
+ return -1 ;
1362
+
1360
1363
/*
1361
1364
* When asked to do --local (do not include an object that appears in a
1362
1365
* pack we borrow from elsewhere) or --honor-pack-keep (do not include
@@ -1472,6 +1475,9 @@ static int want_object_in_pack(const struct object_id *oid,
1472
1475
want = want_found_object (oid , exclude , * found_pack );
1473
1476
if (want != -1 )
1474
1477
return want ;
1478
+
1479
+ * found_pack = NULL ;
1480
+ * found_offset = 0 ;
1475
1481
}
1476
1482
1477
1483
for (m = get_multi_pack_index (the_repository ); m ; m = m -> next ) {
@@ -3201,10 +3207,8 @@ static int add_object_entry_from_pack(const struct object_id *oid,
3201
3207
uint32_t pos ,
3202
3208
void * _data )
3203
3209
{
3204
- struct rev_info * revs = _data ;
3205
- struct object_info oi = OBJECT_INFO_INIT ;
3206
3210
off_t ofs ;
3207
- enum object_type type ;
3211
+ enum object_type type = OBJ_NONE ;
3208
3212
3209
3213
display_progress (progress_state , ++ nr_seen );
3210
3214
@@ -3215,19 +3219,24 @@ static int add_object_entry_from_pack(const struct object_id *oid,
3215
3219
if (!want_object_in_pack (oid , 0 , & p , & ofs ))
3216
3220
return 0 ;
3217
3221
3218
- oi .typep = & type ;
3219
- if (packed_object_info (the_repository , p , ofs , & oi ) < 0 )
3220
- die (_ ("could not get type of object %s in pack %s" ),
3221
- oid_to_hex (oid ), p -> pack_name );
3222
- else if (type == OBJ_COMMIT ) {
3223
- /*
3224
- * commits in included packs are used as starting points for the
3225
- * subsequent revision walk
3226
- */
3227
- add_pending_oid (revs , NULL , oid , 0 );
3228
- }
3222
+ if (p ) {
3223
+ struct rev_info * revs = _data ;
3224
+ struct object_info oi = OBJECT_INFO_INIT ;
3225
+
3226
+ oi .typep = & type ;
3227
+ if (packed_object_info (the_repository , p , ofs , & oi ) < 0 ) {
3228
+ die (_ ("could not get type of object %s in pack %s" ),
3229
+ oid_to_hex (oid ), p -> pack_name );
3230
+ } else if (type == OBJ_COMMIT ) {
3231
+ /*
3232
+ * commits in included packs are used as starting points for the
3233
+ * subsequent revision walk
3234
+ */
3235
+ add_pending_oid (revs , NULL , oid , 0 );
3236
+ }
3229
3237
3230
- stdin_packs_found_nr ++ ;
3238
+ stdin_packs_found_nr ++ ;
3239
+ }
3231
3240
3232
3241
create_object_entry (oid , type , 0 , 0 , 0 , p , ofs );
3233
3242
@@ -3346,6 +3355,8 @@ static void read_packs_list_from_stdin(void)
3346
3355
struct packed_git * p = item -> util ;
3347
3356
if (!p )
3348
3357
die (_ ("could not find pack '%s'" ), item -> string );
3358
+ if (!is_pack_valid (p ))
3359
+ die (_ ("packfile %s cannot be accessed" ), p -> pack_name );
3349
3360
}
3350
3361
3351
3362
/*
@@ -3369,8 +3380,6 @@ static void read_packs_list_from_stdin(void)
3369
3380
3370
3381
for_each_string_list_item (item , & include_packs ) {
3371
3382
struct packed_git * p = item -> util ;
3372
- if (!p )
3373
- die (_ ("could not find pack '%s'" ), item -> string );
3374
3383
for_each_object_in_pack (p ,
3375
3384
add_object_entry_from_pack ,
3376
3385
& revs ,
0 commit comments