Fossil SCM

Added -- support to (annotate, artifact, cat, clone).

stephan 2019-09-27 22:28 double-dash-flag
Commit ef763bcf08af754d1441f276dfdf3f56e329e9691c51e8ca58693d394c347ede
+4 -2
--- src/clone.c
+++ src/clone.c
@@ -80,11 +80,11 @@
8080
8181
8282
/*
8383
** COMMAND: clone
8484
**
85
-** Usage: %fossil clone ?OPTIONS? URI FILENAME
85
+** Usage: %fossil clone ?OPTIONS? URI ?--? FILENAME
8686
**
8787
** Make a clone of a repository specified by URI in the local
8888
** file named FILENAME.
8989
**
9090
** URI may be one of the following form: ([...] mean optional)
@@ -118,10 +118,12 @@
118118
** --save-http-password Remember the HTTP password without asking
119119
** --ssh-command|-c SSH Use SSH as the "ssh" command
120120
** --ssl-identity FILENAME Use the SSL identity if requested by the server
121121
** -u|--unversioned Also sync unversioned content
122122
** -v|--verbose Show more statistics in output
123
+** -- Treat all following arguments as files,
124
+** even if they look like flags.
123125
**
124126
** See also: init
125127
*/
126128
void clone_cmd(void){
127129
char *zPassword;
@@ -145,11 +147,11 @@
145147
zDefaultUser = find_option("admin-user","A",1);
146148
clone_ssh_find_options();
147149
url_proxy_options();
148150
149151
/* We should be done with options.. */
150
- verify_all_options();
152
+ verify_all_options2();
151153
152154
if( g.argc < 4 ){
153155
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
154156
}
155157
db_open_config(0, 0);
156158
--- src/clone.c
+++ src/clone.c
@@ -80,11 +80,11 @@
80
81
82 /*
83 ** COMMAND: clone
84 **
85 ** Usage: %fossil clone ?OPTIONS? URI FILENAME
86 **
87 ** Make a clone of a repository specified by URI in the local
88 ** file named FILENAME.
89 **
90 ** URI may be one of the following form: ([...] mean optional)
@@ -118,10 +118,12 @@
118 ** --save-http-password Remember the HTTP password without asking
119 ** --ssh-command|-c SSH Use SSH as the "ssh" command
120 ** --ssl-identity FILENAME Use the SSL identity if requested by the server
121 ** -u|--unversioned Also sync unversioned content
122 ** -v|--verbose Show more statistics in output
 
 
123 **
124 ** See also: init
125 */
126 void clone_cmd(void){
127 char *zPassword;
@@ -145,11 +147,11 @@
145 zDefaultUser = find_option("admin-user","A",1);
146 clone_ssh_find_options();
147 url_proxy_options();
148
149 /* We should be done with options.. */
150 verify_all_options();
151
152 if( g.argc < 4 ){
153 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
154 }
155 db_open_config(0, 0);
156
--- src/clone.c
+++ src/clone.c
@@ -80,11 +80,11 @@
80
81
82 /*
83 ** COMMAND: clone
84 **
85 ** Usage: %fossil clone ?OPTIONS? URI ?--? FILENAME
86 **
87 ** Make a clone of a repository specified by URI in the local
88 ** file named FILENAME.
89 **
90 ** URI may be one of the following form: ([...] mean optional)
@@ -118,10 +118,12 @@
118 ** --save-http-password Remember the HTTP password without asking
119 ** --ssh-command|-c SSH Use SSH as the "ssh" command
120 ** --ssl-identity FILENAME Use the SSL identity if requested by the server
121 ** -u|--unversioned Also sync unversioned content
122 ** -v|--verbose Show more statistics in output
123 ** -- Treat all following arguments as files,
124 ** even if they look like flags.
125 **
126 ** See also: init
127 */
128 void clone_cmd(void){
129 char *zPassword;
@@ -145,11 +147,11 @@
147 zDefaultUser = find_option("admin-user","A",1);
148 clone_ssh_find_options();
149 url_proxy_options();
150
151 /* We should be done with options.. */
152 verify_all_options2();
153
154 if( g.argc < 4 ){
155 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
156 }
157 db_open_config(0, 0);
158
+8 -3
--- src/content.c
+++ src/content.c
@@ -310,28 +310,33 @@
310310
}
311311
312312
/*
313313
** COMMAND: artifact*
314314
**
315
-** Usage: %fossil artifact ARTIFACT-ID ?OUTPUT-FILENAME? ?OPTIONS?
315
+** Usage: %fossil artifact ARTIFACT-ID ?OPTIONS? ?--? ?OUTPUT-FILENAME?
316316
**
317317
** Extract an artifact by its artifact hash and write the results on
318318
** standard output, or if the optional 4th argument is given, in
319319
** the named output file.
320320
**
321321
** Options:
322322
** -R|--repository FILE Extract artifacts from repository FILE
323
+** -- Treat all following arguments as files,
324
+** even if they look like flags and treat
325
+** output filename "-" as a literal filename
326
+** instead of an alias for stdout.
323327
**
324328
** See also: finfo
325329
*/
326330
void artifact_cmd(void){
327331
int rid;
328332
Blob content;
329333
const char *zFile;
330334
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
331
- if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?FILENAME? ?OPTIONS?");
332
- zFile = g.argc==4 ? g.argv[3] : "-";
335
+ verify_all_options2();
336
+ if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?OPTIONS? ?--? ?FILENAME?");
337
+ zFile = g.argc==4 ? get_dash_filename_arg(3) : "-";
333338
rid = name_to_rid(g.argv[2]);
334339
if( rid==0 ){
335340
fossil_fatal("%s",g.zErrMsg);
336341
}
337342
content_get(rid, &content);
338343
--- src/content.c
+++ src/content.c
@@ -310,28 +310,33 @@
310 }
311
312 /*
313 ** COMMAND: artifact*
314 **
315 ** Usage: %fossil artifact ARTIFACT-ID ?OUTPUT-FILENAME? ?OPTIONS?
316 **
317 ** Extract an artifact by its artifact hash and write the results on
318 ** standard output, or if the optional 4th argument is given, in
319 ** the named output file.
320 **
321 ** Options:
322 ** -R|--repository FILE Extract artifacts from repository FILE
 
 
 
 
323 **
324 ** See also: finfo
325 */
326 void artifact_cmd(void){
327 int rid;
328 Blob content;
329 const char *zFile;
330 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
331 if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?FILENAME? ?OPTIONS?");
332 zFile = g.argc==4 ? g.argv[3] : "-";
 
333 rid = name_to_rid(g.argv[2]);
334 if( rid==0 ){
335 fossil_fatal("%s",g.zErrMsg);
336 }
337 content_get(rid, &content);
338
--- src/content.c
+++ src/content.c
@@ -310,28 +310,33 @@
310 }
311
312 /*
313 ** COMMAND: artifact*
314 **
315 ** Usage: %fossil artifact ARTIFACT-ID ?OPTIONS? ?--? ?OUTPUT-FILENAME?
316 **
317 ** Extract an artifact by its artifact hash and write the results on
318 ** standard output, or if the optional 4th argument is given, in
319 ** the named output file.
320 **
321 ** Options:
322 ** -R|--repository FILE Extract artifacts from repository FILE
323 ** -- Treat all following arguments as files,
324 ** even if they look like flags and treat
325 ** output filename "-" as a literal filename
326 ** instead of an alias for stdout.
327 **
328 ** See also: finfo
329 */
330 void artifact_cmd(void){
331 int rid;
332 Blob content;
333 const char *zFile;
334 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
335 verify_all_options2();
336 if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?OPTIONS? ?--? ?FILENAME?");
337 zFile = g.argc==4 ? get_dash_filename_arg(3) : "-";
338 rid = name_to_rid(g.argv[2]);
339 if( rid==0 ){
340 fossil_fatal("%s",g.zErrMsg);
341 }
342 content_get(rid, &content);
343
+4 -2
--- src/diff.c
+++ src/diff.c
@@ -2534,11 +2534,11 @@
25342534
/*
25352535
** COMMAND: annotate
25362536
** COMMAND: blame
25372537
** COMMAND: praise
25382538
**
2539
-** Usage: %fossil annotate|blame|praise ?OPTIONS? FILENAME
2539
+** Usage: %fossil annotate|blame|praise ?OPTIONS? ?--? FILENAME
25402540
**
25412541
** Output the text of a file with markings to show when each line of the file
25422542
** was last modified. The version currently checked out is shown by default.
25432543
** Other versions may be specified using the -r option. The "annotate" command
25442544
** shows line numbers and omits the username. The "blame" and "praise" commands
@@ -2565,10 +2565,12 @@
25652565
** -o|--origin VERSION The origin check-in. By default this is the
25662566
** root of the repository. Set to "trunk" or
25672567
** similar for a reverse annotation.
25682568
** -w|--ignore-all-space Ignore white space when comparing lines
25692569
** -Z|--ignore-trailing-space Ignore whitespace at line end
2570
+** -- Treat all following arguments as files,
2571
+** even if they look like flags.
25702572
**
25712573
** See also: info, finfo, timeline
25722574
*/
25732575
void annotate_cmd(void){
25742576
const char *zRevision; /* Revision name, or NULL for current check-in */
@@ -2597,11 +2599,11 @@
25972599
}
25982600
fileVers = find_option("filevers",0,0)!=0;
25992601
db_must_be_within_tree();
26002602
26012603
/* We should be done with options.. */
2602
- verify_all_options();
2604
+ verify_all_options2();
26032605
26042606
if( g.argc<3 ) {
26052607
usage("FILENAME");
26062608
}
26072609
26082610
--- src/diff.c
+++ src/diff.c
@@ -2534,11 +2534,11 @@
2534 /*
2535 ** COMMAND: annotate
2536 ** COMMAND: blame
2537 ** COMMAND: praise
2538 **
2539 ** Usage: %fossil annotate|blame|praise ?OPTIONS? FILENAME
2540 **
2541 ** Output the text of a file with markings to show when each line of the file
2542 ** was last modified. The version currently checked out is shown by default.
2543 ** Other versions may be specified using the -r option. The "annotate" command
2544 ** shows line numbers and omits the username. The "blame" and "praise" commands
@@ -2565,10 +2565,12 @@
2565 ** -o|--origin VERSION The origin check-in. By default this is the
2566 ** root of the repository. Set to "trunk" or
2567 ** similar for a reverse annotation.
2568 ** -w|--ignore-all-space Ignore white space when comparing lines
2569 ** -Z|--ignore-trailing-space Ignore whitespace at line end
 
 
2570 **
2571 ** See also: info, finfo, timeline
2572 */
2573 void annotate_cmd(void){
2574 const char *zRevision; /* Revision name, or NULL for current check-in */
@@ -2597,11 +2599,11 @@
2597 }
2598 fileVers = find_option("filevers",0,0)!=0;
2599 db_must_be_within_tree();
2600
2601 /* We should be done with options.. */
2602 verify_all_options();
2603
2604 if( g.argc<3 ) {
2605 usage("FILENAME");
2606 }
2607
2608
--- src/diff.c
+++ src/diff.c
@@ -2534,11 +2534,11 @@
2534 /*
2535 ** COMMAND: annotate
2536 ** COMMAND: blame
2537 ** COMMAND: praise
2538 **
2539 ** Usage: %fossil annotate|blame|praise ?OPTIONS? ?--? FILENAME
2540 **
2541 ** Output the text of a file with markings to show when each line of the file
2542 ** was last modified. The version currently checked out is shown by default.
2543 ** Other versions may be specified using the -r option. The "annotate" command
2544 ** shows line numbers and omits the username. The "blame" and "praise" commands
@@ -2565,10 +2565,12 @@
2565 ** -o|--origin VERSION The origin check-in. By default this is the
2566 ** root of the repository. Set to "trunk" or
2567 ** similar for a reverse annotation.
2568 ** -w|--ignore-all-space Ignore white space when comparing lines
2569 ** -Z|--ignore-trailing-space Ignore whitespace at line end
2570 ** -- Treat all following arguments as files,
2571 ** even if they look like flags.
2572 **
2573 ** See also: info, finfo, timeline
2574 */
2575 void annotate_cmd(void){
2576 const char *zRevision; /* Revision name, or NULL for current check-in */
@@ -2597,11 +2599,11 @@
2599 }
2600 fileVers = find_option("filevers",0,0)!=0;
2601 db_must_be_within_tree();
2602
2603 /* We should be done with options.. */
2604 verify_all_options2();
2605
2606 if( g.argc<3 ) {
2607 usage("FILENAME");
2608 }
2609
2610
+4 -2
--- src/finfo.c
+++ src/finfo.c
@@ -235,19 +235,21 @@
235235
}
236236
237237
/*
238238
** COMMAND: cat
239239
**
240
-** Usage: %fossil cat FILENAME ... ?OPTIONS?
240
+** Usage: %fossil cat ?OPTIONS? ?--? FILENAME ...
241241
**
242242
** Print on standard output the content of one or more files as they exist
243243
** in the repository. The version currently checked out is shown by default.
244244
** Other versions may be specified using the -r option.
245245
**
246246
** Options:
247247
** -R|--repository FILE Extract artifacts from repository FILE
248248
** -r VERSION The specific check-in containing the file
249
+** -- Treat all following arguments as files,
250
+** even if they look like flags.
249251
**
250252
** See also: finfo
251253
*/
252254
void cat_cmd(void){
253255
int i;
@@ -255,11 +257,11 @@
255257
const char *zRev;
256258
db_find_and_open_repository(0, 0);
257259
zRev = find_option("r","r",1);
258260
259261
/* We should be done with options.. */
260
- verify_all_options();
262
+ verify_all_options2();
261263
262264
for(i=2; i<g.argc; i++){
263265
file_tree_name(g.argv[i], &fname, 0, 1);
264266
blob_zero(&content);
265267
historical_blob(zRev, blob_str(&fname), &content, 1);
266268
--- src/finfo.c
+++ src/finfo.c
@@ -235,19 +235,21 @@
235 }
236
237 /*
238 ** COMMAND: cat
239 **
240 ** Usage: %fossil cat FILENAME ... ?OPTIONS?
241 **
242 ** Print on standard output the content of one or more files as they exist
243 ** in the repository. The version currently checked out is shown by default.
244 ** Other versions may be specified using the -r option.
245 **
246 ** Options:
247 ** -R|--repository FILE Extract artifacts from repository FILE
248 ** -r VERSION The specific check-in containing the file
 
 
249 **
250 ** See also: finfo
251 */
252 void cat_cmd(void){
253 int i;
@@ -255,11 +257,11 @@
255 const char *zRev;
256 db_find_and_open_repository(0, 0);
257 zRev = find_option("r","r",1);
258
259 /* We should be done with options.. */
260 verify_all_options();
261
262 for(i=2; i<g.argc; i++){
263 file_tree_name(g.argv[i], &fname, 0, 1);
264 blob_zero(&content);
265 historical_blob(zRev, blob_str(&fname), &content, 1);
266
--- src/finfo.c
+++ src/finfo.c
@@ -235,19 +235,21 @@
235 }
236
237 /*
238 ** COMMAND: cat
239 **
240 ** Usage: %fossil cat ?OPTIONS? ?--? FILENAME ...
241 **
242 ** Print on standard output the content of one or more files as they exist
243 ** in the repository. The version currently checked out is shown by default.
244 ** Other versions may be specified using the -r option.
245 **
246 ** Options:
247 ** -R|--repository FILE Extract artifacts from repository FILE
248 ** -r VERSION The specific check-in containing the file
249 ** -- Treat all following arguments as files,
250 ** even if they look like flags.
251 **
252 ** See also: finfo
253 */
254 void cat_cmd(void){
255 int i;
@@ -255,11 +257,11 @@
257 const char *zRev;
258 db_find_and_open_repository(0, 0);
259 zRev = find_option("r","r",1);
260
261 /* We should be done with options.. */
262 verify_all_options2();
263
264 for(i=2; i<g.argc; i++){
265 file_tree_name(g.argv[i], &fname, 0, 1);
266 blob_zero(&content);
267 historical_blob(zRev, blob_str(&fname), &content, 1);
268

Keyboard Shortcuts

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