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.
Commit
19fc9713fccfed79f7e6f97cdcea58ac37215c264bdbc7b9c06eb6f844414b7f
Parent
2a04c64f4733fcf…
1 file changed
+17
-5
+17
-5
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -2296,10 +2296,11 @@ | ||
| 2296 | 2296 | char *zSep; |
| 2297 | 2297 | char cSave1; |
| 2298 | 2298 | int nIssue = 0; |
| 2299 | 2299 | |
| 2300 | 2300 | z = zStart; |
| 2301 | + blob_init(pSus, 0, 0); | |
| 2301 | 2302 | while( (z = strchr(z,'['))!=0 ){ |
| 2302 | 2303 | zEnd = strchr(z,']'); |
| 2303 | 2304 | if( zEnd==0 ){ |
| 2304 | 2305 | blob_appendf(pSus,"\n (%d) ", ++nIssue); |
| 2305 | 2306 | blob_appendf(pSus, "Unterminated hyperlink \"%.12s...\"", z); |
| @@ -2325,13 +2326,11 @@ | ||
| 2325 | 2326 | } |
| 2326 | 2327 | if( nIssue ){ |
| 2327 | 2328 | Blob tmp = *pSus; |
| 2328 | 2329 | blob_init(pSus, 0, 0); |
| 2329 | 2330 | 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", | |
| 2333 | 2332 | nIssue>1 ? "s" : "", &tmp); |
| 2334 | 2333 | blob_reset(&tmp); |
| 2335 | 2334 | return 1; |
| 2336 | 2335 | }else{ |
| 2337 | 2336 | return 0; |
| @@ -2402,10 +2401,11 @@ | ||
| 2402 | 2401 | ** Options: |
| 2403 | 2402 | ** --allow-conflict Allow unresolved merge conflicts |
| 2404 | 2403 | ** --allow-empty Allow a commit with no changes |
| 2405 | 2404 | ** --allow-fork Allow the commit to fork |
| 2406 | 2405 | ** --allow-older Allow a commit older than its ancestor |
| 2406 | +** --allow-suspect-comment Allow checkin comments that might be misformed | |
| 2407 | 2407 | ** --baseline Use a baseline manifest in the commit process |
| 2408 | 2408 | ** --bgcolor COLOR Apply COLOR to this one check-in only |
| 2409 | 2409 | ** --branch NEW-BRANCH-NAME Check in to this new branch |
| 2410 | 2410 | ** --branchcolor COLOR Apply given COLOR to the branch |
| 2411 | 2411 | ** --close Close the branch being committed |
| @@ -2472,10 +2472,11 @@ | ||
| 2472 | 2472 | int allowConflict = 0; /* Allow unresolve merge conflicts */ |
| 2473 | 2473 | int allowEmpty = 0; /* Allow a commit with no changes */ |
| 2474 | 2474 | int onlyIfChanges = 0; /* No-op if there are no changes */ |
| 2475 | 2475 | int allowFork = 0; /* Allow the commit to fork */ |
| 2476 | 2476 | int allowOlder = 0; /* Allow a commit older than its ancestor */ |
| 2477 | + int allowSusCom = 0; /* Allow suspicious check-in comments */ | |
| 2477 | 2478 | char *zManifestFile; /* Name of the manifest file */ |
| 2478 | 2479 | int useCksum; /* True if checksums should be computed and verified */ |
| 2479 | 2480 | int outputManifest; /* True to output "manifest" and "manifest.uuid" */ |
| 2480 | 2481 | int dryRunFlag; /* True for a test run. Debugging only */ |
| 2481 | 2482 | CheckinInfo sCiInfo; /* Information about this check-in */ |
| @@ -2527,10 +2528,11 @@ | ||
| 2527 | 2528 | } |
| 2528 | 2529 | zComment = find_option("comment","m",1); |
| 2529 | 2530 | forceFlag = find_option("force", "f", 0)!=0; |
| 2530 | 2531 | allowConflict = find_option("allow-conflict",0,0)!=0; |
| 2531 | 2532 | allowEmpty = find_option("allow-empty",0,0)!=0; |
| 2533 | + allowSusCom = find_option("allow-suspect-comment",0,0)!=0; | |
| 2532 | 2534 | onlyIfChanges = find_option("if-changes",0,0)!=0; |
| 2533 | 2535 | allowFork = find_option("allow-fork",0,0)!=0; |
| 2534 | 2536 | if( find_option("override-lock",0,0)!=0 ) allowFork = 1; |
| 2535 | 2537 | allowOlder = find_option("allow-older",0,0)!=0; |
| 2536 | 2538 | noPrompt = find_option("no-prompt", 0, 0)!=0; |
| @@ -2851,26 +2853,36 @@ | ||
| 2851 | 2853 | /* Get the check-in comment. This might involve prompting the |
| 2852 | 2854 | ** user for the check-in comment, in which case we should resync |
| 2853 | 2855 | ** to renew the check-in lock and repeat the checks for conflicts. |
| 2854 | 2856 | */ |
| 2855 | 2857 | if( zComment ){ |
| 2858 | + Blob sus; | |
| 2856 | 2859 | blob_zero(&comment); |
| 2857 | 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 | + } | |
| 2858 | 2865 | }else if( zComFile ){ |
| 2866 | + Blob sus; | |
| 2859 | 2867 | blob_zero(&comment); |
| 2860 | 2868 | blob_read_from_file(&comment, zComFile, ExtFILE); |
| 2861 | 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 | + } | |
| 2862 | 2874 | }else if( !noPrompt ){ |
| 2863 | 2875 | while( 1/*exit-by-break*/ ){ |
| 2864 | 2876 | char *zInit; |
| 2865 | 2877 | Blob sus; |
| 2866 | 2878 | |
| 2867 | 2879 | zInit = db_text(0,"SELECT value FROM vvar WHERE name='ci-comment'"); |
| 2868 | 2880 | prepare_commit_comment(&comment, zInit, &sCiInfo, vid, dryRunFlag); |
| 2869 | 2881 | 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)? "); | |
| 2872 | 2884 | prompt_user(blob_str(&sus), &ans); |
| 2873 | 2885 | cReply = blob_str(&ans)[0]; |
| 2874 | 2886 | blob_reset(&ans); |
| 2875 | 2887 | blob_reset(&sus); |
| 2876 | 2888 | if( cReply=='e' || cReply=='E' ){ |
| 2877 | 2889 |
| --- 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 |