Fossil SCM
Add the --editor option to "fossil commit" and "fossil uv edit".
Commit
76759875516b4dddc269515ff1cf24e4c3240b908fd90b9bfbcb2029b48d0d88
Parent
c2b56250c055aa9…
3 files changed
+2
+5
-3
+16
-6
+2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -2444,10 +2444,11 @@ | ||
| 2444 | 2444 | ** --close Close the branch being committed |
| 2445 | 2445 | ** --date-override DATETIME Make DATETIME the time of the check-in. |
| 2446 | 2446 | ** Useful when importing historical check-ins |
| 2447 | 2447 | ** from another version control system. |
| 2448 | 2448 | ** --delta Use a delta manifest in the commit process |
| 2449 | +** --editor NAME Text editor to use for check-in comment. | |
| 2449 | 2450 | ** --hash Verify file status using hashing rather |
| 2450 | 2451 | ** than relying on filesystem mtimes |
| 2451 | 2452 | ** --if-changes Make this command a silent no-op if there |
| 2452 | 2453 | ** are no changes |
| 2453 | 2454 | ** --ignore-clock-skew If a clock skew is detected, ignore it and |
| @@ -2599,10 +2600,11 @@ | ||
| 2599 | 2600 | useCksum = db_get_boolean("repo-cksum", 1); |
| 2600 | 2601 | bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0; |
| 2601 | 2602 | outputManifest = db_get_manifest_setting(0); |
| 2602 | 2603 | mxSize = db_large_file_size(); |
| 2603 | 2604 | if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0; |
| 2605 | + (void)fossil_text_editor(); | |
| 2604 | 2606 | verify_all_options(); |
| 2605 | 2607 | |
| 2606 | 2608 | /* The --no-warnings flag and the --force flag each imply |
| 2607 | 2609 | ** the --no-verify-comment flag */ |
| 2608 | 2610 | if( noWarningFlag || forceFlag ){ |
| 2609 | 2611 |
| --- 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 |
+5
-3
| --- src/unversioned.c | ||
| +++ src/unversioned.c | ||
| @@ -246,10 +246,12 @@ | ||
| 246 | 246 | ** a single file at a time. |
| 247 | 247 | ** |
| 248 | 248 | ** cat FILE ... Concatenate the content of FILEs to stdout. |
| 249 | 249 | ** |
| 250 | 250 | ** edit FILE Bring up FILE in a text editor for modification. |
| 251 | +** Options: | |
| 252 | +** --editor NAME Name of the text editor to use | |
| 251 | 253 | ** |
| 252 | 254 | ** export FILE OUTPUT Write the content of FILE into OUTPUT on disk |
| 253 | 255 | ** |
| 254 | 256 | ** list | ls Show all unversioned files held in the local |
| 255 | 257 | ** repository. |
| @@ -361,17 +363,17 @@ | ||
| 361 | 363 | const char *zTFile; /* Temporary file */ |
| 362 | 364 | const char *zUVFile; /* Name of the unversioned file */ |
| 363 | 365 | char *zCmd; /* Command to run the text editor */ |
| 364 | 366 | Blob content; /* Content of the unversioned file */ |
| 365 | 367 | |
| 366 | - verify_all_options(); | |
| 367 | - if( g.argc!=4) usage("edit UVFILE"); | |
| 368 | - zUVFile = g.argv[3]; | |
| 369 | 368 | zEditor = fossil_text_editor(); |
| 370 | 369 | if( zEditor==0 ){ |
| 371 | 370 | fossil_fatal("no text editor - set the VISUAL env variable"); |
| 372 | 371 | } |
| 372 | + verify_all_options(); | |
| 373 | + if( g.argc!=4) usage("edit UVFILE"); | |
| 374 | + zUVFile = g.argv[3]; | |
| 373 | 375 | zTFile = fossil_temp_filename(); |
| 374 | 376 | if( zTFile==0 ) fossil_fatal("cannot find a temporary filename"); |
| 375 | 377 | db_begin_transaction(); |
| 376 | 378 | content_rcvid_init("#!fossil unversioned edit"); |
| 377 | 379 | if( unversioned_content(zUVFile, &content)==0 ){ |
| 378 | 380 |
| --- 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 @@ | ||
| 666 | 666 | /* |
| 667 | 667 | ** Return the name of the users preferred text editor. Return NULL if |
| 668 | 668 | ** not found. |
| 669 | 669 | ** |
| 670 | 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: | |
| 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: | |
| 676 | 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. | |
| 677 | 681 | */ |
| 678 | 682 | const char *fossil_text_editor(void){ |
| 679 | - const char *zEditor = db_get("editor", 0); | |
| 683 | + static const char *zEditor = 0; | |
| 680 | 684 | const char *azStdEd[] = { |
| 681 | 685 | "notepad", "nano", "pico", "jove", "edit", "vi", "vim", "ed" |
| 682 | 686 | }; |
| 683 | 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 | + } | |
| 684 | 694 | if( zEditor==0 ){ |
| 685 | 695 | zEditor = fossil_getenv("VISUAL"); |
| 686 | 696 | } |
| 687 | 697 | if( zEditor==0 ){ |
| 688 | 698 | zEditor = fossil_getenv("EDITOR"); |
| 689 | 699 |
| --- 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 |