Fossil SCM
Fix sub-command parsing in order to have the "gdiff" subcommand of the "patch" command working.
Commit
ec7822601487734a37f35541cbd0b73658a945843a086c4671474e41930262d9
Parent
cc34f3cf49a70e5…
1 file changed
+6
-4
+6
-4
| --- src/patch.c | ||
| +++ src/patch.c | ||
| @@ -861,13 +861,15 @@ | ||
| 861 | 861 | ** are reverted and permanently lost. |
| 862 | 862 | ** -n|--dry-run Do nothing, but print what would have happened |
| 863 | 863 | ** -v|--verbose Extra output explaining what happens |
| 864 | 864 | ** |
| 865 | 865 | ** > fossil patch diff [DIRECTORY] FILENAME |
| 866 | +** > fossil patch gdiff [DIRECTORY] FILENAME | |
| 866 | 867 | ** |
| 867 | 868 | ** Show a human-readable diff for the patch. All the usual |
| 868 | -** diff flags described at "fossil help diff" apply. In addition: | |
| 869 | +** diff flags described at "fossil help diff" apply. With gdiff, | |
| 870 | +** gdiff-command is used instead of internal diff logic. In addition: | |
| 869 | 871 | ** |
| 870 | 872 | ** -f|--force Continue trying to perform the diff even if |
| 871 | 873 | ** baseline information is missing from the current |
| 872 | 874 | ** repository |
| 873 | 875 | ** |
| @@ -908,11 +910,11 @@ | ||
| 908 | 910 | void patch_cmd(void){ |
| 909 | 911 | const char *zCmd; |
| 910 | 912 | size_t n; |
| 911 | 913 | if( g.argc<3 ){ |
| 912 | 914 | patch_usage: |
| 913 | - usage("apply|create|diff|pull|push|view"); | |
| 915 | + usage("apply|create|diff|gdiff|pull|push|view"); | |
| 914 | 916 | } |
| 915 | 917 | zCmd = g.argv[2]; |
| 916 | 918 | n = strlen(zCmd); |
| 917 | 919 | if( strncmp(zCmd, "apply", n)==0 ){ |
| 918 | 920 | char *zIn; |
| @@ -934,26 +936,26 @@ | ||
| 934 | 936 | verify_all_options(); |
| 935 | 937 | db_must_be_within_tree(); |
| 936 | 938 | patch_create(flags, zOut, stdout); |
| 937 | 939 | fossil_free(zOut); |
| 938 | 940 | }else |
| 939 | - if( strncmp(zCmd, "diff", n)==0 ){ | |
| 941 | + if( (strncmp(zCmd, "diff", n)==0) || (strncmp(zCmd, "gdiff", n)==0) ){ | |
| 940 | 942 | char *zIn; |
| 941 | 943 | unsigned flags = 0; |
| 942 | 944 | DiffConfig DCfg; |
| 943 | 945 | |
| 944 | 946 | if( find_option("tk",0,0)!=0 ){ |
| 945 | 947 | db_close(0); |
| 946 | 948 | diff_tk("patch diff", 3); |
| 947 | 949 | return; |
| 948 | 950 | } |
| 949 | - diff_options(&DCfg, zCmd[0]=='g', 0); | |
| 950 | 951 | db_find_and_open_repository(0, 0); |
| 951 | 952 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 952 | 953 | verify_all_options(); |
| 953 | 954 | zIn = patch_find_patch_filename("apply"); |
| 954 | 955 | patch_attach(zIn, stdin); |
| 956 | + diff_options(&DCfg, zCmd[0]=='g', 0); | |
| 955 | 957 | patch_diff(flags, &DCfg); |
| 956 | 958 | fossil_free(zIn); |
| 957 | 959 | }else |
| 958 | 960 | if( strncmp(zCmd, "pull", n)==0 ){ |
| 959 | 961 | FILE *pIn = 0; |
| 960 | 962 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -861,13 +861,15 @@ | |
| 861 | ** are reverted and permanently lost. |
| 862 | ** -n|--dry-run Do nothing, but print what would have happened |
| 863 | ** -v|--verbose Extra output explaining what happens |
| 864 | ** |
| 865 | ** > fossil patch diff [DIRECTORY] FILENAME |
| 866 | ** |
| 867 | ** Show a human-readable diff for the patch. All the usual |
| 868 | ** diff flags described at "fossil help diff" apply. In addition: |
| 869 | ** |
| 870 | ** -f|--force Continue trying to perform the diff even if |
| 871 | ** baseline information is missing from the current |
| 872 | ** repository |
| 873 | ** |
| @@ -908,11 +910,11 @@ | |
| 908 | void patch_cmd(void){ |
| 909 | const char *zCmd; |
| 910 | size_t n; |
| 911 | if( g.argc<3 ){ |
| 912 | patch_usage: |
| 913 | usage("apply|create|diff|pull|push|view"); |
| 914 | } |
| 915 | zCmd = g.argv[2]; |
| 916 | n = strlen(zCmd); |
| 917 | if( strncmp(zCmd, "apply", n)==0 ){ |
| 918 | char *zIn; |
| @@ -934,26 +936,26 @@ | |
| 934 | verify_all_options(); |
| 935 | db_must_be_within_tree(); |
| 936 | patch_create(flags, zOut, stdout); |
| 937 | fossil_free(zOut); |
| 938 | }else |
| 939 | if( strncmp(zCmd, "diff", n)==0 ){ |
| 940 | char *zIn; |
| 941 | unsigned flags = 0; |
| 942 | DiffConfig DCfg; |
| 943 | |
| 944 | if( find_option("tk",0,0)!=0 ){ |
| 945 | db_close(0); |
| 946 | diff_tk("patch diff", 3); |
| 947 | return; |
| 948 | } |
| 949 | diff_options(&DCfg, zCmd[0]=='g', 0); |
| 950 | db_find_and_open_repository(0, 0); |
| 951 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 952 | verify_all_options(); |
| 953 | zIn = patch_find_patch_filename("apply"); |
| 954 | patch_attach(zIn, stdin); |
| 955 | patch_diff(flags, &DCfg); |
| 956 | fossil_free(zIn); |
| 957 | }else |
| 958 | if( strncmp(zCmd, "pull", n)==0 ){ |
| 959 | FILE *pIn = 0; |
| 960 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -861,13 +861,15 @@ | |
| 861 | ** are reverted and permanently lost. |
| 862 | ** -n|--dry-run Do nothing, but print what would have happened |
| 863 | ** -v|--verbose Extra output explaining what happens |
| 864 | ** |
| 865 | ** > fossil patch diff [DIRECTORY] FILENAME |
| 866 | ** > fossil patch gdiff [DIRECTORY] FILENAME |
| 867 | ** |
| 868 | ** Show a human-readable diff for the patch. All the usual |
| 869 | ** diff flags described at "fossil help diff" apply. With gdiff, |
| 870 | ** gdiff-command is used instead of internal diff logic. In addition: |
| 871 | ** |
| 872 | ** -f|--force Continue trying to perform the diff even if |
| 873 | ** baseline information is missing from the current |
| 874 | ** repository |
| 875 | ** |
| @@ -908,11 +910,11 @@ | |
| 910 | void patch_cmd(void){ |
| 911 | const char *zCmd; |
| 912 | size_t n; |
| 913 | if( g.argc<3 ){ |
| 914 | patch_usage: |
| 915 | usage("apply|create|diff|gdiff|pull|push|view"); |
| 916 | } |
| 917 | zCmd = g.argv[2]; |
| 918 | n = strlen(zCmd); |
| 919 | if( strncmp(zCmd, "apply", n)==0 ){ |
| 920 | char *zIn; |
| @@ -934,26 +936,26 @@ | |
| 936 | verify_all_options(); |
| 937 | db_must_be_within_tree(); |
| 938 | patch_create(flags, zOut, stdout); |
| 939 | fossil_free(zOut); |
| 940 | }else |
| 941 | if( (strncmp(zCmd, "diff", n)==0) || (strncmp(zCmd, "gdiff", n)==0) ){ |
| 942 | char *zIn; |
| 943 | unsigned flags = 0; |
| 944 | DiffConfig DCfg; |
| 945 | |
| 946 | if( find_option("tk",0,0)!=0 ){ |
| 947 | db_close(0); |
| 948 | diff_tk("patch diff", 3); |
| 949 | return; |
| 950 | } |
| 951 | db_find_and_open_repository(0, 0); |
| 952 | if( find_option("force","f",0) ) flags |= PATCH_FORCE; |
| 953 | verify_all_options(); |
| 954 | zIn = patch_find_patch_filename("apply"); |
| 955 | patch_attach(zIn, stdin); |
| 956 | diff_options(&DCfg, zCmd[0]=='g', 0); |
| 957 | patch_diff(flags, &DCfg); |
| 958 | fossil_free(zIn); |
| 959 | }else |
| 960 | if( strncmp(zCmd, "pull", n)==0 ){ |
| 961 | FILE *pIn = 0; |
| 962 |