Fossil SCM

Added -- support to (diff, finfo, grep, new). We can now grep for patterns which start with a dash.

stephan 2019-09-27 22:51 double-dash-flag
Commit 639b2c183e216c28de5f218233243d86439ad908bf1f5fdeef904edf21055f34
+5 -3
--- src/db.c
+++ src/db.c
@@ -2213,12 +2213,12 @@
22132213
22142214
/*
22152215
** COMMAND: new*
22162216
** COMMAND: init
22172217
**
2218
-** Usage: %fossil new ?OPTIONS? FILENAME
2219
-** or: %fossil init ?OPTIONS? FILENAME
2218
+** Usage: %fossil new ?OPTIONS? ?--? FILENAME
2219
+** or: %fossil init ?OPTIONS? ?--? FILENAME
22202220
**
22212221
** Create a repository for a new project in the file named FILENAME.
22222222
** This command is distinct from "clone". The "clone" command makes
22232223
** a copy of an existing project. This command starts a new project.
22242224
**
@@ -2238,10 +2238,12 @@
22382238
** Options:
22392239
** --template FILE Copy settings from repository file
22402240
** --admin-user|-A USERNAME Select given USERNAME as admin user
22412241
** --date-override DATETIME Use DATETIME as time of the initial check-in
22422242
** --sha1 Use a initial hash policy of "sha1"
2243
+** -- Treat all following arguments as files,
2244
+** even if they look like flags.
22432245
**
22442246
** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in
22452247
** year-month-day form, it may be truncated, the "T" may be replaced by
22462248
** a space, and it may also name a timezone offset from UTC as "-HH:MM"
22472249
** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z"
@@ -2260,11 +2262,11 @@
22602262
zTemplate = find_option("template",0,1);
22612263
zDate = find_option("date-override",0,1);
22622264
zDefaultUser = find_option("admin-user","A",1);
22632265
bUseSha1 = find_option("sha1",0,0)!=0;
22642266
/* We should be done with options.. */
2265
- verify_all_options();
2267
+ verify_all_options2();
22662268
22672269
if( g.argc!=3 ){
22682270
usage("REPOSITORY-NAME");
22692271
}
22702272
22712273
--- src/db.c
+++ src/db.c
@@ -2213,12 +2213,12 @@
2213
2214 /*
2215 ** COMMAND: new*
2216 ** COMMAND: init
2217 **
2218 ** Usage: %fossil new ?OPTIONS? FILENAME
2219 ** or: %fossil init ?OPTIONS? FILENAME
2220 **
2221 ** Create a repository for a new project in the file named FILENAME.
2222 ** This command is distinct from "clone". The "clone" command makes
2223 ** a copy of an existing project. This command starts a new project.
2224 **
@@ -2238,10 +2238,12 @@
2238 ** Options:
2239 ** --template FILE Copy settings from repository file
2240 ** --admin-user|-A USERNAME Select given USERNAME as admin user
2241 ** --date-override DATETIME Use DATETIME as time of the initial check-in
2242 ** --sha1 Use a initial hash policy of "sha1"
 
 
2243 **
2244 ** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in
2245 ** year-month-day form, it may be truncated, the "T" may be replaced by
2246 ** a space, and it may also name a timezone offset from UTC as "-HH:MM"
2247 ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z"
@@ -2260,11 +2262,11 @@
2260 zTemplate = find_option("template",0,1);
2261 zDate = find_option("date-override",0,1);
2262 zDefaultUser = find_option("admin-user","A",1);
2263 bUseSha1 = find_option("sha1",0,0)!=0;
2264 /* We should be done with options.. */
2265 verify_all_options();
2266
2267 if( g.argc!=3 ){
2268 usage("REPOSITORY-NAME");
2269 }
2270
2271
--- src/db.c
+++ src/db.c
@@ -2213,12 +2213,12 @@
2213
2214 /*
2215 ** COMMAND: new*
2216 ** COMMAND: init
2217 **
2218 ** Usage: %fossil new ?OPTIONS? ?--? FILENAME
2219 ** or: %fossil init ?OPTIONS? ?--? FILENAME
2220 **
2221 ** Create a repository for a new project in the file named FILENAME.
2222 ** This command is distinct from "clone". The "clone" command makes
2223 ** a copy of an existing project. This command starts a new project.
2224 **
@@ -2238,10 +2238,12 @@
2238 ** Options:
2239 ** --template FILE Copy settings from repository file
2240 ** --admin-user|-A USERNAME Select given USERNAME as admin user
2241 ** --date-override DATETIME Use DATETIME as time of the initial check-in
2242 ** --sha1 Use a initial hash policy of "sha1"
2243 ** -- Treat all following arguments as files,
2244 ** even if they look like flags.
2245 **
2246 ** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in
2247 ** year-month-day form, it may be truncated, the "T" may be replaced by
2248 ** a space, and it may also name a timezone offset from UTC as "-HH:MM"
2249 ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z"
@@ -2260,11 +2262,11 @@
2262 zTemplate = find_option("template",0,1);
2263 zDate = find_option("date-override",0,1);
2264 zDefaultUser = find_option("admin-user","A",1);
2265 bUseSha1 = find_option("sha1",0,0)!=0;
2266 /* We should be done with options.. */
2267 verify_all_options2();
2268
2269 if( g.argc!=3 ){
2270 usage("REPOSITORY-NAME");
2271 }
2272
2273
+4 -2
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -780,11 +780,11 @@
780780
781781
/*
782782
** COMMAND: diff
783783
** COMMAND: gdiff
784784
**
785
-** Usage: %fossil diff|gdiff ?OPTIONS? ?FILE1? ?FILE2 ...?
785
+** Usage: %fossil diff|gdiff ?OPTIONS? ?--? ?FILE1? ?FILE2 ...?
786786
**
787787
** Show the difference between the current version of each of the FILEs
788788
** specified (as they exist on disk) and that same file as it was checked
789789
** out. Or if the FILE arguments are omitted, show the unsaved changes
790790
** currently in the working check-out.
@@ -839,10 +839,12 @@
839839
** --unified Unified diff
840840
** -v|--verbose Output complete text of added or deleted files
841841
** -w|--ignore-all-space Ignore white space when comparing lines
842842
** -W|--width <num> Width of lines in side-by-side diff
843843
** -Z|--ignore-trailing-space Ignore changes to end-of-line whitespace
844
+** -- Treat all following arguments as files,
845
+** even if they look like flags.
844846
*/
845847
void diff_cmd(void){
846848
int isGDiff; /* True for gdiff. False for normal diff */
847849
int isInternDiff; /* True for internal diff */
848850
int verboseFlag; /* True if -v or --verbose flag is used */
@@ -900,11 +902,11 @@
900902
if( zDiffCmd==0 ) zDiffCmd = diff_command_external(isGDiff);
901903
}
902904
zBinGlob = diff_get_binary_glob();
903905
fIncludeBinary = diff_include_binary_files();
904906
determine_exec_relative_option(1);
905
- verify_all_options();
907
+ verify_all_options2();
906908
if( g.argc>=3 ){
907909
int i;
908910
Blob fname;
909911
pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
910912
memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
911913
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -780,11 +780,11 @@
780
781 /*
782 ** COMMAND: diff
783 ** COMMAND: gdiff
784 **
785 ** Usage: %fossil diff|gdiff ?OPTIONS? ?FILE1? ?FILE2 ...?
786 **
787 ** Show the difference between the current version of each of the FILEs
788 ** specified (as they exist on disk) and that same file as it was checked
789 ** out. Or if the FILE arguments are omitted, show the unsaved changes
790 ** currently in the working check-out.
@@ -839,10 +839,12 @@
839 ** --unified Unified diff
840 ** -v|--verbose Output complete text of added or deleted files
841 ** -w|--ignore-all-space Ignore white space when comparing lines
842 ** -W|--width <num> Width of lines in side-by-side diff
843 ** -Z|--ignore-trailing-space Ignore changes to end-of-line whitespace
 
 
844 */
845 void diff_cmd(void){
846 int isGDiff; /* True for gdiff. False for normal diff */
847 int isInternDiff; /* True for internal diff */
848 int verboseFlag; /* True if -v or --verbose flag is used */
@@ -900,11 +902,11 @@
900 if( zDiffCmd==0 ) zDiffCmd = diff_command_external(isGDiff);
901 }
902 zBinGlob = diff_get_binary_glob();
903 fIncludeBinary = diff_include_binary_files();
904 determine_exec_relative_option(1);
905 verify_all_options();
906 if( g.argc>=3 ){
907 int i;
908 Blob fname;
909 pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
910 memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
911
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -780,11 +780,11 @@
780
781 /*
782 ** COMMAND: diff
783 ** COMMAND: gdiff
784 **
785 ** Usage: %fossil diff|gdiff ?OPTIONS? ?--? ?FILE1? ?FILE2 ...?
786 **
787 ** Show the difference between the current version of each of the FILEs
788 ** specified (as they exist on disk) and that same file as it was checked
789 ** out. Or if the FILE arguments are omitted, show the unsaved changes
790 ** currently in the working check-out.
@@ -839,10 +839,12 @@
839 ** --unified Unified diff
840 ** -v|--verbose Output complete text of added or deleted files
841 ** -w|--ignore-all-space Ignore white space when comparing lines
842 ** -W|--width <num> Width of lines in side-by-side diff
843 ** -Z|--ignore-trailing-space Ignore changes to end-of-line whitespace
844 ** -- Treat all following arguments as files,
845 ** even if they look like flags.
846 */
847 void diff_cmd(void){
848 int isGDiff; /* True for gdiff. False for normal diff */
849 int isInternDiff; /* True for internal diff */
850 int verboseFlag; /* True if -v or --verbose flag is used */
@@ -900,11 +902,11 @@
902 if( zDiffCmd==0 ) zDiffCmd = diff_command_external(isGDiff);
903 }
904 zBinGlob = diff_get_binary_glob();
905 fIncludeBinary = diff_include_binary_files();
906 determine_exec_relative_option(1);
907 verify_all_options2();
908 if( g.argc>=3 ){
909 int i;
910 Blob fname;
911 pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
912 memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
913
+6 -4
--- src/finfo.c
+++ src/finfo.c
@@ -21,11 +21,11 @@
2121
#include "finfo.h"
2222
2323
/*
2424
** COMMAND: finfo
2525
**
26
-** Usage: %fossil finfo ?OPTIONS? FILENAME
26
+** Usage: %fossil finfo ?OPTIONS? ?--? FILENAME
2727
**
2828
** Print the complete change history for a single file going backwards
2929
** in time. The default mode is -l.
3030
**
3131
** For the -l|--log mode: If "-b|--brief" is specified one line per revision
@@ -53,10 +53,12 @@
5353
** to stdout (only in print mode)
5454
** -s|--status select status mode (print a status indicator for FILE)
5555
** -W|--width <num> Width of lines (default is to auto-detect). Must be
5656
** >22 or 0 (= no limit, resulting in a single line per
5757
** entry).
58
+** -- Treat all following arguments as files, even if they
59
+** look like flags.
5860
**
5961
** See also: artifact, cat, descendants, info, leaves
6062
*/
6163
void finfo_cmd(void){
6264
db_must_be_within_tree();
@@ -65,11 +67,11 @@
6567
Blob line;
6668
Blob fname;
6769
int vid;
6870
6971
/* We should be done with options.. */
70
- verify_all_options();
72
+ verify_all_options2();
7173
7274
if( g.argc!=3 ) usage("-s|--status FILENAME");
7375
vid = db_lget_int("checkout", 0);
7476
if( vid==0 ){
7577
fossil_fatal("no checkout to finfo files in");
@@ -120,11 +122,11 @@
120122
Blob record;
121123
Blob fname;
122124
const char *zRevision = find_option("revision", "r", 1);
123125
124126
/* We should be done with options.. */
125
- verify_all_options();
127
+ verify_all_options2();
126128
127129
file_tree_name(g.argv[2], &fname, 0, 1);
128130
if( zRevision ){
129131
historical_blob(zRevision, blob_str(&fname), &record, 1);
130132
}else{
@@ -169,11 +171,11 @@
169171
}else{
170172
iWidth = -1;
171173
}
172174
173175
/* We should be done with options.. */
174
- verify_all_options();
176
+ verify_all_options2();
175177
176178
if( g.argc!=3 ){
177179
usage("?-l|--log? ?-b|--brief? FILENAME");
178180
}
179181
file_tree_name(g.argv[2], &fname, 0, 1);
180182
--- src/finfo.c
+++ src/finfo.c
@@ -21,11 +21,11 @@
21 #include "finfo.h"
22
23 /*
24 ** COMMAND: finfo
25 **
26 ** Usage: %fossil finfo ?OPTIONS? FILENAME
27 **
28 ** Print the complete change history for a single file going backwards
29 ** in time. The default mode is -l.
30 **
31 ** For the -l|--log mode: If "-b|--brief" is specified one line per revision
@@ -53,10 +53,12 @@
53 ** to stdout (only in print mode)
54 ** -s|--status select status mode (print a status indicator for FILE)
55 ** -W|--width <num> Width of lines (default is to auto-detect). Must be
56 ** >22 or 0 (= no limit, resulting in a single line per
57 ** entry).
 
 
58 **
59 ** See also: artifact, cat, descendants, info, leaves
60 */
61 void finfo_cmd(void){
62 db_must_be_within_tree();
@@ -65,11 +67,11 @@
65 Blob line;
66 Blob fname;
67 int vid;
68
69 /* We should be done with options.. */
70 verify_all_options();
71
72 if( g.argc!=3 ) usage("-s|--status FILENAME");
73 vid = db_lget_int("checkout", 0);
74 if( vid==0 ){
75 fossil_fatal("no checkout to finfo files in");
@@ -120,11 +122,11 @@
120 Blob record;
121 Blob fname;
122 const char *zRevision = find_option("revision", "r", 1);
123
124 /* We should be done with options.. */
125 verify_all_options();
126
127 file_tree_name(g.argv[2], &fname, 0, 1);
128 if( zRevision ){
129 historical_blob(zRevision, blob_str(&fname), &record, 1);
130 }else{
@@ -169,11 +171,11 @@
169 }else{
170 iWidth = -1;
171 }
172
173 /* We should be done with options.. */
174 verify_all_options();
175
176 if( g.argc!=3 ){
177 usage("?-l|--log? ?-b|--brief? FILENAME");
178 }
179 file_tree_name(g.argv[2], &fname, 0, 1);
180
--- src/finfo.c
+++ src/finfo.c
@@ -21,11 +21,11 @@
21 #include "finfo.h"
22
23 /*
24 ** COMMAND: finfo
25 **
26 ** Usage: %fossil finfo ?OPTIONS? ?--? FILENAME
27 **
28 ** Print the complete change history for a single file going backwards
29 ** in time. The default mode is -l.
30 **
31 ** For the -l|--log mode: If "-b|--brief" is specified one line per revision
@@ -53,10 +53,12 @@
53 ** to stdout (only in print mode)
54 ** -s|--status select status mode (print a status indicator for FILE)
55 ** -W|--width <num> Width of lines (default is to auto-detect). Must be
56 ** >22 or 0 (= no limit, resulting in a single line per
57 ** entry).
58 ** -- Treat all following arguments as files, even if they
59 ** look like flags.
60 **
61 ** See also: artifact, cat, descendants, info, leaves
62 */
63 void finfo_cmd(void){
64 db_must_be_within_tree();
@@ -65,11 +67,11 @@
67 Blob line;
68 Blob fname;
69 int vid;
70
71 /* We should be done with options.. */
72 verify_all_options2();
73
74 if( g.argc!=3 ) usage("-s|--status FILENAME");
75 vid = db_lget_int("checkout", 0);
76 if( vid==0 ){
77 fossil_fatal("no checkout to finfo files in");
@@ -120,11 +122,11 @@
122 Blob record;
123 Blob fname;
124 const char *zRevision = find_option("revision", "r", 1);
125
126 /* We should be done with options.. */
127 verify_all_options2();
128
129 file_tree_name(g.argv[2], &fname, 0, 1);
130 if( zRevision ){
131 historical_blob(zRevision, blob_str(&fname), &record, 1);
132 }else{
@@ -169,11 +171,11 @@
171 }else{
172 iWidth = -1;
173 }
174
175 /* We should be done with options.. */
176 verify_all_options2();
177
178 if( g.argc!=3 ){
179 usage("?-l|--log? ?-b|--brief? FILENAME");
180 }
181 file_tree_name(g.argv[2], &fname, 0, 1);
182
+5 -2
--- src/regexp.c
+++ src/regexp.c
@@ -787,11 +787,11 @@
787787
}
788788
789789
/*
790790
** COMMAND: grep
791791
**
792
-** Usage: %fossil grep [OPTIONS] PATTERN FILENAME
792
+** Usage: %fossil grep [OPTIONS] ?--? PATTERN FILENAME
793793
**
794794
** Attempt to match the given POSIX extended regular expression PATTERN
795795
** over all historic versions of FILENAME. For details of the supported
796796
** RE dialect, see https://fossil-scm.org/fossil/doc/trunk/www/grep.md
797797
**
@@ -798,10 +798,13 @@
798798
** Options:
799799
**
800800
** -i|--ignore-case Ignore case
801801
** -l|--files-with-matches List only checkin ID for versions that match
802802
** -v|--verbose Show each file as it is analyzed
803
+** -- Treat all following arguments as non-flags,
804
+** even if they look like flags. Use this before
805
+** the PATTERN or FILENAME, but not both.
803806
*/
804807
void re_grep_cmd(void){
805808
u32 flags = 0;
806809
int bVerbose = 0;
807810
ReCompiled *pRe;
@@ -811,11 +814,11 @@
811814
812815
if( find_option("ignore-case","i",0)!=0 ) ignoreCase = 1;
813816
if( find_option("files-with-matches","l",0)!=0 ) flags |= GREP_EXISTS;
814817
if( find_option("verbose","v",0)!=0 ) bVerbose = 1;
815818
db_find_and_open_repository(0, 0);
816
- verify_all_options();
819
+ verify_all_options2();
817820
if( g.argc<4 ){
818821
usage("REGEXP FILENAME");
819822
}
820823
zErr = re_compile(&pRe, g.argv[2], ignoreCase);
821824
if( zErr ) fossil_fatal("%s", zErr);
822825
--- src/regexp.c
+++ src/regexp.c
@@ -787,11 +787,11 @@
787 }
788
789 /*
790 ** COMMAND: grep
791 **
792 ** Usage: %fossil grep [OPTIONS] PATTERN FILENAME
793 **
794 ** Attempt to match the given POSIX extended regular expression PATTERN
795 ** over all historic versions of FILENAME. For details of the supported
796 ** RE dialect, see https://fossil-scm.org/fossil/doc/trunk/www/grep.md
797 **
@@ -798,10 +798,13 @@
798 ** Options:
799 **
800 ** -i|--ignore-case Ignore case
801 ** -l|--files-with-matches List only checkin ID for versions that match
802 ** -v|--verbose Show each file as it is analyzed
 
 
 
803 */
804 void re_grep_cmd(void){
805 u32 flags = 0;
806 int bVerbose = 0;
807 ReCompiled *pRe;
@@ -811,11 +814,11 @@
811
812 if( find_option("ignore-case","i",0)!=0 ) ignoreCase = 1;
813 if( find_option("files-with-matches","l",0)!=0 ) flags |= GREP_EXISTS;
814 if( find_option("verbose","v",0)!=0 ) bVerbose = 1;
815 db_find_and_open_repository(0, 0);
816 verify_all_options();
817 if( g.argc<4 ){
818 usage("REGEXP FILENAME");
819 }
820 zErr = re_compile(&pRe, g.argv[2], ignoreCase);
821 if( zErr ) fossil_fatal("%s", zErr);
822
--- src/regexp.c
+++ src/regexp.c
@@ -787,11 +787,11 @@
787 }
788
789 /*
790 ** COMMAND: grep
791 **
792 ** Usage: %fossil grep [OPTIONS] ?--? PATTERN FILENAME
793 **
794 ** Attempt to match the given POSIX extended regular expression PATTERN
795 ** over all historic versions of FILENAME. For details of the supported
796 ** RE dialect, see https://fossil-scm.org/fossil/doc/trunk/www/grep.md
797 **
@@ -798,10 +798,13 @@
798 ** Options:
799 **
800 ** -i|--ignore-case Ignore case
801 ** -l|--files-with-matches List only checkin ID for versions that match
802 ** -v|--verbose Show each file as it is analyzed
803 ** -- Treat all following arguments as non-flags,
804 ** even if they look like flags. Use this before
805 ** the PATTERN or FILENAME, but not both.
806 */
807 void re_grep_cmd(void){
808 u32 flags = 0;
809 int bVerbose = 0;
810 ReCompiled *pRe;
@@ -811,11 +814,11 @@
814
815 if( find_option("ignore-case","i",0)!=0 ) ignoreCase = 1;
816 if( find_option("files-with-matches","l",0)!=0 ) flags |= GREP_EXISTS;
817 if( find_option("verbose","v",0)!=0 ) bVerbose = 1;
818 db_find_and_open_repository(0, 0);
819 verify_all_options2();
820 if( g.argc<4 ){
821 usage("REGEXP FILENAME");
822 }
823 zErr = re_compile(&pRe, g.argv[2], ignoreCase);
824 if( zErr ) fossil_fatal("%s", zErr);
825

Keyboard Shortcuts

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