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.

stephan 2026-10-28 14:59 UTC trunk
Commit 2959c054f7d1b7a97aaf75787149c760379ede316c76958de86cbfa965190058
1 file changed +9 -2
+9 -2
--- src/stash.c
+++ src/stash.c
@@ -190,12 +190,12 @@
190190
);
191191
}
192192
db_prepare(&q, "%s", blob_sql_text(&sql));
193193
blob_reset(&sql);
194194
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)"
197197
"VALUES(%d,:isadd,:isrm,:isexe,:islink,:rid,"
198198
"(SELECT uuid FROM blob WHERE rid=:rid),:orig,:new,:content)",
199199
stashid
200200
);
201201
while( db_step(&q)==SQLITE_ROW ){
@@ -398,10 +398,17 @@
398398
zNew, zOrig, zOrig, filename_collation(), vid
399399
);
400400
}
401401
}
402402
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);
403410
db_finalize(&q);
404411
if( nConflict ){
405412
fossil_print(
406413
"WARNING: %d merge conflicts - see messages above for details.\n",
407414
nConflict);
408415
--- 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

Keyboard Shortcuts

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