Fossil SCM
The various "diff --tk" commands now take an optional, undocumented option "--script FILENAME" that causes the Tk script to be written into FILENAME rather than to be run. One use for this is to get a copy of the diff script in a form were it can be easily edited and enhanced before being moved back into Fossil.
Commit
326a736493e4bd8eb00fbb33eb9d7c341c3ae6d7
Parent
da96f916cb02bdb…
1 file changed
+17
-6
+17
-6
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -915,11 +915,11 @@ | ||
| 915 | 915 | ** (3) Delete the temp file. |
| 916 | 916 | */ |
| 917 | 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | 918 | int i; |
| 919 | 919 | Blob script; |
| 920 | - char *zTempFile; | |
| 920 | + char *zTempFile = 0; | |
| 921 | 921 | char *zCmd; |
| 922 | 922 | blob_zero(&script); |
| 923 | 923 | blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v", |
| 924 | 924 | g.nameOfExe, zSubCmd); |
| 925 | 925 | for(i=firstArg; i<g.argc; i++){ |
| @@ -926,20 +926,31 @@ | ||
| 926 | 926 | const char *z = g.argv[i]; |
| 927 | 927 | if( z[0]=='-' ){ |
| 928 | 928 | if( strglob("*-html",z) ) continue; |
| 929 | 929 | if( strglob("*-y",z) ) continue; |
| 930 | 930 | if( strglob("*-i",z) ) continue; |
| 931 | + if( strglob("*-script",z) && i<g.argc-1 ){ | |
| 932 | + i++; | |
| 933 | + zTempFile = g.argv[i]; | |
| 934 | + continue; | |
| 935 | + } | |
| 931 | 936 | } |
| 932 | 937 | blob_append(&script, " ", 1); |
| 933 | 938 | shell_escape(&script, z); |
| 934 | 939 | } |
| 935 | 940 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 936 | - zTempFile = write_blob_to_temp_file(&script); | |
| 937 | - zCmd = mprintf("tclsh \"%s\"", zTempFile); | |
| 938 | - fossil_system(zCmd); | |
| 939 | - file_delete(zTempFile); | |
| 940 | - fossil_free(zCmd); | |
| 941 | + if( zTempFile ){ | |
| 942 | + blob_write_to_file(&script, zTempFile); | |
| 943 | + fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); | |
| 944 | + }else{ | |
| 945 | + zTempFile = write_blob_to_temp_file(&script); | |
| 946 | + zCmd = mprintf("tclsh \"%s\"", zTempFile); | |
| 947 | + fossil_system(zCmd); | |
| 948 | + file_delete(zTempFile); | |
| 949 | + fossil_free(zCmd); | |
| 950 | + } | |
| 951 | + blob_reset(&script); | |
| 941 | 952 | } |
| 942 | 953 | |
| 943 | 954 | /* |
| 944 | 955 | ** Returns non-zero if files that may be binary should be used with external |
| 945 | 956 | ** diff programs. |
| 946 | 957 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -915,11 +915,11 @@ | |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| 920 | char *zTempFile; |
| 921 | char *zCmd; |
| 922 | blob_zero(&script); |
| 923 | blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v", |
| 924 | g.nameOfExe, zSubCmd); |
| 925 | for(i=firstArg; i<g.argc; i++){ |
| @@ -926,20 +926,31 @@ | |
| 926 | const char *z = g.argv[i]; |
| 927 | if( z[0]=='-' ){ |
| 928 | if( strglob("*-html",z) ) continue; |
| 929 | if( strglob("*-y",z) ) continue; |
| 930 | if( strglob("*-i",z) ) continue; |
| 931 | } |
| 932 | blob_append(&script, " ", 1); |
| 933 | shell_escape(&script, z); |
| 934 | } |
| 935 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 936 | zTempFile = write_blob_to_temp_file(&script); |
| 937 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 938 | fossil_system(zCmd); |
| 939 | file_delete(zTempFile); |
| 940 | fossil_free(zCmd); |
| 941 | } |
| 942 | |
| 943 | /* |
| 944 | ** Returns non-zero if files that may be binary should be used with external |
| 945 | ** diff programs. |
| 946 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -915,11 +915,11 @@ | |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| 920 | char *zTempFile = 0; |
| 921 | char *zCmd; |
| 922 | blob_zero(&script); |
| 923 | blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v", |
| 924 | g.nameOfExe, zSubCmd); |
| 925 | for(i=firstArg; i<g.argc; i++){ |
| @@ -926,20 +926,31 @@ | |
| 926 | const char *z = g.argv[i]; |
| 927 | if( z[0]=='-' ){ |
| 928 | if( strglob("*-html",z) ) continue; |
| 929 | if( strglob("*-y",z) ) continue; |
| 930 | if( strglob("*-i",z) ) continue; |
| 931 | if( strglob("*-script",z) && i<g.argc-1 ){ |
| 932 | i++; |
| 933 | zTempFile = g.argv[i]; |
| 934 | continue; |
| 935 | } |
| 936 | } |
| 937 | blob_append(&script, " ", 1); |
| 938 | shell_escape(&script, z); |
| 939 | } |
| 940 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 941 | if( zTempFile ){ |
| 942 | blob_write_to_file(&script, zTempFile); |
| 943 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 944 | }else{ |
| 945 | zTempFile = write_blob_to_temp_file(&script); |
| 946 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 947 | fossil_system(zCmd); |
| 948 | file_delete(zTempFile); |
| 949 | fossil_free(zCmd); |
| 950 | } |
| 951 | blob_reset(&script); |
| 952 | } |
| 953 | |
| 954 | /* |
| 955 | ** Returns non-zero if files that may be binary should be used with external |
| 956 | ** diff programs. |
| 957 |