On Wed, Dec 9, 2009 at 11:41 PM, Ramon Ribó <[email protected]> wrote:
> category. I do not see it useful for scripting or external tools, as
> these tools can perfectly use the "-m message" option.
The -m option is not generically usable in scripts or makefiles because the
content might need extra escaping to accommodate embedded quotes, and that's
difficult (or at least troublesome) to handle properly in many scripting
environments. Whether escaping is needed or not would depend on whether the
script uses -m '...' or -m "...", newlines might need special treatment, and
it all gets hairy quickly.
i like the idea of storing the commit in _FOSSIL_, but Jeremy's convinced me
that -M filename is also a useful choice. Regarding the bloat factor: the
diff for -M is only a few lines of real code. i've pasted it below, but keep
in mind that most of the changes are in the docs, not the code:
step...@jareth:~/cvs/fossil/fossil$ f diff src/checkin.c
--- src/checkin.c
+++ src/checkin.c
@@ -388,15 +388,22 @@
**
** 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
** entries in the new branch when shown in the web timeline interface.
@@ -413,10 +420,11 @@
** --branch NEW-BRANCH-NAME
** --bgcolor COLOR
** --nosign
** --force|-f
** --private
+** --comment-file|-M COMMENT-FILE
**
*/
void commit_cmd(void){
int rc;
int vid, nrid, nvid;
@@ -432,10 +440,11 @@
int nBasename; /* Length of "g.zLocalRoot/" */
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 */
Blob cksum1, cksum2; /* Before and after commit checksums */
@@ -445,10 +454,11 @@
noSign = find_option("nosign",0,0)!=0;
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("comment-file", "M", 1);
if( find_option("private",0,0) ){
g.markPrivate = 1;
if( zBranch==0 ) zBranch = "private";
if( zBgColor==0 ) zBgColor = "#fec084"; /* Orange */
}
@@ -537,20 +547,23 @@
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);
- }
+ }
+ 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);
}
}
/* Step 1: Insert records for all modified files into the blob
** table. If there were arguments passed to this command, only
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users