Fossil SCM
Add --edit-commit to edit commit message in EDITOR. This option has precedence over --commit.
Commit
fbf7b54e72de0bb766d7ba68140228c9f4ecb3c6
Parent
0cbdf0586ddab83…
1 file changed
+47
-1
+47
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -2703,10 +2703,44 @@ | ||
| 2703 | 2703 | @ </td></tr> |
| 2704 | 2704 | @ </table> |
| 2705 | 2705 | @ </div></form> |
| 2706 | 2706 | style_footer(); |
| 2707 | 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 | +} | |
| 2708 | 2742 | |
| 2709 | 2743 | #define AMEND_USAGE_STMT "UUID OPTION ?OPTION ...?" |
| 2710 | 2744 | /* |
| 2711 | 2745 | ** COMMAND: amend |
| 2712 | 2746 | ** |
| @@ -2716,10 +2750,11 @@ | ||
| 2716 | 2750 | ** |
| 2717 | 2751 | ** Options: |
| 2718 | 2752 | ** |
| 2719 | 2753 | ** --euser USER Make USER the check-in user |
| 2720 | 2754 | ** --comment COMMENT Make COMMENT the check-in comment |
| 2755 | +** --edit-comment Launch editor to revise comment | |
| 2721 | 2756 | ** --date DATE Make DATE the check-in time |
| 2722 | 2757 | ** --bgcolor COLOR Apply COLOR to this check-in |
| 2723 | 2758 | ** --branchcolor COLOR Apply and propagate COLOR to the branch |
| 2724 | 2759 | ** --tag TAG Add new TAG to this check-in |
| 2725 | 2760 | ** --cancel TAG Cancel TAG from this check-in |
| @@ -2743,16 +2778,19 @@ | ||
| 2743 | 2778 | const char *zCancelTag; |
| 2744 | 2779 | int fClose; /* True if leaf should be closed */ |
| 2745 | 2780 | int fHide; /* True if branch should be hidden */ |
| 2746 | 2781 | int fPropagateColor; /* True if color propagates before amend */ |
| 2747 | 2782 | int fNewPropagateColor = 0; /* True if color propagates after amend */ |
| 2783 | + int fEditComment; /* True if editor to be used for comment */ | |
| 2748 | 2784 | const char *zChngTime; /* The change time on the control artifact */ |
| 2749 | 2785 | const char *zUuid; |
| 2750 | 2786 | Blob ctrl; |
| 2787 | + Blob comment; | |
| 2751 | 2788 | char *zNow; |
| 2752 | 2789 | |
| 2753 | 2790 | if( g.argc==3 ) usage(AMEND_USAGE_STMT); |
| 2791 | + fEditComment = find_option("edit-comment",0,0)!=0; | |
| 2754 | 2792 | zNewComment = find_option("comment",0,1); |
| 2755 | 2793 | zNewBranch = find_option("branch",0,1); |
| 2756 | 2794 | zNewColor = find_option("bgcolor",0,1); |
| 2757 | 2795 | zNewBrColor = find_option("branchcolor",0,1); |
| 2758 | 2796 | if( zNewBrColor ){ |
| @@ -2797,11 +2835,19 @@ | ||
| 2797 | 2835 | || fossil_strcmp(zColor,zNewColor)!=0) |
| 2798 | 2836 | ) add_color(zNewColor,fNewPropagateColor); |
| 2799 | 2837 | if( (zNewColor!=0 && zNewColor[0]==0) && (zColor && zColor[0] ) ){ |
| 2800 | 2838 | cancel_color(); |
| 2801 | 2839 | } |
| 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] | |
| 2803 | 2849 | && comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment); |
| 2804 | 2850 | if( zNewDate && zNewDate[0] && fossil_strcmp(zDate,zNewDate)!=0 ){ |
| 2805 | 2851 | add_date(zNewDate); |
| 2806 | 2852 | } |
| 2807 | 2853 | if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){ |
| 2808 | 2854 |
| --- 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 |