Fossil SCM

Add --edit-commit to edit commit message in EDITOR. This option has precedence over --commit.

andybradford 2015-07-18 02:29 check-in-edit
Commit fbf7b54e72de0bb766d7ba68140228c9f4ecb3c6
1 file changed +47 -1
+47 -1
--- src/info.c
+++ src/info.c
@@ -2703,10 +2703,44 @@
27032703
@ </td></tr>
27042704
@ </table>
27052705
@ </div></form>
27062706
style_footer();
27072707
}
2708
+
2709
+/*
2710
+** Prepare an ammended commit comment. Let the user modify it using the
2711
+** editor specified in the global_config table or either
2712
+** the VISUAL or EDITOR environment variable.
2713
+**
2714
+** Store the final commit comment in pComment. pComment is assumed
2715
+** to be uninitialized - any prior content is overwritten.
2716
+**
2717
+** Use zInit to initialize the check-in comment so that the user does
2718
+** not have to retype.
2719
+*/
2720
+static void prepare_amend_comment(
2721
+ Blob *pComment,
2722
+ const char *zInit,
2723
+ const char *zUuid
2724
+){
2725
+ Blob prompt;
2726
+#if defined(_WIN32) || defined(__CYGWIN__)
2727
+ int bomSize;
2728
+ const unsigned char *bom = get_utf8_bom(&bomSize);
2729
+ blob_init(&prompt, (const char *) bom, bomSize);
2730
+ if( zInit && zInit[0]){
2731
+ blob_append(&prompt, zInit, -1);
2732
+ }
2733
+#else
2734
+ blob_init(&prompt, zInit, -1);
2735
+#endif
2736
+ blob_append(&prompt, "\n# Enter a new comment for check-in ", -1);
2737
+ blob_append(&prompt, zUuid, -1);
2738
+ blob_append(&prompt, ".\n# Lines beginning with a # are ignored.\n", -1);
2739
+ prompt_for_user_comment(pComment, &prompt);
2740
+ blob_reset(&prompt);
2741
+}
27082742
27092743
#define AMEND_USAGE_STMT "UUID OPTION ?OPTION ...?"
27102744
/*
27112745
** COMMAND: amend
27122746
**
@@ -2716,10 +2750,11 @@
27162750
**
27172751
** Options:
27182752
**
27192753
** --euser USER Make USER the check-in user
27202754
** --comment COMMENT Make COMMENT the check-in comment
2755
+** --edit-comment Launch editor to revise comment
27212756
** --date DATE Make DATE the check-in time
27222757
** --bgcolor COLOR Apply COLOR to this check-in
27232758
** --branchcolor COLOR Apply and propagate COLOR to the branch
27242759
** --tag TAG Add new TAG to this check-in
27252760
** --cancel TAG Cancel TAG from this check-in
@@ -2743,16 +2778,19 @@
27432778
const char *zCancelTag;
27442779
int fClose; /* True if leaf should be closed */
27452780
int fHide; /* True if branch should be hidden */
27462781
int fPropagateColor; /* True if color propagates before amend */
27472782
int fNewPropagateColor = 0; /* True if color propagates after amend */
2783
+ int fEditComment; /* True if editor to be used for comment */
27482784
const char *zChngTime; /* The change time on the control artifact */
27492785
const char *zUuid;
27502786
Blob ctrl;
2787
+ Blob comment;
27512788
char *zNow;
27522789
27532790
if( g.argc==3 ) usage(AMEND_USAGE_STMT);
2791
+ fEditComment = find_option("edit-comment",0,0)!=0;
27542792
zNewComment = find_option("comment",0,1);
27552793
zNewBranch = find_option("branch",0,1);
27562794
zNewColor = find_option("bgcolor",0,1);
27572795
zNewBrColor = find_option("branchcolor",0,1);
27582796
if( zNewBrColor ){
@@ -2797,11 +2835,19 @@
27972835
|| fossil_strcmp(zColor,zNewColor)!=0)
27982836
) add_color(zNewColor,fNewPropagateColor);
27992837
if( (zNewColor!=0 && zNewColor[0]==0) && (zColor && zColor[0] ) ){
28002838
cancel_color();
28012839
}
2802
- if( zNewComment && zNewComment[0]
2840
+ if( fEditComment && zComment && zComment[0] ){
2841
+ prepare_amend_comment(&comment, zComment, zUuid);
2842
+ zNewComment = blob_str(&comment);
2843
+ if( comment_compare(zComment, zNewComment)==0 ){
2844
+ add_comment(zNewComment);
2845
+ }else{
2846
+ fossil_warning("Comment is unchanged.");
2847
+ }
2848
+ }else if( zNewComment && zNewComment[0]
28032849
&& comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment);
28042850
if( zNewDate && zNewDate[0] && fossil_strcmp(zDate,zNewDate)!=0 ){
28052851
add_date(zNewDate);
28062852
}
28072853
if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){
28082854
--- src/info.c
+++ src/info.c
@@ -2703,10 +2703,44 @@
2703 @ </td></tr>
2704 @ </table>
2705 @ </div></form>
2706 style_footer();
2707 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2708
2709 #define AMEND_USAGE_STMT "UUID OPTION ?OPTION ...?"
2710 /*
2711 ** COMMAND: amend
2712 **
@@ -2716,10 +2750,11 @@
2716 **
2717 ** Options:
2718 **
2719 ** --euser USER Make USER the check-in user
2720 ** --comment COMMENT Make COMMENT the check-in comment
 
2721 ** --date DATE Make DATE the check-in time
2722 ** --bgcolor COLOR Apply COLOR to this check-in
2723 ** --branchcolor COLOR Apply and propagate COLOR to the branch
2724 ** --tag TAG Add new TAG to this check-in
2725 ** --cancel TAG Cancel TAG from this check-in
@@ -2743,16 +2778,19 @@
2743 const char *zCancelTag;
2744 int fClose; /* True if leaf should be closed */
2745 int fHide; /* True if branch should be hidden */
2746 int fPropagateColor; /* True if color propagates before amend */
2747 int fNewPropagateColor = 0; /* True if color propagates after amend */
 
2748 const char *zChngTime; /* The change time on the control artifact */
2749 const char *zUuid;
2750 Blob ctrl;
 
2751 char *zNow;
2752
2753 if( g.argc==3 ) usage(AMEND_USAGE_STMT);
 
2754 zNewComment = find_option("comment",0,1);
2755 zNewBranch = find_option("branch",0,1);
2756 zNewColor = find_option("bgcolor",0,1);
2757 zNewBrColor = find_option("branchcolor",0,1);
2758 if( zNewBrColor ){
@@ -2797,11 +2835,19 @@
2797 || fossil_strcmp(zColor,zNewColor)!=0)
2798 ) add_color(zNewColor,fNewPropagateColor);
2799 if( (zNewColor!=0 && zNewColor[0]==0) && (zColor && zColor[0] ) ){
2800 cancel_color();
2801 }
2802 if( zNewComment && zNewComment[0]
 
 
 
 
 
 
 
 
2803 && comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment);
2804 if( zNewDate && zNewDate[0] && fossil_strcmp(zDate,zNewDate)!=0 ){
2805 add_date(zNewDate);
2806 }
2807 if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){
2808
--- src/info.c
+++ src/info.c
@@ -2703,10 +2703,44 @@
2703 @ </td></tr>
2704 @ </table>
2705 @ </div></form>
2706 style_footer();
2707 }
2708
2709 /*
2710 ** Prepare an ammended commit comment. Let the user modify it using the
2711 ** editor specified in the global_config table or either
2712 ** the VISUAL or EDITOR environment variable.
2713 **
2714 ** Store the final commit comment in pComment. pComment is assumed
2715 ** to be uninitialized - any prior content is overwritten.
2716 **
2717 ** Use zInit to initialize the check-in comment so that the user does
2718 ** not have to retype.
2719 */
2720 static void prepare_amend_comment(
2721 Blob *pComment,
2722 const char *zInit,
2723 const char *zUuid
2724 ){
2725 Blob prompt;
2726 #if defined(_WIN32) || defined(__CYGWIN__)
2727 int bomSize;
2728 const unsigned char *bom = get_utf8_bom(&bomSize);
2729 blob_init(&prompt, (const char *) bom, bomSize);
2730 if( zInit && zInit[0]){
2731 blob_append(&prompt, zInit, -1);
2732 }
2733 #else
2734 blob_init(&prompt, zInit, -1);
2735 #endif
2736 blob_append(&prompt, "\n# Enter a new comment for check-in ", -1);
2737 blob_append(&prompt, zUuid, -1);
2738 blob_append(&prompt, ".\n# Lines beginning with a # are ignored.\n", -1);
2739 prompt_for_user_comment(pComment, &prompt);
2740 blob_reset(&prompt);
2741 }
2742
2743 #define AMEND_USAGE_STMT "UUID OPTION ?OPTION ...?"
2744 /*
2745 ** COMMAND: amend
2746 **
@@ -2716,10 +2750,11 @@
2750 **
2751 ** Options:
2752 **
2753 ** --euser USER Make USER the check-in user
2754 ** --comment COMMENT Make COMMENT the check-in comment
2755 ** --edit-comment Launch editor to revise comment
2756 ** --date DATE Make DATE the check-in time
2757 ** --bgcolor COLOR Apply COLOR to this check-in
2758 ** --branchcolor COLOR Apply and propagate COLOR to the branch
2759 ** --tag TAG Add new TAG to this check-in
2760 ** --cancel TAG Cancel TAG from this check-in
@@ -2743,16 +2778,19 @@
2778 const char *zCancelTag;
2779 int fClose; /* True if leaf should be closed */
2780 int fHide; /* True if branch should be hidden */
2781 int fPropagateColor; /* True if color propagates before amend */
2782 int fNewPropagateColor = 0; /* True if color propagates after amend */
2783 int fEditComment; /* True if editor to be used for comment */
2784 const char *zChngTime; /* The change time on the control artifact */
2785 const char *zUuid;
2786 Blob ctrl;
2787 Blob comment;
2788 char *zNow;
2789
2790 if( g.argc==3 ) usage(AMEND_USAGE_STMT);
2791 fEditComment = find_option("edit-comment",0,0)!=0;
2792 zNewComment = find_option("comment",0,1);
2793 zNewBranch = find_option("branch",0,1);
2794 zNewColor = find_option("bgcolor",0,1);
2795 zNewBrColor = find_option("branchcolor",0,1);
2796 if( zNewBrColor ){
@@ -2797,11 +2835,19 @@
2835 || fossil_strcmp(zColor,zNewColor)!=0)
2836 ) add_color(zNewColor,fNewPropagateColor);
2837 if( (zNewColor!=0 && zNewColor[0]==0) && (zColor && zColor[0] ) ){
2838 cancel_color();
2839 }
2840 if( fEditComment && zComment && zComment[0] ){
2841 prepare_amend_comment(&comment, zComment, zUuid);
2842 zNewComment = blob_str(&comment);
2843 if( comment_compare(zComment, zNewComment)==0 ){
2844 add_comment(zNewComment);
2845 }else{
2846 fossil_warning("Comment is unchanged.");
2847 }
2848 }else if( zNewComment && zNewComment[0]
2849 && comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment);
2850 if( zNewDate && zNewDate[0] && fossil_strcmp(zDate,zNewDate)!=0 ){
2851 add_date(zNewDate);
2852 }
2853 if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){
2854

Keyboard Shortcuts

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