Fossil SCM

Fix a corner case of the import command which could leave behind a phantom. Based on [forum:2026-09-28T10:22:05Z|bug report 2026-09-28T10:22:05Z].

stephan 2026-09-28 16:40 UTC trunk
Commit 7f366c872c8c6f459dadfe037b9ea137f1bf292c5f5aa0ac2051fbc5b815b897
1 file changed +18 -1
+18 -1
--- src/bundle.c
+++ src/bundle.c
@@ -458,10 +458,23 @@
458458
blob_reset(&basis);
459459
blob_reset(&c1);
460460
}else if( pBasis ){
461461
blob_delta_apply(pBasis, &c1, &c2);
462462
blob_reset(&c1);
463
+ }else if( db_column_type(&q,2)==SQLITE_INTEGER ){
464
+ /* This is a delta against another bundle entry which was not
465
+ ** imported because the repository already has it. Use the
466
+ ** repository's copy. [forum:2629a1deaa] */
467
+ Blob basis;
468
+ rid = db_int(0,"SELECT rid FROM blob, bblob"
469
+ " WHERE bblob.blobid=%d"
470
+ " AND blob.uuid=bblob.uuid",
471
+ db_column_int(&q,2));
472
+ content_get(rid, &basis);
473
+ blob_delta_apply(&basis, &c1, &c2);
474
+ blob_reset(&basis);
475
+ blob_reset(&c1);
463476
}else{
464477
c2 = c1;
465478
}
466479
if( hname_verify_hash(&c2, blob_buffer(&h1), blob_size(&h1))==0 ){
467480
fossil_fatal("artifact hash error on %b", &h1);
@@ -611,11 +624,15 @@
611624
"INSERT INTO bix(blobid,delta)"
612625
" SELECT blobid,"
613626
" CASE WHEN typeof(delta)=='integer'"
614627
" THEN delta ELSE 0 END"
615628
" FROM bblob"
616
- " WHERE NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.uuid AND size>=0);"
629
+ " WHERE NOT EXISTS("
630
+ " SELECT 1 FROM blob WHERE uuid=bblob.uuid AND size>=0"
631
+ " );"
632
+ "UPDATE bix SET delta=0"
633
+ " WHERE delta>0 AND delta NOT IN (SELECT blobid FROM bix);"
617634
"CREATE TEMP TABLE got(rid INTEGER PRIMARY KEY ON CONFLICT IGNORE);"
618635
);
619636
manifest_crosslink_begin();
620637
bundle_import_elements(0, 0, isPriv);
621638
manifest_crosslink_end(0);
622639
--- src/bundle.c
+++ src/bundle.c
@@ -458,10 +458,23 @@
458 blob_reset(&basis);
459 blob_reset(&c1);
460 }else if( pBasis ){
461 blob_delta_apply(pBasis, &c1, &c2);
462 blob_reset(&c1);
 
 
 
 
 
 
 
 
 
 
 
 
 
463 }else{
464 c2 = c1;
465 }
466 if( hname_verify_hash(&c2, blob_buffer(&h1), blob_size(&h1))==0 ){
467 fossil_fatal("artifact hash error on %b", &h1);
@@ -611,11 +624,15 @@
611 "INSERT INTO bix(blobid,delta)"
612 " SELECT blobid,"
613 " CASE WHEN typeof(delta)=='integer'"
614 " THEN delta ELSE 0 END"
615 " FROM bblob"
616 " WHERE NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.uuid AND size>=0);"
 
 
 
 
617 "CREATE TEMP TABLE got(rid INTEGER PRIMARY KEY ON CONFLICT IGNORE);"
618 );
619 manifest_crosslink_begin();
620 bundle_import_elements(0, 0, isPriv);
621 manifest_crosslink_end(0);
622
--- src/bundle.c
+++ src/bundle.c
@@ -458,10 +458,23 @@
458 blob_reset(&basis);
459 blob_reset(&c1);
460 }else if( pBasis ){
461 blob_delta_apply(pBasis, &c1, &c2);
462 blob_reset(&c1);
463 }else if( db_column_type(&q,2)==SQLITE_INTEGER ){
464 /* This is a delta against another bundle entry which was not
465 ** imported because the repository already has it. Use the
466 ** repository's copy. [forum:2629a1deaa] */
467 Blob basis;
468 rid = db_int(0,"SELECT rid FROM blob, bblob"
469 " WHERE bblob.blobid=%d"
470 " AND blob.uuid=bblob.uuid",
471 db_column_int(&q,2));
472 content_get(rid, &basis);
473 blob_delta_apply(&basis, &c1, &c2);
474 blob_reset(&basis);
475 blob_reset(&c1);
476 }else{
477 c2 = c1;
478 }
479 if( hname_verify_hash(&c2, blob_buffer(&h1), blob_size(&h1))==0 ){
480 fossil_fatal("artifact hash error on %b", &h1);
@@ -611,11 +624,15 @@
624 "INSERT INTO bix(blobid,delta)"
625 " SELECT blobid,"
626 " CASE WHEN typeof(delta)=='integer'"
627 " THEN delta ELSE 0 END"
628 " FROM bblob"
629 " WHERE NOT EXISTS("
630 " SELECT 1 FROM blob WHERE uuid=bblob.uuid AND size>=0"
631 " );"
632 "UPDATE bix SET delta=0"
633 " WHERE delta>0 AND delta NOT IN (SELECT blobid FROM bix);"
634 "CREATE TEMP TABLE got(rid INTEGER PRIMARY KEY ON CONFLICT IGNORE);"
635 );
636 manifest_crosslink_begin();
637 bundle_import_elements(0, 0, isPriv);
638 manifest_crosslink_end(0);
639

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button