Fossil SCM

Add the --editor option to "fossil commit" and "fossil uv edit".

drh 2025-04-16 16:22 trunk
Commit 76759875516b4dddc269515ff1cf24e4c3240b908fd90b9bfbcb2029b48d0d88
--- src/checkin.c
+++ src/checkin.c
@@ -2444,10 +2444,11 @@
24442444
** --close Close the branch being committed
24452445
** --date-override DATETIME Make DATETIME the time of the check-in.
24462446
** Useful when importing historical check-ins
24472447
** from another version control system.
24482448
** --delta Use a delta manifest in the commit process
2449
+** --editor NAME Text editor to use for check-in comment.
24492450
** --hash Verify file status using hashing rather
24502451
** than relying on filesystem mtimes
24512452
** --if-changes Make this command a silent no-op if there
24522453
** are no changes
24532454
** --ignore-clock-skew If a clock skew is detected, ignore it and
@@ -2599,10 +2600,11 @@
25992600
useCksum = db_get_boolean("repo-cksum", 1);
26002601
bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0;
26012602
outputManifest = db_get_manifest_setting(0);
26022603
mxSize = db_large_file_size();
26032604
if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0;
2605
+ (void)fossil_text_editor();
26042606
verify_all_options();
26052607
26062608
/* The --no-warnings flag and the --force flag each imply
26072609
** the --no-verify-comment flag */
26082610
if( noWarningFlag || forceFlag ){
26092611
--- src/checkin.c
+++ src/checkin.c
@@ -2444,10 +2444,11 @@
2444 ** --close Close the branch being committed
2445 ** --date-override DATETIME Make DATETIME the time of the check-in.
2446 ** Useful when importing historical check-ins
2447 ** from another version control system.
2448 ** --delta Use a delta manifest in the commit process
 
2449 ** --hash Verify file status using hashing rather
2450 ** than relying on filesystem mtimes
2451 ** --if-changes Make this command a silent no-op if there
2452 ** are no changes
2453 ** --ignore-clock-skew If a clock skew is detected, ignore it and
@@ -2599,10 +2600,11 @@
2599 useCksum = db_get_boolean("repo-cksum", 1);
2600 bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0;
2601 outputManifest = db_get_manifest_setting(0);
2602 mxSize = db_large_file_size();
2603 if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0;
 
2604 verify_all_options();
2605
2606 /* The --no-warnings flag and the --force flag each imply
2607 ** the --no-verify-comment flag */
2608 if( noWarningFlag || forceFlag ){
2609
--- src/checkin.c
+++ src/checkin.c
@@ -2444,10 +2444,11 @@
2444 ** --close Close the branch being committed
2445 ** --date-override DATETIME Make DATETIME the time of the check-in.
2446 ** Useful when importing historical check-ins
2447 ** from another version control system.
2448 ** --delta Use a delta manifest in the commit process
2449 ** --editor NAME Text editor to use for check-in comment.
2450 ** --hash Verify file status using hashing rather
2451 ** than relying on filesystem mtimes
2452 ** --if-changes Make this command a silent no-op if there
2453 ** are no changes
2454 ** --ignore-clock-skew If a clock skew is detected, ignore it and
@@ -2599,10 +2600,11 @@
2600 useCksum = db_get_boolean("repo-cksum", 1);
2601 bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0;
2602 outputManifest = db_get_manifest_setting(0);
2603 mxSize = db_large_file_size();
2604 if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0;
2605 (void)fossil_text_editor();
2606 verify_all_options();
2607
2608 /* The --no-warnings flag and the --force flag each imply
2609 ** the --no-verify-comment flag */
2610 if( noWarningFlag || forceFlag ){
2611
--- src/unversioned.c
+++ src/unversioned.c
@@ -246,10 +246,12 @@
246246
** a single file at a time.
247247
**
248248
** cat FILE ... Concatenate the content of FILEs to stdout.
249249
**
250250
** edit FILE Bring up FILE in a text editor for modification.
251
+** Options:
252
+** --editor NAME Name of the text editor to use
251253
**
252254
** export FILE OUTPUT Write the content of FILE into OUTPUT on disk
253255
**
254256
** list | ls Show all unversioned files held in the local
255257
** repository.
@@ -361,17 +363,17 @@
361363
const char *zTFile; /* Temporary file */
362364
const char *zUVFile; /* Name of the unversioned file */
363365
char *zCmd; /* Command to run the text editor */
364366
Blob content; /* Content of the unversioned file */
365367
366
- verify_all_options();
367
- if( g.argc!=4) usage("edit UVFILE");
368
- zUVFile = g.argv[3];
369368
zEditor = fossil_text_editor();
370369
if( zEditor==0 ){
371370
fossil_fatal("no text editor - set the VISUAL env variable");
372371
}
372
+ verify_all_options();
373
+ if( g.argc!=4) usage("edit UVFILE");
374
+ zUVFile = g.argv[3];
373375
zTFile = fossil_temp_filename();
374376
if( zTFile==0 ) fossil_fatal("cannot find a temporary filename");
375377
db_begin_transaction();
376378
content_rcvid_init("#!fossil unversioned edit");
377379
if( unversioned_content(zUVFile, &content)==0 ){
378380
--- src/unversioned.c
+++ src/unversioned.c
@@ -246,10 +246,12 @@
246 ** a single file at a time.
247 **
248 ** cat FILE ... Concatenate the content of FILEs to stdout.
249 **
250 ** edit FILE Bring up FILE in a text editor for modification.
 
 
251 **
252 ** export FILE OUTPUT Write the content of FILE into OUTPUT on disk
253 **
254 ** list | ls Show all unversioned files held in the local
255 ** repository.
@@ -361,17 +363,17 @@
361 const char *zTFile; /* Temporary file */
362 const char *zUVFile; /* Name of the unversioned file */
363 char *zCmd; /* Command to run the text editor */
364 Blob content; /* Content of the unversioned file */
365
366 verify_all_options();
367 if( g.argc!=4) usage("edit UVFILE");
368 zUVFile = g.argv[3];
369 zEditor = fossil_text_editor();
370 if( zEditor==0 ){
371 fossil_fatal("no text editor - set the VISUAL env variable");
372 }
 
 
 
373 zTFile = fossil_temp_filename();
374 if( zTFile==0 ) fossil_fatal("cannot find a temporary filename");
375 db_begin_transaction();
376 content_rcvid_init("#!fossil unversioned edit");
377 if( unversioned_content(zUVFile, &content)==0 ){
378
--- src/unversioned.c
+++ src/unversioned.c
@@ -246,10 +246,12 @@
246 ** a single file at a time.
247 **
248 ** cat FILE ... Concatenate the content of FILEs to stdout.
249 **
250 ** edit FILE Bring up FILE in a text editor for modification.
251 ** Options:
252 ** --editor NAME Name of the text editor to use
253 **
254 ** export FILE OUTPUT Write the content of FILE into OUTPUT on disk
255 **
256 ** list | ls Show all unversioned files held in the local
257 ** repository.
@@ -361,17 +363,17 @@
363 const char *zTFile; /* Temporary file */
364 const char *zUVFile; /* Name of the unversioned file */
365 char *zCmd; /* Command to run the text editor */
366 Blob content; /* Content of the unversioned file */
367
 
 
 
368 zEditor = fossil_text_editor();
369 if( zEditor==0 ){
370 fossil_fatal("no text editor - set the VISUAL env variable");
371 }
372 verify_all_options();
373 if( g.argc!=4) usage("edit UVFILE");
374 zUVFile = g.argv[3];
375 zTFile = fossil_temp_filename();
376 if( zTFile==0 ) fossil_fatal("cannot find a temporary filename");
377 db_begin_transaction();
378 content_rcvid_init("#!fossil unversioned edit");
379 if( unversioned_content(zUVFile, &content)==0 ){
380
+16 -6
--- src/util.c
+++ src/util.c
@@ -666,23 +666,33 @@
666666
/*
667667
** Return the name of the users preferred text editor. Return NULL if
668668
** not found.
669669
**
670670
** Search algorithm:
671
-** (1) The local "editor" setting
672
-** (2) The global "editor" setting
673
-** (3) The VISUAL environment variable
674
-** (4) The EDITOR environment variable
675
-** (5) Any of the following programs that are available:
671
+** (1) The value of the --editor command-line argument
672
+** (2) The local "editor" setting
673
+** (3) The global "editor" setting
674
+** (4) The VISUAL environment variable
675
+** (5) The EDITOR environment variable
676
+** (6) Any of the following programs that are available:
676677
** notepad, nano, pico, jove, edit, vi, vim, ed,
678
+**
679
+** The search only occurs once, the first time this routine is called.
680
+** Second and subsequent invocations always return the same value.
677681
*/
678682
const char *fossil_text_editor(void){
679
- const char *zEditor = db_get("editor", 0);
683
+ static const char *zEditor = 0;
680684
const char *azStdEd[] = {
681685
"notepad", "nano", "pico", "jove", "edit", "vi", "vim", "ed"
682686
};
683687
int i = 0;
688
+ if( zEditor==0 ){
689
+ zEditor = find_option("editor",0,1);
690
+ }
691
+ if( zEditor==0 ){
692
+ zEditor = db_get("editor", 0);
693
+ }
684694
if( zEditor==0 ){
685695
zEditor = fossil_getenv("VISUAL");
686696
}
687697
if( zEditor==0 ){
688698
zEditor = fossil_getenv("EDITOR");
689699
--- src/util.c
+++ src/util.c
@@ -666,23 +666,33 @@
666 /*
667 ** Return the name of the users preferred text editor. Return NULL if
668 ** not found.
669 **
670 ** Search algorithm:
671 ** (1) The local "editor" setting
672 ** (2) The global "editor" setting
673 ** (3) The VISUAL environment variable
674 ** (4) The EDITOR environment variable
675 ** (5) Any of the following programs that are available:
 
676 ** notepad, nano, pico, jove, edit, vi, vim, ed,
 
 
 
677 */
678 const char *fossil_text_editor(void){
679 const char *zEditor = db_get("editor", 0);
680 const char *azStdEd[] = {
681 "notepad", "nano", "pico", "jove", "edit", "vi", "vim", "ed"
682 };
683 int i = 0;
 
 
 
 
 
 
684 if( zEditor==0 ){
685 zEditor = fossil_getenv("VISUAL");
686 }
687 if( zEditor==0 ){
688 zEditor = fossil_getenv("EDITOR");
689
--- src/util.c
+++ src/util.c
@@ -666,23 +666,33 @@
666 /*
667 ** Return the name of the users preferred text editor. Return NULL if
668 ** not found.
669 **
670 ** Search algorithm:
671 ** (1) The value of the --editor command-line argument
672 ** (2) The local "editor" setting
673 ** (3) The global "editor" setting
674 ** (4) The VISUAL environment variable
675 ** (5) The EDITOR environment variable
676 ** (6) Any of the following programs that are available:
677 ** notepad, nano, pico, jove, edit, vi, vim, ed,
678 **
679 ** The search only occurs once, the first time this routine is called.
680 ** Second and subsequent invocations always return the same value.
681 */
682 const char *fossil_text_editor(void){
683 static const char *zEditor = 0;
684 const char *azStdEd[] = {
685 "notepad", "nano", "pico", "jove", "edit", "vi", "vim", "ed"
686 };
687 int i = 0;
688 if( zEditor==0 ){
689 zEditor = find_option("editor",0,1);
690 }
691 if( zEditor==0 ){
692 zEditor = db_get("editor", 0);
693 }
694 if( zEditor==0 ){
695 zEditor = fossil_getenv("VISUAL");
696 }
697 if( zEditor==0 ){
698 zEditor = fossil_getenv("EDITOR");
699

Keyboard Shortcuts

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