Fossil SCM
Two minor stash fixes: (A) passing both a file and its dir caused the entry to violate a unique constraint. (B) stash apply now sets the vfile.mtime of stashed files to 0 (as stash goto does) to avoid a corner case when a same-sized file is reverted but not recognized as modified. These were found by Dan Mestas in his testing of libfossil's upcoming stash support.
Commit
2959c054f7d1b7a97aaf75787149c760379ede316c76958de86cbfa965190058
Parent
bb14723b0120096…
1 file changed
+9
-2
+9
-2
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -190,12 +190,12 @@ | ||
| 190 | 190 | ); |
| 191 | 191 | } |
| 192 | 192 | db_prepare(&q, "%s", blob_sql_text(&sql)); |
| 193 | 193 | blob_reset(&sql); |
| 194 | 194 | db_prepare(&ins, |
| 195 | - "INSERT INTO stashfile(stashid, isAdded, isRemoved, isExec, isLink, rid, " | |
| 196 | - "hash, origname, newname, delta)" | |
| 195 | + "INSERT OR IGNORE INTO stashfile(stashid, isAdded, isRemoved, isExec, " | |
| 196 | + "isLink, rid, hash, origname, newname, delta)" | |
| 197 | 197 | "VALUES(%d,:isadd,:isrm,:isexe,:islink,:rid," |
| 198 | 198 | "(SELECT uuid FROM blob WHERE rid=:rid),:orig,:new,:content)", |
| 199 | 199 | stashid |
| 200 | 200 | ); |
| 201 | 201 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -398,10 +398,17 @@ | ||
| 398 | 398 | zNew, zOrig, zOrig, filename_collation(), vid |
| 399 | 399 | ); |
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | stash_add_files_in_sfile(vid); |
| 403 | + /* Clear the recorded mtimes of the stashed files, as (stash goto) | |
| 404 | + ** does, so that the next change check is forced to hash them, to | |
| 405 | + ** avoid that a same-size file written in the same second as the | |
| 406 | + ** last revert looks unchanged. */ | |
| 407 | + db_multi_exec("UPDATE vfile SET mtime=0 WHERE pathname IN " | |
| 408 | + "(SELECT newname FROM stashfile WHERE stashid=%d)", | |
| 409 | + stashid); | |
| 403 | 410 | db_finalize(&q); |
| 404 | 411 | if( nConflict ){ |
| 405 | 412 | fossil_print( |
| 406 | 413 | "WARNING: %d merge conflicts - see messages above for details.\n", |
| 407 | 414 | nConflict); |
| 408 | 415 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -190,12 +190,12 @@ | |
| 190 | ); |
| 191 | } |
| 192 | db_prepare(&q, "%s", blob_sql_text(&sql)); |
| 193 | blob_reset(&sql); |
| 194 | db_prepare(&ins, |
| 195 | "INSERT INTO stashfile(stashid, isAdded, isRemoved, isExec, isLink, rid, " |
| 196 | "hash, origname, newname, delta)" |
| 197 | "VALUES(%d,:isadd,:isrm,:isexe,:islink,:rid," |
| 198 | "(SELECT uuid FROM blob WHERE rid=:rid),:orig,:new,:content)", |
| 199 | stashid |
| 200 | ); |
| 201 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -398,10 +398,17 @@ | |
| 398 | zNew, zOrig, zOrig, filename_collation(), vid |
| 399 | ); |
| 400 | } |
| 401 | } |
| 402 | stash_add_files_in_sfile(vid); |
| 403 | db_finalize(&q); |
| 404 | if( nConflict ){ |
| 405 | fossil_print( |
| 406 | "WARNING: %d merge conflicts - see messages above for details.\n", |
| 407 | nConflict); |
| 408 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -190,12 +190,12 @@ | |
| 190 | ); |
| 191 | } |
| 192 | db_prepare(&q, "%s", blob_sql_text(&sql)); |
| 193 | blob_reset(&sql); |
| 194 | db_prepare(&ins, |
| 195 | "INSERT OR IGNORE INTO stashfile(stashid, isAdded, isRemoved, isExec, " |
| 196 | "isLink, rid, hash, origname, newname, delta)" |
| 197 | "VALUES(%d,:isadd,:isrm,:isexe,:islink,:rid," |
| 198 | "(SELECT uuid FROM blob WHERE rid=:rid),:orig,:new,:content)", |
| 199 | stashid |
| 200 | ); |
| 201 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -398,10 +398,17 @@ | |
| 398 | zNew, zOrig, zOrig, filename_collation(), vid |
| 399 | ); |
| 400 | } |
| 401 | } |
| 402 | stash_add_files_in_sfile(vid); |
| 403 | /* Clear the recorded mtimes of the stashed files, as (stash goto) |
| 404 | ** does, so that the next change check is forced to hash them, to |
| 405 | ** avoid that a same-size file written in the same second as the |
| 406 | ** last revert looks unchanged. */ |
| 407 | db_multi_exec("UPDATE vfile SET mtime=0 WHERE pathname IN " |
| 408 | "(SELECT newname FROM stashfile WHERE stashid=%d)", |
| 409 | stashid); |
| 410 | db_finalize(&q); |
| 411 | if( nConflict ){ |
| 412 | fossil_print( |
| 413 | "WARNING: %d merge conflicts - see messages above for details.\n", |
| 414 | nConflict); |
| 415 |