Fossil SCM

Made 'fossil commit' detect if the editor changed the file. If the editor did not change the file, ask confirmation, as if it was an empty comment. I think svn behaves this way.

viriketo 2012-04-05 14:31 annotate_links
Commit d2a733beda6cd7d77b594d8249d27cb05458f57f
1 file changed +5 -2
+5 -2
--- src/checkin.c
+++ src/checkin.c
@@ -480,17 +480,20 @@
480480
#if defined(_WIN32)
481481
blob_add_cr(&text);
482482
#endif
483483
blob_write_to_file(&text, zFile);
484484
if( zEditor ){
485
+ i64 original_time;
485486
zCmd = mprintf("%s \"%s\"", zEditor, zFile);
486487
fossil_print("%s\n", zCmd);
488
+ original_time = file_mtime(zFile);
487489
if( fossil_system(zCmd) ){
488490
fossil_panic("editor aborted");
489491
}
490492
blob_reset(&text);
491
- blob_read_from_file(&text, zFile);
493
+ if (file_mtime(zFile) != original_time)
494
+ blob_read_from_file(&text, zFile);
492495
}else{
493496
char zIn[300];
494497
blob_reset(&text);
495498
while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
496499
char *zUtf8 = fossil_mbcs_to_utf8(zIn);
@@ -1115,11 +1118,11 @@
11151118
free(zInit);
11161119
}
11171120
if( blob_size(&comment)==0 ){
11181121
Blob ans;
11191122
blob_zero(&ans);
1120
- prompt_user("empty check-in comment. continue (y/N)? ", &ans);
1123
+ prompt_user("empty/unchanged check-in comment. continue (y/N)? ", &ans);
11211124
if( blob_str(&ans)[0]!='y' ){
11221125
fossil_exit(1);
11231126
}
11241127
}else{
11251128
db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
11261129
--- src/checkin.c
+++ src/checkin.c
@@ -480,17 +480,20 @@
480 #if defined(_WIN32)
481 blob_add_cr(&text);
482 #endif
483 blob_write_to_file(&text, zFile);
484 if( zEditor ){
 
485 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
486 fossil_print("%s\n", zCmd);
 
487 if( fossil_system(zCmd) ){
488 fossil_panic("editor aborted");
489 }
490 blob_reset(&text);
491 blob_read_from_file(&text, zFile);
 
492 }else{
493 char zIn[300];
494 blob_reset(&text);
495 while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
496 char *zUtf8 = fossil_mbcs_to_utf8(zIn);
@@ -1115,11 +1118,11 @@
1115 free(zInit);
1116 }
1117 if( blob_size(&comment)==0 ){
1118 Blob ans;
1119 blob_zero(&ans);
1120 prompt_user("empty check-in comment. continue (y/N)? ", &ans);
1121 if( blob_str(&ans)[0]!='y' ){
1122 fossil_exit(1);
1123 }
1124 }else{
1125 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
1126
--- src/checkin.c
+++ src/checkin.c
@@ -480,17 +480,20 @@
480 #if defined(_WIN32)
481 blob_add_cr(&text);
482 #endif
483 blob_write_to_file(&text, zFile);
484 if( zEditor ){
485 i64 original_time;
486 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
487 fossil_print("%s\n", zCmd);
488 original_time = file_mtime(zFile);
489 if( fossil_system(zCmd) ){
490 fossil_panic("editor aborted");
491 }
492 blob_reset(&text);
493 if (file_mtime(zFile) != original_time)
494 blob_read_from_file(&text, zFile);
495 }else{
496 char zIn[300];
497 blob_reset(&text);
498 while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
499 char *zUtf8 = fossil_mbcs_to_utf8(zIn);
@@ -1115,11 +1118,11 @@
1118 free(zInit);
1119 }
1120 if( blob_size(&comment)==0 ){
1121 Blob ans;
1122 blob_zero(&ans);
1123 prompt_user("empty/unchanged check-in comment. continue (y/N)? ", &ans);
1124 if( blob_str(&ans)[0]!='y' ){
1125 fossil_exit(1);
1126 }
1127 }else{
1128 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
1129

Keyboard Shortcuts

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