Fossil SCM

Fix sub-command parsing in order to have the "gdiff" subcommand of the "patch" command working.

mgagnon 2023-05-09 21:44 trunk
Commit ec7822601487734a37f35541cbd0b73658a945843a086c4671474e41930262d9
1 file changed +6 -4
+6 -4
--- src/patch.c
+++ src/patch.c
@@ -861,13 +861,15 @@
861861
** are reverted and permanently lost.
862862
** -n|--dry-run Do nothing, but print what would have happened
863863
** -v|--verbose Extra output explaining what happens
864864
**
865865
** > fossil patch diff [DIRECTORY] FILENAME
866
+** > fossil patch gdiff [DIRECTORY] FILENAME
866867
**
867868
** 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:
869871
**
870872
** -f|--force Continue trying to perform the diff even if
871873
** baseline information is missing from the current
872874
** repository
873875
**
@@ -908,11 +910,11 @@
908910
void patch_cmd(void){
909911
const char *zCmd;
910912
size_t n;
911913
if( g.argc<3 ){
912914
patch_usage:
913
- usage("apply|create|diff|pull|push|view");
915
+ usage("apply|create|diff|gdiff|pull|push|view");
914916
}
915917
zCmd = g.argv[2];
916918
n = strlen(zCmd);
917919
if( strncmp(zCmd, "apply", n)==0 ){
918920
char *zIn;
@@ -934,26 +936,26 @@
934936
verify_all_options();
935937
db_must_be_within_tree();
936938
patch_create(flags, zOut, stdout);
937939
fossil_free(zOut);
938940
}else
939
- if( strncmp(zCmd, "diff", n)==0 ){
941
+ if( (strncmp(zCmd, "diff", n)==0) || (strncmp(zCmd, "gdiff", n)==0) ){
940942
char *zIn;
941943
unsigned flags = 0;
942944
DiffConfig DCfg;
943945
944946
if( find_option("tk",0,0)!=0 ){
945947
db_close(0);
946948
diff_tk("patch diff", 3);
947949
return;
948950
}
949
- diff_options(&DCfg, zCmd[0]=='g', 0);
950951
db_find_and_open_repository(0, 0);
951952
if( find_option("force","f",0) ) flags |= PATCH_FORCE;
952953
verify_all_options();
953954
zIn = patch_find_patch_filename("apply");
954955
patch_attach(zIn, stdin);
956
+ diff_options(&DCfg, zCmd[0]=='g', 0);
955957
patch_diff(flags, &DCfg);
956958
fossil_free(zIn);
957959
}else
958960
if( strncmp(zCmd, "pull", n)==0 ){
959961
FILE *pIn = 0;
960962
--- 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

Keyboard Shortcuts

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