@@ -238,9 +238,9 @@
if( allFlag ){
unlink(db_column_text(&q, 0));
}else{
Blob ans;
- char *prompt = mprintf("remove unmanaged file \"%s\" [y/N]? ",
+ char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ",
db_column_text(&q, 0));
blob_zero(&ans);
prompt_user(prompt, &ans);
if( blob_str(&ans)[0]=='y' ){
@@ -258,20 +258,21 @@
**
** Store the final commit comment in pComment. pComment is assumed
** to be uninitialized - any prior content is overwritten.
*/
-static void prepare_commit_comment(Blob *pComment){
+static void prepare_commit_comment(Blob *pComment, char *zInit){
const char *zEditor;
char *zCmd;
char *zFile;
Blob text, line;
char *zComment;
int i;
- blob_set(&text,
+ blob_init(&text, zInit, -1);
+ blob_append(&text,
"\n"
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
"# The check-in comment follows wiki formatting rules.\n"
- "#\n"
+ "#\n", -1
);
if( g.markPrivate ){
blob_append(&text,
"# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
@@ -389,13 +390,20 @@
** Usage: %fossil commit ?OPTIONS? ?FILE...?
**
** Create a new version containing all of the changes in the current
** checkout. You will be prompted to enter a check-in comment unless
-** the "-m" option is used to specify a comment line. You will be
-** prompted for your GPG passphrase in order to sign the new manifest
-** unless the "--nosign" options is used. All files that have
-** changed will be committed unless some subset of files is specified
-** on the command line.
+** one of the "-m" or "-M" options are used to specify a comment.
+** "-m" takes a single string for the commit message and "-M" requires
+** a filename from which to read the commit message. If neither "-m"
+** nor "-M" are specified then the editor defined in the "editor"
+** fossil option (see %fossil help set) will be used, or from the
+** "VISUAL" or "EDITOR" environment variables (in that order) if no
+** editor is set.
+**
+** You will be prompted for your GPG passphrase in order to sign the
+** new manifest unless the "--nosign" options is used. All files that
+** have changed will be committed unless some subset of files is
+** specified on the command line.
**
** The --branch option followed by a branch name cases the new check-in
** to be placed in the named branch. The --bgcolor option can be followed
** by a color name (ex: '#ffc0c0') to specify the background color of
@@ -414,8 +422,9 @@
** --bgcolor COLOR
** --nosign
** --force|-f
** --private
+** --message-file|-M COMMENT-FILE
**
*/
void commit_cmd(void){
int rc;
@@ -433,8 +442,9 @@
const char *zBranch; /* Create a new branch with this name */
const char *zBgColor; /* Set background color when branching */
const char *zDateOvrd; /* Override date string */
const char *zUserOvrd; /* Override user name */
+ const char *zCommentFile; /* Read commit message from this file */
Blob filename; /* complete filename */
Blob manifest;
Blob muuid; /* Manifest uuid */
Blob mcksum; /* Self-checksum on the manifest */
@@ -446,8 +456,9 @@
zComment = find_option("comment","m",1);
forceFlag = find_option("force", "f", 0)!=0;
zBranch = find_option("branch","b",1);
zBgColor = find_option("bgcolor",0,1);
+ zCommentFile = find_option("message-file", "M", 1);
if( find_option("private",0,0) ){
g.markPrivate = 1;
if( zBranch==0 ) zBranch = "private";
if( zBgColor==0 ) zBgColor = "#fec084"; /* Orange */
@@ -538,19 +549,28 @@
vfile_aggregate_checksum_disk(vid, &cksum1);
if( zComment ){
blob_zero(&comment);
blob_append(&comment, zComment, -1);
+ }else if( zCommentFile ){
+ blob_zero(&comment);
+ blob_read_from_file(&comment, zCommentFile);
}else{
- prepare_commit_comment(&comment);
- if( blob_size(&comment)==0 ){
- Blob ans;
- blob_zero(&ans);
- prompt_user("empty check-in comment. continue [y/N]? ", &ans);
- if( blob_str(&ans)[0]!='y' ){
- db_end_transaction(1);
- exit(1);
- }
+ char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
+ prepare_commit_comment(&comment, zInit);
+ free(zInit);
+ }
+ if( blob_size(&comment)==0 ){
+ Blob ans;
+ blob_zero(&ans);
+ prompt_user("empty check-in comment. continue (y/N)? ", &ans);
+ if( blob_str(&ans)[0]!='y' ){
+ db_end_transaction(1);
+ exit(1);
}
+ }else{
+ db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
+ db_end_transaction(0);
+ db_begin_transaction();
}
/* Step 1: Insert records for all modified files into the blob
** table. If there were arguments passed to this command, only
@@ -668,9 +688,9 @@
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
if( !noSign && !g.markPrivate && clearsign(&manifest, &manifest) ){
Blob ans;
blob_zero(&ans);
- prompt_user("unable to sign manifest. continue [y/N]? ", &ans);
+ prompt_user("unable to sign manifest. continue (y/N)? ", &ans);
if( blob_str(&ans)[0]!='y' ){
db_end_transaction(1);
exit(1);
}
@@ -736,8 +756,9 @@
/* Clear the undo/redo stack */
undo_reset();
/* Commit */
+ db_multi_exec("DELETE FROM vvar WHERE name='ci-comment'");
db_end_transaction(0);
if( !g.markPrivate ){
autosync(AUTOSYNC_PUSH);