Fossil SCM

Check hash if mtime matches system time at the time we started checking.

preben 2024-01-08 13:11 hash-if-mtime-is-current
Commit f0aa85e302ee674e473d3bbcbaaad281881bde84698919ffb3995957a5aea0ce
1 file changed +4 -2
+4 -2
--- src/vfile.c
+++ src/vfile.c
@@ -171,10 +171,11 @@
171171
** If the mtime of a file has changed, we still examine the on-disk content
172172
** to see whether or not the edit was a null-edit.
173173
*/
174174
void vfile_check_signature(int vid, unsigned int cksigFlags){
175175
int nErr = 0;
176
+ time_t now = time(0);
176177
Stmt q;
177178
int useMtime = (cksigFlags & CKSIG_HASH)==0
178179
&& db_get_boolean("mtime-changes", 1);
179180
180181
db_begin_transaction();
@@ -233,15 +234,16 @@
233234
const char *zUuid = db_column_text(&q, 5);
234235
int nUuid = db_column_bytes(&q, 5);
235236
assert( origSize==currentSize );
236237
if( hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 0;
237238
}else if( (chnged==0 || chnged==2 || chnged==4)
238
- && (useMtime==0 || currentMtime!=oldMtime || currentMtime==time(0)) ){
239
+ && (useMtime==0 || currentMtime!=oldMtime || oldMtime==now) ){
239240
/* For files that were formerly believed to be unchanged or that were
240241
** changed by merging, if their mtime changes, or unconditionally
241242
** if --hash is used, check to see if they have been edited by
242
- ** looking at their artifact hashes */
243
+ ** looking at their artifact hashes. Also check if mtime is current
244
+ ** in case a commit took place the same clock second checks started. */
243245
const char *zUuid = db_column_text(&q, 5);
244246
int nUuid = db_column_bytes(&q, 5);
245247
assert( origSize==currentSize );
246248
if( !hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 1;
247249
}
248250
--- src/vfile.c
+++ src/vfile.c
@@ -171,10 +171,11 @@
171 ** If the mtime of a file has changed, we still examine the on-disk content
172 ** to see whether or not the edit was a null-edit.
173 */
174 void vfile_check_signature(int vid, unsigned int cksigFlags){
175 int nErr = 0;
 
176 Stmt q;
177 int useMtime = (cksigFlags & CKSIG_HASH)==0
178 && db_get_boolean("mtime-changes", 1);
179
180 db_begin_transaction();
@@ -233,15 +234,16 @@
233 const char *zUuid = db_column_text(&q, 5);
234 int nUuid = db_column_bytes(&q, 5);
235 assert( origSize==currentSize );
236 if( hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 0;
237 }else if( (chnged==0 || chnged==2 || chnged==4)
238 && (useMtime==0 || currentMtime!=oldMtime || currentMtime==time(0)) ){
239 /* For files that were formerly believed to be unchanged or that were
240 ** changed by merging, if their mtime changes, or unconditionally
241 ** if --hash is used, check to see if they have been edited by
242 ** looking at their artifact hashes */
 
243 const char *zUuid = db_column_text(&q, 5);
244 int nUuid = db_column_bytes(&q, 5);
245 assert( origSize==currentSize );
246 if( !hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 1;
247 }
248
--- src/vfile.c
+++ src/vfile.c
@@ -171,10 +171,11 @@
171 ** If the mtime of a file has changed, we still examine the on-disk content
172 ** to see whether or not the edit was a null-edit.
173 */
174 void vfile_check_signature(int vid, unsigned int cksigFlags){
175 int nErr = 0;
176 time_t now = time(0);
177 Stmt q;
178 int useMtime = (cksigFlags & CKSIG_HASH)==0
179 && db_get_boolean("mtime-changes", 1);
180
181 db_begin_transaction();
@@ -233,15 +234,16 @@
234 const char *zUuid = db_column_text(&q, 5);
235 int nUuid = db_column_bytes(&q, 5);
236 assert( origSize==currentSize );
237 if( hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 0;
238 }else if( (chnged==0 || chnged==2 || chnged==4)
239 && (useMtime==0 || currentMtime!=oldMtime || oldMtime==now) ){
240 /* For files that were formerly believed to be unchanged or that were
241 ** changed by merging, if their mtime changes, or unconditionally
242 ** if --hash is used, check to see if they have been edited by
243 ** looking at their artifact hashes. Also check if mtime is current
244 ** in case a commit took place the same clock second checks started. */
245 const char *zUuid = db_column_text(&q, 5);
246 int nUuid = db_column_bytes(&q, 5);
247 assert( origSize==currentSize );
248 if( !hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 1;
249 }
250

Keyboard Shortcuts

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