Index: src/checkin.c ================================================================== --- src/checkin.c +++ src/checkin.c @@ -1470,10 +1470,11 @@ static int commit_warning( Blob *p, /* The content of the file being committed. */ int crnlOk, /* Non-zero if CR/NL warnings should be disabled. */ int binOk, /* Non-zero if binary warnings should be disabled. */ int encodingOk, /* Non-zero if encoding warnings should be disabled. */ + int noPrompt, /* Non-zero to disable prompts and assume 'No'. */ const char *zFilename /* The full name of the file being committed. */ ){ int bReverse; /* UTF-16 byte order is reversed? */ int fUnicode; /* return value of could_be_utf16() */ int fBinary; /* does the blob content appear to be binary? */ @@ -1562,13 +1563,18 @@ zMsg = mprintf( "%s contains %s. Use --no-warnings or the %s to" " disable this warning.\n" "Commit anyhow (a=all/%sy/N)? ", blob_str(&fname), zWarning, zDisable, zConvert); - prompt_user(zMsg, &ans); + if( !noPrompt ){ + prompt_user(zMsg, &ans); + cReply = blob_str(&ans)[0]; + blob_reset(&ans); + }else{ + cReply = 'N'; + } fossil_free(zMsg); - cReply = blob_str(&ans)[0]; if( cReply=='a' || cReply=='A' ){ allOk = 1; }else if( *zConvert && (cReply=='c' || cReply=='C') ){ char *zOrig = file_newname(zFilename, "original", 1); FILE *f; @@ -1595,11 +1601,10 @@ return 1; }else if( cReply!='y' && cReply!='Y' ){ fossil_fatal("Abandoning commit due to %s in %s", zWarning, blob_str(&fname)); } - blob_reset(&ans); blob_reset(&fname); } return 0; } @@ -1683,10 +1688,13 @@ ** --integrate close all merged-in branches ** -m|--comment COMMENT-TEXT use COMMENT-TEXT as commit comment ** -M|--message-file FILE read the commit comment from given file ** --mimetype MIMETYPE mimetype of check-in comment ** -n|--dry-run If given, display instead of run actions +** --no-prompt This option disables prompting the user for +** input and assumes an answer of 'No' for every +** question. ** --no-warnings omit all warnings about file contents ** --nosign do not attempt to sign this commit with gpg ** --private do not sync changes and their descendants ** --sha1sum verify file status using SHA1 hashing rather ** than relying on file mtimes @@ -1713,10 +1721,11 @@ char *zUuid; /* UUID of the new check-in */ int useSha1sum = 0; /* True to verify file status using SHA1 hashing */ int noSign = 0; /* True to omit signing the manifest using GPG */ int isAMerge = 0; /* True if checking in a merge */ int noWarningFlag = 0; /* True if skipping all warnings */ + int noPrompt = 0; /* True if skipping all prompts */ int forceFlag = 0; /* Undocumented: Disables all checks */ int forceDelta = 0; /* Force a delta-manifest */ int forceBaseline = 0; /* Force a baseline-manifest */ int allowConflict = 0; /* Allow unresolve merge conflicts */ int allowEmpty = 0; /* Allow a commit with no changes */ @@ -1760,10 +1769,11 @@ forceFlag = find_option("force", "f", 0)!=0; allowConflict = find_option("allow-conflict",0,0)!=0; allowEmpty = find_option("allow-empty",0,0)!=0; allowFork = find_option("allow-fork",0,0)!=0; allowOlder = find_option("allow-older",0,0)!=0; + noPrompt = find_option("no-prompt", 0, 0)!=0; noWarningFlag = find_option("no-warnings", 0, 0)!=0; sCiInfo.zBranch = find_option("branch","b",1); sCiInfo.zColor = find_option("bgcolor",0,1); sCiInfo.zBrClr = find_option("branchcolor",0,1); sCiInfo.closeFlag = find_option("close",0,0)!=0; @@ -1829,12 +1839,18 @@ /* Require confirmation to continue with the check-in if there is ** clock skew */ if( g.clockSkewSeen ){ - prompt_user("continue in spite of time skew (y/N)? ", &ans); - cReply = blob_str(&ans)[0]; + if( !noPrompt ){ + prompt_user("continue in spite of time skew (y/N)? ", &ans); + cReply = blob_str(&ans)[0]; + blob_reset(&ans); + }else{ + fossil_print("Abandoning commit due to time skew\n"); + cReply = 'N'; + } if( cReply!='y' && cReply!='Y' ){ fossil_exit(1); } } @@ -1847,13 +1863,20 @@ ** array is allocated to contain the "id" field from the vfile table ** for each file to be committed. Or, if aCommitFile is NULL, all files ** should be committed. */ if( select_commit_files() ){ - prompt_user("continue (y/N)? ", &ans); - cReply = blob_str(&ans)[0]; - if( cReply!='y' && cReply!='Y' ) fossil_exit(1); + if( !noPrompt ){ + prompt_user("continue (y/N)? ", &ans); + cReply = blob_str(&ans)[0]; + blob_reset(&ans); + }else{ + cReply = 'N'; + } + if( cReply!='y' && cReply!='Y' ){ + fossil_exit(1); + } } isAMerge = db_exists("SELECT 1 FROM vmerge WHERE id=0 OR id<-2"); if( g.aCommitFile && isAMerge ){ fossil_fatal("cannot do a partial commit of a merge"); } @@ -1954,26 +1977,35 @@ blob_append(&comment, zComment, -1); }else if( zComFile ){ blob_zero(&comment); blob_read_from_file(&comment, zComFile); blob_to_utf8_no_bom(&comment, 1); - }else if(dryRunFlag){ + }else if( dryRunFlag ){ blob_zero(&comment); - }else{ + }else if( !noPrompt ){ char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); prepare_commit_comment(&comment, zInit, &sCiInfo, vid); if( zInit && zInit[0] && fossil_strcmp(zInit, blob_str(&comment))==0 ){ prompt_user("unchanged check-in comment. continue (y/N)? ", &ans); cReply = blob_str(&ans)[0]; - if( cReply!='y' && cReply!='Y' ) fossil_exit(1); + blob_reset(&ans); + if( cReply!='y' && cReply!='Y' ){ + fossil_exit(1); + } } free(zInit); } if( blob_size(&comment)==0 ){ if( !dryRunFlag ){ - prompt_user("empty check-in comment. continue (y/N)? ", &ans); - cReply = blob_str(&ans)[0]; + if( !noPrompt ){ + prompt_user("empty check-in comment. continue (y/N)? ", &ans); + cReply = blob_str(&ans)[0]; + blob_reset(&ans); + }else{ + fossil_print("Abandoning commit due to empty check-in comment\n"); + cReply = 'N'; + } if( cReply!='y' && cReply!='Y' ){ fossil_exit(1); } } }else{ @@ -2023,11 +2055,12 @@ blob_read_from_file(&content, zFullname); } /* Do not emit any warnings when they are disabled. */ if( !noWarningFlag ){ abortCommit |= commit_warning(&content, crnlOk, binOk, - encodingOk, zFullname); + encodingOk, noPrompt, + zFullname); } if( contains_merge_marker(&content) ){ Blob fname; /* Relative pathname of the file */ nConflict++; @@ -2107,12 +2140,18 @@ }else if( forceDelta ){ fossil_fatal("unable to find a baseline-manifest for the delta"); } } if( !noSign && !g.markPrivate && clearsign(&manifest, &manifest) ){ - prompt_user("unable to sign manifest. continue (y/N)? ", &ans); - cReply = blob_str(&ans)[0]; + if( !noPrompt ){ + prompt_user("unable to sign manifest. continue (y/N)? ", &ans); + cReply = blob_str(&ans)[0]; + blob_reset(&ans); + }else{ + fossil_print("Abandoning commit due to manifest signing failure\n"); + cReply = 'N'; + } if( cReply!='y' && cReply!='Y' ){ fossil_exit(1); } }