Fossil SCM
Add the undocumented --script FILENAME option to all diff operations that make use of the --tk option. The --script FILENAME option is used for testing and debugging only.
Commit
cee30a34d80d3fe7f8f6b275d0a5dc6f0c3aebb8
Parent
ddc313e8e103645…
2 files changed
+20
-6
+20
-6
+20
-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,34 @@ | ||
| 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 | + /* The undocumented --script FILENAME option causes the Tk script to | |
| 932 | + ** be written into the FILENAME instead of being run. This is used | |
| 933 | + ** for testing and debugging. */ | |
| 934 | + if( strglob("*-script",z) && i<g.argc-1 ){ | |
| 935 | + i++; | |
| 936 | + zTempFile = g.argv[i]; | |
| 937 | + continue; | |
| 938 | + } | |
| 931 | 939 | } |
| 932 | 940 | blob_append(&script, " ", 1); |
| 933 | 941 | shell_escape(&script, z); |
| 934 | 942 | } |
| 935 | 943 | 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); | |
| 944 | + if( zTempFile ){ | |
| 945 | + blob_write_to_file(&script, zTempFile); | |
| 946 | + fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); | |
| 947 | + }else{ | |
| 948 | + zTempFile = write_blob_to_temp_file(&script); | |
| 949 | + zCmd = mprintf("tclsh \"%s\"", zTempFile); | |
| 950 | + fossil_system(zCmd); | |
| 951 | + file_delete(zTempFile); | |
| 952 | + fossil_free(zCmd); | |
| 953 | + } | |
| 954 | + blob_reset(&script); | |
| 941 | 955 | } |
| 942 | 956 | |
| 943 | 957 | /* |
| 944 | 958 | ** Returns non-zero if files that may be binary should be used with external |
| 945 | 959 | ** diff programs. |
| 946 | 960 |
| --- 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,34 @@ | |
| 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,34 @@ | |
| 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 | /* The undocumented --script FILENAME option causes the Tk script to |
| 932 | ** be written into the FILENAME instead of being run. This is used |
| 933 | ** for testing and debugging. */ |
| 934 | if( strglob("*-script",z) && i<g.argc-1 ){ |
| 935 | i++; |
| 936 | zTempFile = g.argv[i]; |
| 937 | continue; |
| 938 | } |
| 939 | } |
| 940 | blob_append(&script, " ", 1); |
| 941 | shell_escape(&script, z); |
| 942 | } |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| 953 | } |
| 954 | blob_reset(&script); |
| 955 | } |
| 956 | |
| 957 | /* |
| 958 | ** Returns non-zero if files that may be binary should be used with external |
| 959 | ** diff programs. |
| 960 |
+20
-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,34 @@ | ||
| 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 | + /* The undocumented --script FILENAME option causes the Tk script to | |
| 932 | + ** be written into the FILENAME instead of being run. This is used | |
| 933 | + ** for testing and debugging. */ | |
| 934 | + if( strglob("*-script",z) && i<g.argc-1 ){ | |
| 935 | + i++; | |
| 936 | + zTempFile = g.argv[i]; | |
| 937 | + continue; | |
| 938 | + } | |
| 931 | 939 | } |
| 932 | 940 | blob_append(&script, " ", 1); |
| 933 | 941 | shell_escape(&script, z); |
| 934 | 942 | } |
| 935 | 943 | 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); | |
| 944 | + if( zTempFile ){ | |
| 945 | + blob_write_to_file(&script, zTempFile); | |
| 946 | + fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); | |
| 947 | + }else{ | |
| 948 | + zTempFile = write_blob_to_temp_file(&script); | |
| 949 | + zCmd = mprintf("tclsh \"%s\"", zTempFile); | |
| 950 | + fossil_system(zCmd); | |
| 951 | + file_delete(zTempFile); | |
| 952 | + fossil_free(zCmd); | |
| 953 | + } | |
| 954 | + blob_reset(&script); | |
| 941 | 955 | } |
| 942 | 956 | |
| 943 | 957 | /* |
| 944 | 958 | ** Returns non-zero if files that may be binary should be used with external |
| 945 | 959 | ** diff programs. |
| 946 | 960 |
| --- 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,34 @@ | |
| 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,34 @@ | |
| 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 | /* The undocumented --script FILENAME option causes the Tk script to |
| 932 | ** be written into the FILENAME instead of being run. This is used |
| 933 | ** for testing and debugging. */ |
| 934 | if( strglob("*-script",z) && i<g.argc-1 ){ |
| 935 | i++; |
| 936 | zTempFile = g.argv[i]; |
| 937 | continue; |
| 938 | } |
| 939 | } |
| 940 | blob_append(&script, " ", 1); |
| 941 | shell_escape(&script, z); |
| 942 | } |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| 953 | } |
| 954 | blob_reset(&script); |
| 955 | } |
| 956 | |
| 957 | /* |
| 958 | ** Returns non-zero if files that may be binary should be used with external |
| 959 | ** diff programs. |
| 960 |