Fossil SCM

Verify the checkin comment for "fossil commit" even if provide by the -m or the -M options. Add the --allow-suspect-comment to override this step.

drh 2025-03-16 18:06 trunk
Commit 19fc9713fccfed79f7e6f97cdcea58ac37215c264bdbc7b9c06eb6f844414b7f
1 file changed +17 -5
+17 -5
--- src/checkin.c
+++ src/checkin.c
@@ -2296,10 +2296,11 @@
22962296
char *zSep;
22972297
char cSave1;
22982298
int nIssue = 0;
22992299
23002300
z = zStart;
2301
+ blob_init(pSus, 0, 0);
23012302
while( (z = strchr(z,'['))!=0 ){
23022303
zEnd = strchr(z,']');
23032304
if( zEnd==0 ){
23042305
blob_appendf(pSus,"\n (%d) ", ++nIssue);
23052306
blob_appendf(pSus, "Unterminated hyperlink \"%.12s...\"", z);
@@ -2325,13 +2326,11 @@
23252326
}
23262327
if( nIssue ){
23272328
Blob tmp = *pSus;
23282329
blob_init(pSus, 0, 0);
23292330
blob_appendf(pSus,
2330
- "Possible comment formatting error%s:"
2331
- "%b\n"
2332
- "Edit, continue, or abort (E/c/a)? ",
2331
+ "Possible comment formatting error%s:%b\n",
23332332
nIssue>1 ? "s" : "", &tmp);
23342333
blob_reset(&tmp);
23352334
return 1;
23362335
}else{
23372336
return 0;
@@ -2402,10 +2401,11 @@
24022401
** Options:
24032402
** --allow-conflict Allow unresolved merge conflicts
24042403
** --allow-empty Allow a commit with no changes
24052404
** --allow-fork Allow the commit to fork
24062405
** --allow-older Allow a commit older than its ancestor
2406
+** --allow-suspect-comment Allow checkin comments that might be misformed
24072407
** --baseline Use a baseline manifest in the commit process
24082408
** --bgcolor COLOR Apply COLOR to this one check-in only
24092409
** --branch NEW-BRANCH-NAME Check in to this new branch
24102410
** --branchcolor COLOR Apply given COLOR to the branch
24112411
** --close Close the branch being committed
@@ -2472,10 +2472,11 @@
24722472
int allowConflict = 0; /* Allow unresolve merge conflicts */
24732473
int allowEmpty = 0; /* Allow a commit with no changes */
24742474
int onlyIfChanges = 0; /* No-op if there are no changes */
24752475
int allowFork = 0; /* Allow the commit to fork */
24762476
int allowOlder = 0; /* Allow a commit older than its ancestor */
2477
+ int allowSusCom = 0; /* Allow suspicious check-in comments */
24772478
char *zManifestFile; /* Name of the manifest file */
24782479
int useCksum; /* True if checksums should be computed and verified */
24792480
int outputManifest; /* True to output "manifest" and "manifest.uuid" */
24802481
int dryRunFlag; /* True for a test run. Debugging only */
24812482
CheckinInfo sCiInfo; /* Information about this check-in */
@@ -2527,10 +2528,11 @@
25272528
}
25282529
zComment = find_option("comment","m",1);
25292530
forceFlag = find_option("force", "f", 0)!=0;
25302531
allowConflict = find_option("allow-conflict",0,0)!=0;
25312532
allowEmpty = find_option("allow-empty",0,0)!=0;
2533
+ allowSusCom = find_option("allow-suspect-comment",0,0)!=0;
25322534
onlyIfChanges = find_option("if-changes",0,0)!=0;
25332535
allowFork = find_option("allow-fork",0,0)!=0;
25342536
if( find_option("override-lock",0,0)!=0 ) allowFork = 1;
25352537
allowOlder = find_option("allow-older",0,0)!=0;
25362538
noPrompt = find_option("no-prompt", 0, 0)!=0;
@@ -2851,26 +2853,36 @@
28512853
/* Get the check-in comment. This might involve prompting the
28522854
** user for the check-in comment, in which case we should resync
28532855
** to renew the check-in lock and repeat the checks for conflicts.
28542856
*/
28552857
if( zComment ){
2858
+ Blob sus;
28562859
blob_zero(&comment);
28572860
blob_append(&comment, zComment, -1);
2861
+ if( !forceFlag && !allowSusCom && suspicious_comment(&comment, &sus) ){
2862
+ fossil_fatal("%bCommit aborted; "
2863
+ "use --allow-suspect-comment to override", &sus);
2864
+ }
28582865
}else if( zComFile ){
2866
+ Blob sus;
28592867
blob_zero(&comment);
28602868
blob_read_from_file(&comment, zComFile, ExtFILE);
28612869
blob_to_utf8_no_bom(&comment, 1);
2870
+ if( !forceFlag && !allowSusCom && suspicious_comment(&comment, &sus) ){
2871
+ fossil_fatal("%bCommit aborted; "
2872
+ "use --allow-suspect-comment to override", &sus);
2873
+ }
28622874
}else if( !noPrompt ){
28632875
while( 1/*exit-by-break*/ ){
28642876
char *zInit;
28652877
Blob sus;
28662878
28672879
zInit = db_text(0,"SELECT value FROM vvar WHERE name='ci-comment'");
28682880
prepare_commit_comment(&comment, zInit, &sCiInfo, vid, dryRunFlag);
28692881
db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
2870
- blob_init(&sus, 0, 0);
2871
- if( suspicious_comment(&comment,&sus) ){
2882
+ if( !allowSusCom && suspicious_comment(&comment,&sus) ){
2883
+ blob_appendf(&sus, "Edit, abort, or continue (E/a/c)? ");
28722884
prompt_user(blob_str(&sus), &ans);
28732885
cReply = blob_str(&ans)[0];
28742886
blob_reset(&ans);
28752887
blob_reset(&sus);
28762888
if( cReply=='e' || cReply=='E' ){
28772889
--- src/checkin.c
+++ src/checkin.c
@@ -2296,10 +2296,11 @@
2296 char *zSep;
2297 char cSave1;
2298 int nIssue = 0;
2299
2300 z = zStart;
 
2301 while( (z = strchr(z,'['))!=0 ){
2302 zEnd = strchr(z,']');
2303 if( zEnd==0 ){
2304 blob_appendf(pSus,"\n (%d) ", ++nIssue);
2305 blob_appendf(pSus, "Unterminated hyperlink \"%.12s...\"", z);
@@ -2325,13 +2326,11 @@
2325 }
2326 if( nIssue ){
2327 Blob tmp = *pSus;
2328 blob_init(pSus, 0, 0);
2329 blob_appendf(pSus,
2330 "Possible comment formatting error%s:"
2331 "%b\n"
2332 "Edit, continue, or abort (E/c/a)? ",
2333 nIssue>1 ? "s" : "", &tmp);
2334 blob_reset(&tmp);
2335 return 1;
2336 }else{
2337 return 0;
@@ -2402,10 +2401,11 @@
2402 ** Options:
2403 ** --allow-conflict Allow unresolved merge conflicts
2404 ** --allow-empty Allow a commit with no changes
2405 ** --allow-fork Allow the commit to fork
2406 ** --allow-older Allow a commit older than its ancestor
 
2407 ** --baseline Use a baseline manifest in the commit process
2408 ** --bgcolor COLOR Apply COLOR to this one check-in only
2409 ** --branch NEW-BRANCH-NAME Check in to this new branch
2410 ** --branchcolor COLOR Apply given COLOR to the branch
2411 ** --close Close the branch being committed
@@ -2472,10 +2472,11 @@
2472 int allowConflict = 0; /* Allow unresolve merge conflicts */
2473 int allowEmpty = 0; /* Allow a commit with no changes */
2474 int onlyIfChanges = 0; /* No-op if there are no changes */
2475 int allowFork = 0; /* Allow the commit to fork */
2476 int allowOlder = 0; /* Allow a commit older than its ancestor */
 
2477 char *zManifestFile; /* Name of the manifest file */
2478 int useCksum; /* True if checksums should be computed and verified */
2479 int outputManifest; /* True to output "manifest" and "manifest.uuid" */
2480 int dryRunFlag; /* True for a test run. Debugging only */
2481 CheckinInfo sCiInfo; /* Information about this check-in */
@@ -2527,10 +2528,11 @@
2527 }
2528 zComment = find_option("comment","m",1);
2529 forceFlag = find_option("force", "f", 0)!=0;
2530 allowConflict = find_option("allow-conflict",0,0)!=0;
2531 allowEmpty = find_option("allow-empty",0,0)!=0;
 
2532 onlyIfChanges = find_option("if-changes",0,0)!=0;
2533 allowFork = find_option("allow-fork",0,0)!=0;
2534 if( find_option("override-lock",0,0)!=0 ) allowFork = 1;
2535 allowOlder = find_option("allow-older",0,0)!=0;
2536 noPrompt = find_option("no-prompt", 0, 0)!=0;
@@ -2851,26 +2853,36 @@
2851 /* Get the check-in comment. This might involve prompting the
2852 ** user for the check-in comment, in which case we should resync
2853 ** to renew the check-in lock and repeat the checks for conflicts.
2854 */
2855 if( zComment ){
 
2856 blob_zero(&comment);
2857 blob_append(&comment, zComment, -1);
 
 
 
 
2858 }else if( zComFile ){
 
2859 blob_zero(&comment);
2860 blob_read_from_file(&comment, zComFile, ExtFILE);
2861 blob_to_utf8_no_bom(&comment, 1);
 
 
 
 
2862 }else if( !noPrompt ){
2863 while( 1/*exit-by-break*/ ){
2864 char *zInit;
2865 Blob sus;
2866
2867 zInit = db_text(0,"SELECT value FROM vvar WHERE name='ci-comment'");
2868 prepare_commit_comment(&comment, zInit, &sCiInfo, vid, dryRunFlag);
2869 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
2870 blob_init(&sus, 0, 0);
2871 if( suspicious_comment(&comment,&sus) ){
2872 prompt_user(blob_str(&sus), &ans);
2873 cReply = blob_str(&ans)[0];
2874 blob_reset(&ans);
2875 blob_reset(&sus);
2876 if( cReply=='e' || cReply=='E' ){
2877
--- src/checkin.c
+++ src/checkin.c
@@ -2296,10 +2296,11 @@
2296 char *zSep;
2297 char cSave1;
2298 int nIssue = 0;
2299
2300 z = zStart;
2301 blob_init(pSus, 0, 0);
2302 while( (z = strchr(z,'['))!=0 ){
2303 zEnd = strchr(z,']');
2304 if( zEnd==0 ){
2305 blob_appendf(pSus,"\n (%d) ", ++nIssue);
2306 blob_appendf(pSus, "Unterminated hyperlink \"%.12s...\"", z);
@@ -2325,13 +2326,11 @@
2326 }
2327 if( nIssue ){
2328 Blob tmp = *pSus;
2329 blob_init(pSus, 0, 0);
2330 blob_appendf(pSus,
2331 "Possible comment formatting error%s:%b\n",
 
 
2332 nIssue>1 ? "s" : "", &tmp);
2333 blob_reset(&tmp);
2334 return 1;
2335 }else{
2336 return 0;
@@ -2402,10 +2401,11 @@
2401 ** Options:
2402 ** --allow-conflict Allow unresolved merge conflicts
2403 ** --allow-empty Allow a commit with no changes
2404 ** --allow-fork Allow the commit to fork
2405 ** --allow-older Allow a commit older than its ancestor
2406 ** --allow-suspect-comment Allow checkin comments that might be misformed
2407 ** --baseline Use a baseline manifest in the commit process
2408 ** --bgcolor COLOR Apply COLOR to this one check-in only
2409 ** --branch NEW-BRANCH-NAME Check in to this new branch
2410 ** --branchcolor COLOR Apply given COLOR to the branch
2411 ** --close Close the branch being committed
@@ -2472,10 +2472,11 @@
2472 int allowConflict = 0; /* Allow unresolve merge conflicts */
2473 int allowEmpty = 0; /* Allow a commit with no changes */
2474 int onlyIfChanges = 0; /* No-op if there are no changes */
2475 int allowFork = 0; /* Allow the commit to fork */
2476 int allowOlder = 0; /* Allow a commit older than its ancestor */
2477 int allowSusCom = 0; /* Allow suspicious check-in comments */
2478 char *zManifestFile; /* Name of the manifest file */
2479 int useCksum; /* True if checksums should be computed and verified */
2480 int outputManifest; /* True to output "manifest" and "manifest.uuid" */
2481 int dryRunFlag; /* True for a test run. Debugging only */
2482 CheckinInfo sCiInfo; /* Information about this check-in */
@@ -2527,10 +2528,11 @@
2528 }
2529 zComment = find_option("comment","m",1);
2530 forceFlag = find_option("force", "f", 0)!=0;
2531 allowConflict = find_option("allow-conflict",0,0)!=0;
2532 allowEmpty = find_option("allow-empty",0,0)!=0;
2533 allowSusCom = find_option("allow-suspect-comment",0,0)!=0;
2534 onlyIfChanges = find_option("if-changes",0,0)!=0;
2535 allowFork = find_option("allow-fork",0,0)!=0;
2536 if( find_option("override-lock",0,0)!=0 ) allowFork = 1;
2537 allowOlder = find_option("allow-older",0,0)!=0;
2538 noPrompt = find_option("no-prompt", 0, 0)!=0;
@@ -2851,26 +2853,36 @@
2853 /* Get the check-in comment. This might involve prompting the
2854 ** user for the check-in comment, in which case we should resync
2855 ** to renew the check-in lock and repeat the checks for conflicts.
2856 */
2857 if( zComment ){
2858 Blob sus;
2859 blob_zero(&comment);
2860 blob_append(&comment, zComment, -1);
2861 if( !forceFlag && !allowSusCom && suspicious_comment(&comment, &sus) ){
2862 fossil_fatal("%bCommit aborted; "
2863 "use --allow-suspect-comment to override", &sus);
2864 }
2865 }else if( zComFile ){
2866 Blob sus;
2867 blob_zero(&comment);
2868 blob_read_from_file(&comment, zComFile, ExtFILE);
2869 blob_to_utf8_no_bom(&comment, 1);
2870 if( !forceFlag && !allowSusCom && suspicious_comment(&comment, &sus) ){
2871 fossil_fatal("%bCommit aborted; "
2872 "use --allow-suspect-comment to override", &sus);
2873 }
2874 }else if( !noPrompt ){
2875 while( 1/*exit-by-break*/ ){
2876 char *zInit;
2877 Blob sus;
2878
2879 zInit = db_text(0,"SELECT value FROM vvar WHERE name='ci-comment'");
2880 prepare_commit_comment(&comment, zInit, &sCiInfo, vid, dryRunFlag);
2881 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
2882 if( !allowSusCom && suspicious_comment(&comment,&sus) ){
2883 blob_appendf(&sus, "Edit, abort, or continue (E/a/c)? ");
2884 prompt_user(blob_str(&sus), &ans);
2885 cReply = blob_str(&ans)[0];
2886 blob_reset(&ans);
2887 blob_reset(&sus);
2888 if( cReply=='e' || cReply=='E' ){
2889

Keyboard Shortcuts

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