Fossil SCM
Changes to the checksum verification steps to allow a partial commit of changes after new files are added to the tree.
Commit
5c74c300b11f2f89da7562adec32a7909f9efe22
Parent
aafd536a5cced06…
1 file changed
+12
-8
+12
-8
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -257,10 +257,12 @@ | ||
| 257 | 257 | ** |
| 258 | 258 | ** This function operates differently if the Global.aCommitFile |
| 259 | 259 | ** variable is not NULL. In that case, the disk image is used for |
| 260 | 260 | ** each file in aCommitFile[] and the repository image (see |
| 261 | 261 | ** vfile_aggregate_checksum_repository() is used for all others). |
| 262 | +** Newly added files that are not contained in the repository are | |
| 263 | +** omitted from the checksum if they are not in Global.aCommitFile. | |
| 262 | 264 | ** |
| 263 | 265 | ** Return the resulting checksum in blob pOut. |
| 264 | 266 | */ |
| 265 | 267 | void vfile_aggregate_checksum_disk(int vid, Blob *pOut){ |
| 266 | 268 | FILE *in; |
| @@ -278,13 +280,12 @@ | ||
| 278 | 280 | while( db_step(&q)==SQLITE_ROW ){ |
| 279 | 281 | const char *zFullpath = db_column_text(&q, 0); |
| 280 | 282 | const char *zName = db_column_text(&q, 1); |
| 281 | 283 | int isSelected = db_column_int(&q, 2); |
| 282 | 284 | |
| 283 | - md5sum_step_text(zName, -1); | |
| 284 | - | |
| 285 | 285 | if( isSelected ){ |
| 286 | + md5sum_step_text(zName, -1); | |
| 286 | 287 | in = fopen(zFullpath,"rb"); |
| 287 | 288 | if( in==0 ){ |
| 288 | 289 | md5sum_step_text(" 0\n", -1); |
| 289 | 290 | continue; |
| 290 | 291 | } |
| @@ -302,16 +303,19 @@ | ||
| 302 | 303 | }else{ |
| 303 | 304 | int rid = db_column_int(&q, 3); |
| 304 | 305 | char zBuf[100]; |
| 305 | 306 | Blob file; |
| 306 | 307 | |
| 307 | - blob_zero(&file); | |
| 308 | - content_get(rid, &file); | |
| 309 | - sprintf(zBuf, " %d\n", blob_size(&file)); | |
| 310 | - md5sum_step_text(zBuf, -1); | |
| 311 | - md5sum_step_blob(&file); | |
| 312 | - blob_reset(&file); | |
| 308 | + if( rid>0 ){ | |
| 309 | + md5sum_step_text(zName, -1); | |
| 310 | + blob_zero(&file); | |
| 311 | + content_get(rid, &file); | |
| 312 | + sprintf(zBuf, " %d\n", blob_size(&file)); | |
| 313 | + md5sum_step_text(zBuf, -1); | |
| 314 | + md5sum_step_blob(&file); | |
| 315 | + blob_reset(&file); | |
| 316 | + } | |
| 313 | 317 | } |
| 314 | 318 | } |
| 315 | 319 | db_finalize(&q); |
| 316 | 320 | md5sum_finish(pOut); |
| 317 | 321 | } |
| 318 | 322 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -257,10 +257,12 @@ | |
| 257 | ** |
| 258 | ** This function operates differently if the Global.aCommitFile |
| 259 | ** variable is not NULL. In that case, the disk image is used for |
| 260 | ** each file in aCommitFile[] and the repository image (see |
| 261 | ** vfile_aggregate_checksum_repository() is used for all others). |
| 262 | ** |
| 263 | ** Return the resulting checksum in blob pOut. |
| 264 | */ |
| 265 | void vfile_aggregate_checksum_disk(int vid, Blob *pOut){ |
| 266 | FILE *in; |
| @@ -278,13 +280,12 @@ | |
| 278 | while( db_step(&q)==SQLITE_ROW ){ |
| 279 | const char *zFullpath = db_column_text(&q, 0); |
| 280 | const char *zName = db_column_text(&q, 1); |
| 281 | int isSelected = db_column_int(&q, 2); |
| 282 | |
| 283 | md5sum_step_text(zName, -1); |
| 284 | |
| 285 | if( isSelected ){ |
| 286 | in = fopen(zFullpath,"rb"); |
| 287 | if( in==0 ){ |
| 288 | md5sum_step_text(" 0\n", -1); |
| 289 | continue; |
| 290 | } |
| @@ -302,16 +303,19 @@ | |
| 302 | }else{ |
| 303 | int rid = db_column_int(&q, 3); |
| 304 | char zBuf[100]; |
| 305 | Blob file; |
| 306 | |
| 307 | blob_zero(&file); |
| 308 | content_get(rid, &file); |
| 309 | sprintf(zBuf, " %d\n", blob_size(&file)); |
| 310 | md5sum_step_text(zBuf, -1); |
| 311 | md5sum_step_blob(&file); |
| 312 | blob_reset(&file); |
| 313 | } |
| 314 | } |
| 315 | db_finalize(&q); |
| 316 | md5sum_finish(pOut); |
| 317 | } |
| 318 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -257,10 +257,12 @@ | |
| 257 | ** |
| 258 | ** This function operates differently if the Global.aCommitFile |
| 259 | ** variable is not NULL. In that case, the disk image is used for |
| 260 | ** each file in aCommitFile[] and the repository image (see |
| 261 | ** vfile_aggregate_checksum_repository() is used for all others). |
| 262 | ** Newly added files that are not contained in the repository are |
| 263 | ** omitted from the checksum if they are not in Global.aCommitFile. |
| 264 | ** |
| 265 | ** Return the resulting checksum in blob pOut. |
| 266 | */ |
| 267 | void vfile_aggregate_checksum_disk(int vid, Blob *pOut){ |
| 268 | FILE *in; |
| @@ -278,13 +280,12 @@ | |
| 280 | while( db_step(&q)==SQLITE_ROW ){ |
| 281 | const char *zFullpath = db_column_text(&q, 0); |
| 282 | const char *zName = db_column_text(&q, 1); |
| 283 | int isSelected = db_column_int(&q, 2); |
| 284 | |
| 285 | if( isSelected ){ |
| 286 | md5sum_step_text(zName, -1); |
| 287 | in = fopen(zFullpath,"rb"); |
| 288 | if( in==0 ){ |
| 289 | md5sum_step_text(" 0\n", -1); |
| 290 | continue; |
| 291 | } |
| @@ -302,16 +303,19 @@ | |
| 303 | }else{ |
| 304 | int rid = db_column_int(&q, 3); |
| 305 | char zBuf[100]; |
| 306 | Blob file; |
| 307 | |
| 308 | if( rid>0 ){ |
| 309 | md5sum_step_text(zName, -1); |
| 310 | blob_zero(&file); |
| 311 | content_get(rid, &file); |
| 312 | sprintf(zBuf, " %d\n", blob_size(&file)); |
| 313 | md5sum_step_text(zBuf, -1); |
| 314 | md5sum_step_blob(&file); |
| 315 | blob_reset(&file); |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | db_finalize(&q); |
| 320 | md5sum_finish(pOut); |
| 321 | } |
| 322 |