Fossil SCM

Simplify the verify-comments setting to have just "on", "off", and "preview" options. Rename the function that implements this feature to "verify_comment()". Reimplement that function so that it uses the new error reporting mechanism in wiki_convert().

drh 2025-03-22 09:38 trunk
Commit 072125b0ecd047c9184ae83f0974065d56cbea3b87d344a9b797ac2918ec63f8
3 files changed +59 -125 +8 -13 +1 -1
+59 -125
--- src/checkin.c
+++ src/checkin.c
@@ -2289,134 +2289,72 @@
22892289
**
22902290
** This setting determines how much sanity checking, if any, the
22912291
** "fossil commit" and "fossil amend" commands do against check-in
22922292
** comments. Recognized values:
22932293
**
2294
-** on (Default) Check for bad syntax in check-in comments
2295
-** and offer the user a chance to continue editing for
2296
-** interactive sessions, or simply abort the commit if
2297
-** commit was entered using -m or -M
2298
-**
2299
-** off Do not do syntax checking of any kind
2300
-**
2301
-** links Similar to "on", except only check for bad hyperlinks
2302
-**
2303
-** preview Do all the same checks as "on" but also preview the
2304
-** check-in comment to the user during interactive sessions
2305
-** and provide an opportunity to accept or re-edit
2294
+** on (Default) Check for bad syntax and/or broken hyperlinks
2295
+** in check-in comments and offer the user a chance to
2296
+** continue editing for interactive sessions, or simply
2297
+** abort the commit if the comment was entered using -m or -M
2298
+**
2299
+** off Do not do syntax checking of any kind
2300
+**
2301
+** preview Do all the same checks as "on" but also always preview the
2302
+** check-in comment to the user during interactive sessions
2303
+** even if no obvious errors are found, and provide an
2304
+** opportunity to accept or re-edit
23062305
*/
23072306
23082307
#if INTERFACE
2309
-#define COMCK_LINKS 0x01 /* Check for back hyperlinks */
2310
-#define COMCK_MARKUP 0x02 /* Check markup */
2311
-#define COMCK_PREVIEW 0x04 /* Always preview, even if no issues found */
2312
-#define COMCK_NOPREVIEW 0x08 /* Never preview, even for other errors */
2308
+#define COMCK_MARKUP 0x01 /* Check for mistakes */
2309
+#define COMCK_PREVIEW 0x02 /* Always preview, even if no issues found */
23132310
#endif /* INTERFACE */
23142311
23152312
/*
23162313
** Check for possible formatting errors in the comment string pComment.
23172314
**
2318
-** If concerns are found, write a description of the problem(s) to
2319
-** stdout and return non-zero. The return value is some combination
2320
-** of the COMCK_* flags, depending on what went wrong.
2315
+** If issues are found, write an appropriate error notice, probably also
2316
+** including the complete text of the comment formatted to highlight the
2317
+** problem, to stdout and return non-zero. The return value is some
2318
+** combination of the COMCK_* flags, depending on what went wrong.
23212319
**
23222320
** If no issues are seen, do not output anything and return zero.
23232321
*/
2324
-int suspicious_comment(Blob *pComment, int mFlags){
2325
- char *zStart = blob_str(pComment);
2326
- char *z;
2327
- char *zEnd, *zEnd2;
2328
- char *zSep;
2329
- char cSave1;
2330
- int nIssue = 0;
2322
+int verify_comment(Blob *pComment, int mFlags){
2323
+ Blob in, html;
2324
+ int mResult;
23312325
int rc = mFlags & COMCK_PREVIEW;
2332
- Blob out;
2333
- static const char zSpecial[] = "\\&<*_`[";
2326
+ int wFlags;
23342327
23352328
if( mFlags==0 ) return 0;
2336
- z = zStart;
2337
- blob_init(&out, 0, 0);
2338
- if( mFlags & COMCK_LINKS ){
2339
- while( (z = strchr(z,'['))!=0 ){
2340
- zEnd = strchr(z,']');
2341
- if( zEnd==0 ){
2342
- blob_appendf(&out,"\n (%d) ", ++nIssue);
2343
- blob_appendf(&out, "Unterminated hyperlink \"%.12s...\"", z);
2344
- break;
2345
- }
2346
- if( zEnd[1]=='(' && (zEnd2 = strchr(zEnd,')'))!=0 ){
2347
- blob_appendf(&out,"\n (%d) ", ++nIssue);
2348
- blob_appendf(&out, "Markdown hyperlink syntax: %.*s",
2349
- (int)(zEnd2+1-z), z);
2350
- z = zEnd2;
2351
- continue;
2352
- }
2353
- zSep = strchr(z+1,'|');
2354
- if( zSep==0 || zSep>zEnd ) zSep = zEnd;
2355
- while( zSep>z && fossil_isspace(zSep[-1]) ) zSep--;
2356
- cSave1 = zSep[0];
2357
- zSep[0] = 0;
2358
- if( !wiki_valid_link_target(z+1) ){
2359
- blob_appendf(&out,"\n (%d) ", ++nIssue);
2360
- blob_appendf(&out, "Broken hyperlink: [%s]", z+1);
2361
- }
2362
- zSep[0] = cSave1;
2363
- z = zEnd;
2364
- }
2365
- }
2366
-
2367
- if( nIssue>0
2368
- || (mFlags & COMCK_PREVIEW)!=0
2369
- || ((mFlags & COMCK_MARKUP)!=0 && strcspn(zStart,zSpecial)<strlen(zStart))
2370
- ){
2371
- char zGot[16];
2372
- int nGot = 0;
2373
- int i;
2374
- if( (mFlags & COMCK_MARKUP)!=0 ){
2375
- for(i=0; zSpecial[i]; i++){
2376
- if( strchr(zStart,zSpecial[i]) ) zGot[nGot++] = zSpecial[i];
2377
- }
2378
- }
2379
- zGot[nGot] = 0;
2380
- if( nGot>0 ) rc |= COMCK_MARKUP;
2381
- if( nGot>0 && nIssue>0 ){
2382
- blob_appendf(&out,"\n (%d) Comment uses special character%s \"%s\"",
2383
- ++nIssue, (nGot>1 ? "s" : ""), zGot);
2384
- nGot = 0;
2385
- }
2386
- if( nIssue ){
2387
- rc |= COMCK_LINKS;
2388
- fossil_print(
2389
- "Possible comment formatting error%s:%b\n",
2390
- nIssue>1 ? "s" : "", &out
2391
- );
2392
- }
2393
- if( (mFlags & COMCK_NOPREVIEW)==0 ){
2394
- Blob in, html, txt;
2395
- blob_init(&in, blob_str(pComment), -1);
2396
- blob_init(&html, 0, 0);
2397
- blob_init(&txt, 0, 0);
2398
- wiki_convert(&in, &html, WIKI_INLINE);
2399
- html_to_plaintext(blob_str(&html), &txt, HTOT_VT100);
2400
- if( nGot>0 ){
2401
- fossil_print(
2402
- "The comment uses special character%s \"%s\". "
2403
- "Does it render as you expect?\n\n ",
2404
- (nGot>1 ? "s" : ""), zGot
2405
- );
2406
- }else{
2407
- fossil_print("Preview of the check-in comment:\n\n ");
2408
- }
2409
- comment_print(blob_str(&txt), 0, 3, -1, get_comment_format());
2410
- blob_reset(&in);
2411
- blob_reset(&html);
2412
- blob_reset(&txt);
2413
- }
2414
- }
2415
- blob_reset(&out);
2329
+ blob_init(&in, blob_str(pComment), -1);
2330
+ blob_init(&html, 0, 0);
2331
+ wFlags = wiki_convert_flags(0);
2332
+ wFlags &= WIKI_NOBADLINKS;
2333
+ wFlags |= WIKI_MARK;
2334
+ mResult = wiki_convert(&in, &html, wFlags);
2335
+ if( mResult & RENDER_ANYERROR ) rc |= COMCK_MARKUP;
2336
+ if( rc ){
2337
+ int htot = HTOT_NO_WS;
2338
+ Blob txt;
2339
+ if( terminal_is_vt100() ) htot |= HTOT_VT100;
2340
+ blob_init(&txt, 0, 0);
2341
+ html_to_plaintext(blob_str(&html), &txt, htot);
2342
+ if( rc & COMCK_MARKUP ){
2343
+ fossil_print("Possible format errors in the check-in comment:\n\n ");
2344
+ }else{
2345
+ fossil_print("Preview of the check-in comment:\n\n ");
2346
+ }
2347
+ comment_print(blob_str(&txt), 0, 3, -1, get_comment_format());
2348
+ fossil_print("\n");
2349
+ fflush(stdout);
2350
+ blob_reset(&txt);
2351
+ }
2352
+ blob_reset(&html);
2353
+ blob_reset(&in);
24162354
return rc;
2417
-}
2355
+}
24182356
24192357
/*
24202358
** COMMAND: ci#
24212359
** COMMAND: commit
24222360
**
@@ -2556,11 +2494,11 @@
25562494
int bRecheck = 0; /* Repeat fork and closed-branch checks*/
25572495
int bIgnoreSkew = 0; /* --ignore-clock-skew flag */
25582496
int mxSize;
25592497
char *zCurBranch = 0; /* The current branch name of checkout */
25602498
char *zNewBranch = 0; /* The branch name after update */
2561
- int ckComFlgs; /* Flags passed to suspicious_comment() */
2499
+ int ckComFlgs; /* Flags passed to verify_comment() */
25622500
25632501
memset(&sCiInfo, 0, sizeof(sCiInfo));
25642502
url_proxy_options();
25652503
/* --sha1sum is an undocumented alias for --hash for backwards compatiblity */
25662504
useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0;
@@ -2928,15 +2866,13 @@
29282866
}else{
29292867
const char *zVerComs = db_get("verify-comments","on");
29302868
if( is_false(zVerComs) ){
29312869
ckComFlgs = 0;
29322870
}else if( strcmp(zVerComs,"preview")==0 ){
2933
- ckComFlgs = COMCK_PREVIEW | COMCK_LINKS | COMCK_MARKUP;
2934
- }else if( strcmp(zVerComs,"links")==0 ){
2935
- ckComFlgs = COMCK_LINKS;
2871
+ ckComFlgs = COMCK_PREVIEW | COMCK_MARKUP;
29362872
}else{
2937
- ckComFlgs = COMCK_LINKS | COMCK_MARKUP;
2873
+ ckComFlgs = COMCK_MARKUP;
29382874
}
29392875
}
29402876
29412877
/* Get the check-in comment. This might involve prompting the
29422878
** user for the check-in comment, in which case we should resync
@@ -2943,23 +2879,21 @@
29432879
** to renew the check-in lock and repeat the checks for conflicts.
29442880
*/
29452881
if( zComment ){
29462882
blob_zero(&comment);
29472883
blob_append(&comment, zComment, -1);
2948
- ckComFlgs &= ~(COMCK_PREVIEW|COMCK_MARKUP);
2949
- ckComFlgs |= COMCK_NOPREVIEW;
2950
- if( suspicious_comment(&comment, ckComFlgs) ){
2884
+ ckComFlgs &= ~COMCK_PREVIEW;
2885
+ if( verify_comment(&comment, ckComFlgs) ){
29512886
fossil_fatal("Commit aborted; "
29522887
"use --no-verify-comment to override");
29532888
}
29542889
}else if( zComFile ){
29552890
blob_zero(&comment);
29562891
blob_read_from_file(&comment, zComFile, ExtFILE);
29572892
blob_to_utf8_no_bom(&comment, 1);
2958
- ckComFlgs &= ~(COMCK_PREVIEW|COMCK_MARKUP);
2959
- ckComFlgs |= COMCK_NOPREVIEW;
2960
- if( suspicious_comment(&comment, ckComFlgs) ){
2893
+ ckComFlgs &= ~COMCK_PREVIEW;
2894
+ if( verify_comment(&comment, ckComFlgs) ){
29612895
fossil_fatal("Commit aborted; "
29622896
"use --no-verify-comment to override");
29632897
}
29642898
}else if( !noPrompt ){
29652899
while( 1/*exit-by-break*/ ){
@@ -2966,23 +2900,23 @@
29662900
int rc;
29672901
char *zInit;
29682902
zInit = db_text(0,"SELECT value FROM vvar WHERE name='ci-comment'");
29692903
prepare_commit_comment(&comment, zInit, &sCiInfo, vid, dryRunFlag);
29702904
db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
2971
- if( (rc = suspicious_comment(&comment, ckComFlgs))!=0 ){
2905
+ if( (rc = verify_comment(&comment, ckComFlgs))!=0 ){
29722906
if( rc==COMCK_PREVIEW ){
2973
- prompt_user("\nContinue (Y/n/e=edit)? ", &ans);
2907
+ prompt_user("Continue, abort, or edit? (C/a/e)? ", &ans);
29742908
}else{
2975
- prompt_user("\nContinue (y/n/E=edit)? ", &ans);
2909
+ prompt_user("Edit, abort, or continue (E/a/c)? ", &ans);
29762910
}
29772911
cReply = blob_str(&ans)[0];
29782912
cReply = fossil_tolower(cReply);
29792913
blob_reset(&ans);
2980
- if( cReply=='n' ){
2914
+ if( cReply=='a' ){
29812915
fossil_fatal("Commit aborted.");
29822916
}
2983
- if( cReply=='e' || (cReply!='y' && rc!=COMCK_PREVIEW) ){
2917
+ if( cReply=='e' || (cReply!='c' && rc!=COMCK_PREVIEW) ){
29842918
fossil_free(zInit);
29852919
continue;
29862920
}
29872921
}
29882922
if( zInit && zInit[0] && fossil_strcmp(zInit, blob_str(&comment))==0 ){
29892923
--- src/checkin.c
+++ src/checkin.c
@@ -2289,134 +2289,72 @@
2289 **
2290 ** This setting determines how much sanity checking, if any, the
2291 ** "fossil commit" and "fossil amend" commands do against check-in
2292 ** comments. Recognized values:
2293 **
2294 ** on (Default) Check for bad syntax in check-in comments
2295 ** and offer the user a chance to continue editing for
2296 ** interactive sessions, or simply abort the commit if
2297 ** commit was entered using -m or -M
2298 **
2299 ** off Do not do syntax checking of any kind
2300 **
2301 ** links Similar to "on", except only check for bad hyperlinks
2302 **
2303 ** preview Do all the same checks as "on" but also preview the
2304 ** check-in comment to the user during interactive sessions
2305 ** and provide an opportunity to accept or re-edit
2306 */
2307
2308 #if INTERFACE
2309 #define COMCK_LINKS 0x01 /* Check for back hyperlinks */
2310 #define COMCK_MARKUP 0x02 /* Check markup */
2311 #define COMCK_PREVIEW 0x04 /* Always preview, even if no issues found */
2312 #define COMCK_NOPREVIEW 0x08 /* Never preview, even for other errors */
2313 #endif /* INTERFACE */
2314
2315 /*
2316 ** Check for possible formatting errors in the comment string pComment.
2317 **
2318 ** If concerns are found, write a description of the problem(s) to
2319 ** stdout and return non-zero. The return value is some combination
2320 ** of the COMCK_* flags, depending on what went wrong.
 
2321 **
2322 ** If no issues are seen, do not output anything and return zero.
2323 */
2324 int suspicious_comment(Blob *pComment, int mFlags){
2325 char *zStart = blob_str(pComment);
2326 char *z;
2327 char *zEnd, *zEnd2;
2328 char *zSep;
2329 char cSave1;
2330 int nIssue = 0;
2331 int rc = mFlags & COMCK_PREVIEW;
2332 Blob out;
2333 static const char zSpecial[] = "\\&<*_`[";
2334
2335 if( mFlags==0 ) return 0;
2336 z = zStart;
2337 blob_init(&out, 0, 0);
2338 if( mFlags & COMCK_LINKS ){
2339 while( (z = strchr(z,'['))!=0 ){
2340 zEnd = strchr(z,']');
2341 if( zEnd==0 ){
2342 blob_appendf(&out,"\n (%d) ", ++nIssue);
2343 blob_appendf(&out, "Unterminated hyperlink \"%.12s...\"", z);
2344 break;
2345 }
2346 if( zEnd[1]=='(' && (zEnd2 = strchr(zEnd,')'))!=0 ){
2347 blob_appendf(&out,"\n (%d) ", ++nIssue);
2348 blob_appendf(&out, "Markdown hyperlink syntax: %.*s",
2349 (int)(zEnd2+1-z), z);
2350 z = zEnd2;
2351 continue;
2352 }
2353 zSep = strchr(z+1,'|');
2354 if( zSep==0 || zSep>zEnd ) zSep = zEnd;
2355 while( zSep>z && fossil_isspace(zSep[-1]) ) zSep--;
2356 cSave1 = zSep[0];
2357 zSep[0] = 0;
2358 if( !wiki_valid_link_target(z+1) ){
2359 blob_appendf(&out,"\n (%d) ", ++nIssue);
2360 blob_appendf(&out, "Broken hyperlink: [%s]", z+1);
2361 }
2362 zSep[0] = cSave1;
2363 z = zEnd;
2364 }
2365 }
2366
2367 if( nIssue>0
2368 || (mFlags & COMCK_PREVIEW)!=0
2369 || ((mFlags & COMCK_MARKUP)!=0 && strcspn(zStart,zSpecial)<strlen(zStart))
2370 ){
2371 char zGot[16];
2372 int nGot = 0;
2373 int i;
2374 if( (mFlags & COMCK_MARKUP)!=0 ){
2375 for(i=0; zSpecial[i]; i++){
2376 if( strchr(zStart,zSpecial[i]) ) zGot[nGot++] = zSpecial[i];
2377 }
2378 }
2379 zGot[nGot] = 0;
2380 if( nGot>0 ) rc |= COMCK_MARKUP;
2381 if( nGot>0 && nIssue>0 ){
2382 blob_appendf(&out,"\n (%d) Comment uses special character%s \"%s\"",
2383 ++nIssue, (nGot>1 ? "s" : ""), zGot);
2384 nGot = 0;
2385 }
2386 if( nIssue ){
2387 rc |= COMCK_LINKS;
2388 fossil_print(
2389 "Possible comment formatting error%s:%b\n",
2390 nIssue>1 ? "s" : "", &out
2391 );
2392 }
2393 if( (mFlags & COMCK_NOPREVIEW)==0 ){
2394 Blob in, html, txt;
2395 blob_init(&in, blob_str(pComment), -1);
2396 blob_init(&html, 0, 0);
2397 blob_init(&txt, 0, 0);
2398 wiki_convert(&in, &html, WIKI_INLINE);
2399 html_to_plaintext(blob_str(&html), &txt, HTOT_VT100);
2400 if( nGot>0 ){
2401 fossil_print(
2402 "The comment uses special character%s \"%s\". "
2403 "Does it render as you expect?\n\n ",
2404 (nGot>1 ? "s" : ""), zGot
2405 );
2406 }else{
2407 fossil_print("Preview of the check-in comment:\n\n ");
2408 }
2409 comment_print(blob_str(&txt), 0, 3, -1, get_comment_format());
2410 blob_reset(&in);
2411 blob_reset(&html);
2412 blob_reset(&txt);
2413 }
2414 }
2415 blob_reset(&out);
2416 return rc;
2417 }
2418
2419 /*
2420 ** COMMAND: ci#
2421 ** COMMAND: commit
2422 **
@@ -2556,11 +2494,11 @@
2556 int bRecheck = 0; /* Repeat fork and closed-branch checks*/
2557 int bIgnoreSkew = 0; /* --ignore-clock-skew flag */
2558 int mxSize;
2559 char *zCurBranch = 0; /* The current branch name of checkout */
2560 char *zNewBranch = 0; /* The branch name after update */
2561 int ckComFlgs; /* Flags passed to suspicious_comment() */
2562
2563 memset(&sCiInfo, 0, sizeof(sCiInfo));
2564 url_proxy_options();
2565 /* --sha1sum is an undocumented alias for --hash for backwards compatiblity */
2566 useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0;
@@ -2928,15 +2866,13 @@
2928 }else{
2929 const char *zVerComs = db_get("verify-comments","on");
2930 if( is_false(zVerComs) ){
2931 ckComFlgs = 0;
2932 }else if( strcmp(zVerComs,"preview")==0 ){
2933 ckComFlgs = COMCK_PREVIEW | COMCK_LINKS | COMCK_MARKUP;
2934 }else if( strcmp(zVerComs,"links")==0 ){
2935 ckComFlgs = COMCK_LINKS;
2936 }else{
2937 ckComFlgs = COMCK_LINKS | COMCK_MARKUP;
2938 }
2939 }
2940
2941 /* Get the check-in comment. This might involve prompting the
2942 ** user for the check-in comment, in which case we should resync
@@ -2943,23 +2879,21 @@
2943 ** to renew the check-in lock and repeat the checks for conflicts.
2944 */
2945 if( zComment ){
2946 blob_zero(&comment);
2947 blob_append(&comment, zComment, -1);
2948 ckComFlgs &= ~(COMCK_PREVIEW|COMCK_MARKUP);
2949 ckComFlgs |= COMCK_NOPREVIEW;
2950 if( suspicious_comment(&comment, ckComFlgs) ){
2951 fossil_fatal("Commit aborted; "
2952 "use --no-verify-comment to override");
2953 }
2954 }else if( zComFile ){
2955 blob_zero(&comment);
2956 blob_read_from_file(&comment, zComFile, ExtFILE);
2957 blob_to_utf8_no_bom(&comment, 1);
2958 ckComFlgs &= ~(COMCK_PREVIEW|COMCK_MARKUP);
2959 ckComFlgs |= COMCK_NOPREVIEW;
2960 if( suspicious_comment(&comment, ckComFlgs) ){
2961 fossil_fatal("Commit aborted; "
2962 "use --no-verify-comment to override");
2963 }
2964 }else if( !noPrompt ){
2965 while( 1/*exit-by-break*/ ){
@@ -2966,23 +2900,23 @@
2966 int rc;
2967 char *zInit;
2968 zInit = db_text(0,"SELECT value FROM vvar WHERE name='ci-comment'");
2969 prepare_commit_comment(&comment, zInit, &sCiInfo, vid, dryRunFlag);
2970 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
2971 if( (rc = suspicious_comment(&comment, ckComFlgs))!=0 ){
2972 if( rc==COMCK_PREVIEW ){
2973 prompt_user("\nContinue (Y/n/e=edit)? ", &ans);
2974 }else{
2975 prompt_user("\nContinue (y/n/E=edit)? ", &ans);
2976 }
2977 cReply = blob_str(&ans)[0];
2978 cReply = fossil_tolower(cReply);
2979 blob_reset(&ans);
2980 if( cReply=='n' ){
2981 fossil_fatal("Commit aborted.");
2982 }
2983 if( cReply=='e' || (cReply!='y' && rc!=COMCK_PREVIEW) ){
2984 fossil_free(zInit);
2985 continue;
2986 }
2987 }
2988 if( zInit && zInit[0] && fossil_strcmp(zInit, blob_str(&comment))==0 ){
2989
--- src/checkin.c
+++ src/checkin.c
@@ -2289,134 +2289,72 @@
2289 **
2290 ** This setting determines how much sanity checking, if any, the
2291 ** "fossil commit" and "fossil amend" commands do against check-in
2292 ** comments. Recognized values:
2293 **
2294 ** on (Default) Check for bad syntax and/or broken hyperlinks
2295 ** in check-in comments and offer the user a chance to
2296 ** continue editing for interactive sessions, or simply
2297 ** abort the commit if the comment was entered using -m or -M
2298 **
2299 ** off Do not do syntax checking of any kind
2300 **
2301 ** preview Do all the same checks as "on" but also always preview the
2302 ** check-in comment to the user during interactive sessions
2303 ** even if no obvious errors are found, and provide an
2304 ** opportunity to accept or re-edit
 
2305 */
2306
2307 #if INTERFACE
2308 #define COMCK_MARKUP 0x01 /* Check for mistakes */
2309 #define COMCK_PREVIEW 0x02 /* Always preview, even if no issues found */
 
 
2310 #endif /* INTERFACE */
2311
2312 /*
2313 ** Check for possible formatting errors in the comment string pComment.
2314 **
2315 ** If issues are found, write an appropriate error notice, probably also
2316 ** including the complete text of the comment formatted to highlight the
2317 ** problem, to stdout and return non-zero. The return value is some
2318 ** combination of the COMCK_* flags, depending on what went wrong.
2319 **
2320 ** If no issues are seen, do not output anything and return zero.
2321 */
2322 int verify_comment(Blob *pComment, int mFlags){
2323 Blob in, html;
2324 int mResult;
 
 
 
 
2325 int rc = mFlags & COMCK_PREVIEW;
2326 int wFlags;
 
2327
2328 if( mFlags==0 ) return 0;
2329 blob_init(&in, blob_str(pComment), -1);
2330 blob_init(&html, 0, 0);
2331 wFlags = wiki_convert_flags(0);
2332 wFlags &= WIKI_NOBADLINKS;
2333 wFlags |= WIKI_MARK;
2334 mResult = wiki_convert(&in, &html, wFlags);
2335 if( mResult & RENDER_ANYERROR ) rc |= COMCK_MARKUP;
2336 if( rc ){
2337 int htot = HTOT_NO_WS;
2338 Blob txt;
2339 if( terminal_is_vt100() ) htot |= HTOT_VT100;
2340 blob_init(&txt, 0, 0);
2341 html_to_plaintext(blob_str(&html), &txt, htot);
2342 if( rc & COMCK_MARKUP ){
2343 fossil_print("Possible format errors in the check-in comment:\n\n ");
2344 }else{
2345 fossil_print("Preview of the check-in comment:\n\n ");
2346 }
2347 comment_print(blob_str(&txt), 0, 3, -1, get_comment_format());
2348 fossil_print("\n");
2349 fflush(stdout);
2350 blob_reset(&txt);
2351 }
2352 blob_reset(&html);
2353 blob_reset(&in);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2354 return rc;
2355 }
2356
2357 /*
2358 ** COMMAND: ci#
2359 ** COMMAND: commit
2360 **
@@ -2556,11 +2494,11 @@
2494 int bRecheck = 0; /* Repeat fork and closed-branch checks*/
2495 int bIgnoreSkew = 0; /* --ignore-clock-skew flag */
2496 int mxSize;
2497 char *zCurBranch = 0; /* The current branch name of checkout */
2498 char *zNewBranch = 0; /* The branch name after update */
2499 int ckComFlgs; /* Flags passed to verify_comment() */
2500
2501 memset(&sCiInfo, 0, sizeof(sCiInfo));
2502 url_proxy_options();
2503 /* --sha1sum is an undocumented alias for --hash for backwards compatiblity */
2504 useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0;
@@ -2928,15 +2866,13 @@
2866 }else{
2867 const char *zVerComs = db_get("verify-comments","on");
2868 if( is_false(zVerComs) ){
2869 ckComFlgs = 0;
2870 }else if( strcmp(zVerComs,"preview")==0 ){
2871 ckComFlgs = COMCK_PREVIEW | COMCK_MARKUP;
 
 
2872 }else{
2873 ckComFlgs = COMCK_MARKUP;
2874 }
2875 }
2876
2877 /* Get the check-in comment. This might involve prompting the
2878 ** user for the check-in comment, in which case we should resync
@@ -2943,23 +2879,21 @@
2879 ** to renew the check-in lock and repeat the checks for conflicts.
2880 */
2881 if( zComment ){
2882 blob_zero(&comment);
2883 blob_append(&comment, zComment, -1);
2884 ckComFlgs &= ~COMCK_PREVIEW;
2885 if( verify_comment(&comment, ckComFlgs) ){
 
2886 fossil_fatal("Commit aborted; "
2887 "use --no-verify-comment to override");
2888 }
2889 }else if( zComFile ){
2890 blob_zero(&comment);
2891 blob_read_from_file(&comment, zComFile, ExtFILE);
2892 blob_to_utf8_no_bom(&comment, 1);
2893 ckComFlgs &= ~COMCK_PREVIEW;
2894 if( verify_comment(&comment, ckComFlgs) ){
 
2895 fossil_fatal("Commit aborted; "
2896 "use --no-verify-comment to override");
2897 }
2898 }else if( !noPrompt ){
2899 while( 1/*exit-by-break*/ ){
@@ -2966,23 +2900,23 @@
2900 int rc;
2901 char *zInit;
2902 zInit = db_text(0,"SELECT value FROM vvar WHERE name='ci-comment'");
2903 prepare_commit_comment(&comment, zInit, &sCiInfo, vid, dryRunFlag);
2904 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
2905 if( (rc = verify_comment(&comment, ckComFlgs))!=0 ){
2906 if( rc==COMCK_PREVIEW ){
2907 prompt_user("Continue, abort, or edit? (C/a/e)? ", &ans);
2908 }else{
2909 prompt_user("Edit, abort, or continue (E/a/c)? ", &ans);
2910 }
2911 cReply = blob_str(&ans)[0];
2912 cReply = fossil_tolower(cReply);
2913 blob_reset(&ans);
2914 if( cReply=='a' ){
2915 fossil_fatal("Commit aborted.");
2916 }
2917 if( cReply=='e' || (cReply!='c' && rc!=COMCK_PREVIEW) ){
2918 fossil_free(zInit);
2919 continue;
2920 }
2921 }
2922 if( zInit && zInit[0] && fossil_strcmp(zInit, blob_str(&comment))==0 ){
2923
+8 -13
--- src/info.c
+++ src/info.c
@@ -3937,11 +3937,11 @@
39373937
Blob comment;
39383938
char *zNow;
39393939
int nTags, nCancels;
39403940
int i;
39413941
Stmt q;
3942
- int ckComFlgs; /* Flags passed to suspicious_comment() */
3942
+ int ckComFlgs; /* Flags passed to verify_comment() */
39433943
39443944
39453945
fEditComment = find_option("edit-comment","e",0)!=0;
39463946
zNewComment = find_option("comment","m",1);
39473947
zComFile = find_option("message-file","M",1);
@@ -4030,18 +4030,13 @@
40304030
}else{
40314031
const char *zVerComs = db_get("verify-comments","on");
40324032
if( is_false(zVerComs) ){
40334033
ckComFlgs = 0;
40344034
}else if( strcmp(zVerComs,"preview")==0 ){
4035
- ckComFlgs = COMCK_PREVIEW | COMCK_LINKS | COMCK_MARKUP;
4036
- }else if( strcmp(zVerComs,"links")==0 ){
4037
- ckComFlgs = COMCK_LINKS;
4035
+ ckComFlgs = COMCK_PREVIEW | COMCK_MARKUP;
40384036
}else{
4039
- ckComFlgs = COMCK_LINKS | COMCK_MARKUP;
4040
- }
4041
- if( zNewComment || zComFile ){
4042
- ckComFlgs = (ckComFlgs & COMCK_LINKS) | COMCK_NOPREVIEW;
4037
+ ckComFlgs = COMCK_MARKUP;
40434038
}
40444039
}
40454040
if( fEditComment ){
40464041
prepare_amend_comment(&comment, zComment, zUuid);
40474042
}else if( zComFile ){
@@ -4052,29 +4047,29 @@
40524047
}
40534048
if( blob_size(&comment)>0
40544049
&& comment_compare(zComment, blob_str(&comment))==0
40554050
){
40564051
int rc;
4057
- while( (rc = suspicious_comment(&comment, ckComFlgs))!=0 ){
4052
+ while( (rc = verify_comment(&comment, ckComFlgs))!=0 ){
40584053
char cReply;
40594054
Blob ans;
40604055
if( !fEditComment ){
40614056
fossil_fatal("Amend aborted; "
40624057
"use --no-verify-comment to override");
40634058
}
40644059
if( rc==COMCK_PREVIEW ){
4065
- prompt_user("\nContinue (Y/n/e=edit)? ", &ans);
4060
+ prompt_user("Continue, abort, or edit (C/a/e)? ", &ans);
40664061
}else{
4067
- prompt_user("\nContinue (y/n/E=edit)? ", &ans);
4062
+ prompt_user("Edit, abort, or continue (E/a/c)? ", &ans);
40684063
}
40694064
cReply = blob_str(&ans)[0];
40704065
cReply = fossil_tolower(cReply);
40714066
blob_reset(&ans);
4072
- if( cReply=='n' ){
4067
+ if( cReply=='a' ){
40734068
fossil_fatal("Amend aborted.");
40744069
}
4075
- if( cReply=='e' || (cReply!='y' && rc!=COMCK_PREVIEW) ){
4070
+ if( cReply=='e' || (cReply!='c' && rc!=COMCK_PREVIEW) ){
40764071
char *zPrior = blob_materialize(&comment);
40774072
blob_init(&comment, 0, 0);
40784073
prepare_amend_comment(&comment, zPrior, zUuid);
40794074
fossil_free(zPrior);
40804075
continue;
40814076
--- src/info.c
+++ src/info.c
@@ -3937,11 +3937,11 @@
3937 Blob comment;
3938 char *zNow;
3939 int nTags, nCancels;
3940 int i;
3941 Stmt q;
3942 int ckComFlgs; /* Flags passed to suspicious_comment() */
3943
3944
3945 fEditComment = find_option("edit-comment","e",0)!=0;
3946 zNewComment = find_option("comment","m",1);
3947 zComFile = find_option("message-file","M",1);
@@ -4030,18 +4030,13 @@
4030 }else{
4031 const char *zVerComs = db_get("verify-comments","on");
4032 if( is_false(zVerComs) ){
4033 ckComFlgs = 0;
4034 }else if( strcmp(zVerComs,"preview")==0 ){
4035 ckComFlgs = COMCK_PREVIEW | COMCK_LINKS | COMCK_MARKUP;
4036 }else if( strcmp(zVerComs,"links")==0 ){
4037 ckComFlgs = COMCK_LINKS;
4038 }else{
4039 ckComFlgs = COMCK_LINKS | COMCK_MARKUP;
4040 }
4041 if( zNewComment || zComFile ){
4042 ckComFlgs = (ckComFlgs & COMCK_LINKS) | COMCK_NOPREVIEW;
4043 }
4044 }
4045 if( fEditComment ){
4046 prepare_amend_comment(&comment, zComment, zUuid);
4047 }else if( zComFile ){
@@ -4052,29 +4047,29 @@
4052 }
4053 if( blob_size(&comment)>0
4054 && comment_compare(zComment, blob_str(&comment))==0
4055 ){
4056 int rc;
4057 while( (rc = suspicious_comment(&comment, ckComFlgs))!=0 ){
4058 char cReply;
4059 Blob ans;
4060 if( !fEditComment ){
4061 fossil_fatal("Amend aborted; "
4062 "use --no-verify-comment to override");
4063 }
4064 if( rc==COMCK_PREVIEW ){
4065 prompt_user("\nContinue (Y/n/e=edit)? ", &ans);
4066 }else{
4067 prompt_user("\nContinue (y/n/E=edit)? ", &ans);
4068 }
4069 cReply = blob_str(&ans)[0];
4070 cReply = fossil_tolower(cReply);
4071 blob_reset(&ans);
4072 if( cReply=='n' ){
4073 fossil_fatal("Amend aborted.");
4074 }
4075 if( cReply=='e' || (cReply!='y' && rc!=COMCK_PREVIEW) ){
4076 char *zPrior = blob_materialize(&comment);
4077 blob_init(&comment, 0, 0);
4078 prepare_amend_comment(&comment, zPrior, zUuid);
4079 fossil_free(zPrior);
4080 continue;
4081
--- src/info.c
+++ src/info.c
@@ -3937,11 +3937,11 @@
3937 Blob comment;
3938 char *zNow;
3939 int nTags, nCancels;
3940 int i;
3941 Stmt q;
3942 int ckComFlgs; /* Flags passed to verify_comment() */
3943
3944
3945 fEditComment = find_option("edit-comment","e",0)!=0;
3946 zNewComment = find_option("comment","m",1);
3947 zComFile = find_option("message-file","M",1);
@@ -4030,18 +4030,13 @@
4030 }else{
4031 const char *zVerComs = db_get("verify-comments","on");
4032 if( is_false(zVerComs) ){
4033 ckComFlgs = 0;
4034 }else if( strcmp(zVerComs,"preview")==0 ){
4035 ckComFlgs = COMCK_PREVIEW | COMCK_MARKUP;
 
 
4036 }else{
4037 ckComFlgs = COMCK_MARKUP;
 
 
 
4038 }
4039 }
4040 if( fEditComment ){
4041 prepare_amend_comment(&comment, zComment, zUuid);
4042 }else if( zComFile ){
@@ -4052,29 +4047,29 @@
4047 }
4048 if( blob_size(&comment)>0
4049 && comment_compare(zComment, blob_str(&comment))==0
4050 ){
4051 int rc;
4052 while( (rc = verify_comment(&comment, ckComFlgs))!=0 ){
4053 char cReply;
4054 Blob ans;
4055 if( !fEditComment ){
4056 fossil_fatal("Amend aborted; "
4057 "use --no-verify-comment to override");
4058 }
4059 if( rc==COMCK_PREVIEW ){
4060 prompt_user("Continue, abort, or edit (C/a/e)? ", &ans);
4061 }else{
4062 prompt_user("Edit, abort, or continue (E/a/c)? ", &ans);
4063 }
4064 cReply = blob_str(&ans)[0];
4065 cReply = fossil_tolower(cReply);
4066 blob_reset(&ans);
4067 if( cReply=='a' ){
4068 fossil_fatal("Amend aborted.");
4069 }
4070 if( cReply=='e' || (cReply!='c' && rc!=COMCK_PREVIEW) ){
4071 char *zPrior = blob_materialize(&comment);
4072 blob_init(&comment, 0, 0);
4073 prepare_amend_comment(&comment, zPrior, zUuid);
4074 fossil_free(zPrior);
4075 continue;
4076
+1 -1
--- src/printf.c
+++ src/printf.c
@@ -275,11 +275,11 @@
275275
** The altForm2 argument is true for "%!W" (with the "!" alternate-form-2
276276
** flags) and is false for plain "%W". The ! indicates that the text is
277277
** to be rendered on a form rather than the timeline and that block markup
278278
** is acceptable even if the "timeline-block-markup" setting is false.
279279
*/
280
-static int wiki_convert_flags(int altForm2){
280
+int wiki_convert_flags(int altForm2){
281281
static int wikiFlags = 0;
282282
if( wikiFlags==0 ){
283283
if( db_get_boolean("timeline-block-markup", 0) ){
284284
wikiFlags = WIKI_INLINE | WIKI_NOBADLINKS;
285285
}else{
286286
--- src/printf.c
+++ src/printf.c
@@ -275,11 +275,11 @@
275 ** The altForm2 argument is true for "%!W" (with the "!" alternate-form-2
276 ** flags) and is false for plain "%W". The ! indicates that the text is
277 ** to be rendered on a form rather than the timeline and that block markup
278 ** is acceptable even if the "timeline-block-markup" setting is false.
279 */
280 static int wiki_convert_flags(int altForm2){
281 static int wikiFlags = 0;
282 if( wikiFlags==0 ){
283 if( db_get_boolean("timeline-block-markup", 0) ){
284 wikiFlags = WIKI_INLINE | WIKI_NOBADLINKS;
285 }else{
286
--- src/printf.c
+++ src/printf.c
@@ -275,11 +275,11 @@
275 ** The altForm2 argument is true for "%!W" (with the "!" alternate-form-2
276 ** flags) and is false for plain "%W". The ! indicates that the text is
277 ** to be rendered on a form rather than the timeline and that block markup
278 ** is acceptable even if the "timeline-block-markup" setting is false.
279 */
280 int wiki_convert_flags(int altForm2){
281 static int wikiFlags = 0;
282 if( wikiFlags==0 ){
283 if( db_get_boolean("timeline-block-markup", 0) ){
284 wikiFlags = WIKI_INLINE | WIKI_NOBADLINKS;
285 }else{
286

Keyboard Shortcuts

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