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.
Commit
d2a733beda6cd7d77b594d8249d27cb05458f57f
Parent
a610b2567ff944e…
1 file changed
+5
-2
+5
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -480,17 +480,20 @@ | ||
| 480 | 480 | #if defined(_WIN32) |
| 481 | 481 | blob_add_cr(&text); |
| 482 | 482 | #endif |
| 483 | 483 | blob_write_to_file(&text, zFile); |
| 484 | 484 | if( zEditor ){ |
| 485 | + i64 original_time; | |
| 485 | 486 | zCmd = mprintf("%s \"%s\"", zEditor, zFile); |
| 486 | 487 | fossil_print("%s\n", zCmd); |
| 488 | + original_time = file_mtime(zFile); | |
| 487 | 489 | if( fossil_system(zCmd) ){ |
| 488 | 490 | fossil_panic("editor aborted"); |
| 489 | 491 | } |
| 490 | 492 | blob_reset(&text); |
| 491 | - blob_read_from_file(&text, zFile); | |
| 493 | + if (file_mtime(zFile) != original_time) | |
| 494 | + blob_read_from_file(&text, zFile); | |
| 492 | 495 | }else{ |
| 493 | 496 | char zIn[300]; |
| 494 | 497 | blob_reset(&text); |
| 495 | 498 | while( fgets(zIn, sizeof(zIn), stdin)!=0 ){ |
| 496 | 499 | char *zUtf8 = fossil_mbcs_to_utf8(zIn); |
| @@ -1115,11 +1118,11 @@ | ||
| 1115 | 1118 | free(zInit); |
| 1116 | 1119 | } |
| 1117 | 1120 | if( blob_size(&comment)==0 ){ |
| 1118 | 1121 | Blob ans; |
| 1119 | 1122 | 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); | |
| 1121 | 1124 | if( blob_str(&ans)[0]!='y' ){ |
| 1122 | 1125 | fossil_exit(1); |
| 1123 | 1126 | } |
| 1124 | 1127 | }else{ |
| 1125 | 1128 | db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); |
| 1126 | 1129 |
| --- 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 |