@@ -1064,7 +1064,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1064
1064
int bitmapped_packs_concat_len = 0 ;
1065
1065
int pack_name_concat_len = 0 ;
1066
1066
int dropped_packs = 0 ;
1067
- int result = 0 ;
1067
+ int result = -1 ;
1068
1068
const char * * keep_hashes = NULL ;
1069
1069
struct chunkfile * cf ;
1070
1070
@@ -1117,14 +1117,12 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1117
1117
error (_ ("could not load reverse index for MIDX %s" ),
1118
1118
hash_to_hex_algop (get_midx_checksum (m ),
1119
1119
m -> repo -> hash_algo ));
1120
- result = 1 ;
1121
1120
goto cleanup ;
1122
1121
}
1123
1122
ctx .num_multi_pack_indexes_before ++ ;
1124
1123
m = m -> base_midx ;
1125
1124
}
1126
1125
} else if (ctx .m && fill_packs_from_midx (& ctx )) {
1127
- result = 1 ;
1128
1126
goto cleanup ;
1129
1127
}
1130
1128
@@ -1160,12 +1158,16 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1160
1158
*/
1161
1159
if (!want_bitmap )
1162
1160
clear_midx_files_ext (object_dir , "bitmap" , NULL );
1161
+
1162
+ result = 0 ;
1163
1163
goto cleanup ;
1164
1164
}
1165
1165
}
1166
1166
1167
- if (ctx .incremental && !ctx .nr )
1167
+ if (ctx .incremental && !ctx .nr ) {
1168
+ result = 0 ;
1168
1169
goto cleanup ; /* nothing to do */
1170
+ }
1169
1171
1170
1172
if (preferred_pack_name ) {
1171
1173
ctx .preferred_pack_idx = NO_PREFERRED_PACK ;
@@ -1239,7 +1241,6 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1239
1241
if (!preferred -> num_objects ) {
1240
1242
error (_ ("cannot select preferred pack %s with no objects" ),
1241
1243
preferred -> pack_name );
1242
- result = 1 ;
1243
1244
goto cleanup ;
1244
1245
}
1245
1246
}
@@ -1278,10 +1279,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1278
1279
}
1279
1280
}
1280
1281
1281
- if (missing_drops ) {
1282
- result = 1 ;
1282
+ if (missing_drops )
1283
1283
goto cleanup ;
1284
- }
1285
1284
}
1286
1285
1287
1286
/*
@@ -1327,7 +1326,6 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1327
1326
1328
1327
if (ctx .nr - dropped_packs == 0 ) {
1329
1328
error (_ ("no pack files to index." ));
1330
- result = 1 ;
1331
1329
goto cleanup ;
1332
1330
}
1333
1331
@@ -1347,14 +1345,12 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1347
1345
incr = mks_tempfile_m (midx_name .buf , 0444 );
1348
1346
if (!incr ) {
1349
1347
error (_ ("unable to create temporary MIDX layer" ));
1350
- result = -1 ;
1351
1348
goto cleanup ;
1352
1349
}
1353
1350
1354
1351
if (adjust_shared_perm (r , get_tempfile_path (incr ))) {
1355
1352
error (_ ("unable to adjust shared permissions for '%s'" ),
1356
1353
get_tempfile_path (incr ));
1357
- result = -1 ;
1358
1354
goto cleanup ;
1359
1355
}
1360
1356
@@ -1432,7 +1428,6 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1432
1428
midx_hash , & pdata , commits , commits_nr ,
1433
1429
flags ) < 0 ) {
1434
1430
error (_ ("could not write multi-pack bitmap" ));
1435
- result = 1 ;
1436
1431
clear_packing_data (& pdata );
1437
1432
free (commits );
1438
1433
goto cleanup ;
@@ -1458,21 +1453,17 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1458
1453
1459
1454
if (!chainf ) {
1460
1455
error_errno (_ ("unable to open multi-pack-index chain file" ));
1461
- result = -1 ;
1462
1456
goto cleanup ;
1463
1457
}
1464
1458
1465
- if (link_midx_to_chain (ctx .base_midx ) < 0 ) {
1466
- result = -1 ;
1459
+ if (link_midx_to_chain (ctx .base_midx ) < 0 )
1467
1460
goto cleanup ;
1468
- }
1469
1461
1470
1462
get_split_midx_filename_ext (r -> hash_algo , & final_midx_name ,
1471
1463
object_dir , midx_hash , MIDX_EXT_MIDX );
1472
1464
1473
1465
if (rename_tempfile (& incr , final_midx_name .buf ) < 0 ) {
1474
1466
error_errno (_ ("unable to rename new multi-pack-index layer" ));
1475
- result = -1 ;
1476
1467
goto cleanup ;
1477
1468
}
1478
1469
@@ -1505,6 +1496,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1505
1496
clear_midx_files (r , object_dir , keep_hashes ,
1506
1497
ctx .num_multi_pack_indexes_before + 1 ,
1507
1498
ctx .incremental );
1499
+ result = 0 ;
1508
1500
1509
1501
cleanup :
1510
1502
for (size_t i = 0 ; i < ctx .nr ; i ++ ) {
0 commit comments