Fossil SCM

Changes to the checksum verification steps to allow a partial commit of changes after new files are added to the tree.

drh 2007-08-04 00:38 trunk
Commit 5c74c300b11f2f89da7562adec32a7909f9efe22
1 file changed +12 -8
+12 -8
--- src/vfile.c
+++ src/vfile.c
@@ -257,10 +257,12 @@
257257
**
258258
** This function operates differently if the Global.aCommitFile
259259
** variable is not NULL. In that case, the disk image is used for
260260
** each file in aCommitFile[] and the repository image (see
261261
** 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.
262264
**
263265
** Return the resulting checksum in blob pOut.
264266
*/
265267
void vfile_aggregate_checksum_disk(int vid, Blob *pOut){
266268
FILE *in;
@@ -278,13 +280,12 @@
278280
while( db_step(&q)==SQLITE_ROW ){
279281
const char *zFullpath = db_column_text(&q, 0);
280282
const char *zName = db_column_text(&q, 1);
281283
int isSelected = db_column_int(&q, 2);
282284
283
- md5sum_step_text(zName, -1);
284
-
285285
if( isSelected ){
286
+ md5sum_step_text(zName, -1);
286287
in = fopen(zFullpath,"rb");
287288
if( in==0 ){
288289
md5sum_step_text(" 0\n", -1);
289290
continue;
290291
}
@@ -302,16 +303,19 @@
302303
}else{
303304
int rid = db_column_int(&q, 3);
304305
char zBuf[100];
305306
Blob file;
306307
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
+ }
313317
}
314318
}
315319
db_finalize(&q);
316320
md5sum_finish(pOut);
317321
}
318322
--- 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

Keyboard Shortcuts

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