| | @@ -218,27 +218,30 @@ |
| 218 | 218 | ** of each UV-file is retained. Changes to an UV-file are permanent and cannot |
| 219 | 219 | ** be undone, so use appropriate caution with this command. |
| 220 | 220 | ** |
| 221 | 221 | ** Subcommands: |
| 222 | 222 | ** |
| 223 | | -** add FILE ... Add or update one or more unversioned files in |
| 223 | +** add [--] FILE ... Add or update one or more unversioned files in |
| 224 | 224 | ** the local repository so that they match FILEs |
| 225 | 225 | ** on disk. Changes are not pushed to other |
| 226 | 226 | ** repositories until the next sync. |
| 227 | 227 | ** |
| 228 | | -** add FILE --as UVFILE Add or update a single file named FILE on disk |
| 228 | +** add FILE --as UVFILE |
| 229 | +** add --as UVFILE -- FILE |
| 230 | +** Add or update a single file named FILE on disk |
| 229 | 231 | ** and UVFILE in the repository unversioned file |
| 230 | 232 | ** namespace. This variant of the 'add' command allows |
| 231 | 233 | ** the name to be different in the repository versus |
| 232 | 234 | ** what appears on disk, but it only allows adding |
| 233 | 235 | ** a single file at a time. |
| 234 | 236 | ** |
| 235 | | -** cat FILE ... Concatenate the content of FILEs to stdout. |
| 237 | +** cat [--] FILE ... Concatenate the content of FILEs to stdout. |
| 236 | 238 | ** |
| 237 | | -** edit FILE Bring up FILE in a text editor for modification. |
| 239 | +** edit [--] FILE Bring up FILE in a text editor for modification. |
| 238 | 240 | ** |
| 239 | | -** export FILE OUTPUT Write the content of FILE into OUTPUT on disk |
| 241 | +** export [--] FILE OUTPUT |
| 242 | +** Write the content of FILE into OUTPUT on disk |
| 240 | 243 | ** |
| 241 | 244 | ** list | ls Show all unversioned files held in the local |
| 242 | 245 | ** repository. |
| 243 | 246 | ** |
| 244 | 247 | ** revert ?URL? Restore the state of all unversioned files in the |
| | @@ -247,11 +250,11 @@ |
| 247 | 250 | ** |
| 248 | 251 | ** Options: |
| 249 | 252 | ** -v|--verbose Extra diagnostic output |
| 250 | 253 | ** -n|--dryrun Show what would have happened |
| 251 | 254 | ** |
| 252 | | -** remove|rm|delete FILE ... |
| 255 | +** remove|rm|delete [--] FILE ... |
| 253 | 256 | ** Remove unversioned files from the local repository. |
| 254 | 257 | ** Changes are not pushed to other repositories until |
| 255 | 258 | ** the next sync. |
| 256 | 259 | ** |
| 257 | 260 | ** sync ?URL? Synchronize the state of all unversioned files with |
| | @@ -261,16 +264,19 @@ |
| 261 | 264 | ** |
| 262 | 265 | ** Options: |
| 263 | 266 | ** -v|--verbose Extra diagnostic output |
| 264 | 267 | ** -n|--dryrun Show what would have happened |
| 265 | 268 | ** |
| 266 | | -** touch FILE ... Update the TIMESTAMP on all of the listed files |
| 269 | +** touch [--] FILE ... Update the TIMESTAMP on all of the listed files |
| 267 | 270 | ** |
| 268 | 271 | ** Options: |
| 269 | 272 | ** |
| 270 | 273 | ** --mtime TIMESTAMP Use TIMESTAMP instead of "now" for the "add", |
| 271 | 274 | ** "edit", "remove", and "touch" subcommands. |
| 275 | +** -- For commands which support this, it means to treat |
| 276 | +** all subsequent arguments as file names even if they |
| 277 | +** start with a "-". |
| 272 | 278 | */ |
| 273 | 279 | void unversioned_cmd(void){ |
| 274 | 280 | const char *zCmd; |
| 275 | 281 | int nCmd; |
| 276 | 282 | const char *zMtime = find_option("mtime", 0, 1); |
| | @@ -287,16 +293,17 @@ |
| 287 | 293 | } |
| 288 | 294 | if( memcmp(zCmd, "add", nCmd)==0 ){ |
| 289 | 295 | const char *zError = 0; |
| 290 | 296 | const char *zIn; |
| 291 | 297 | const char *zAs; |
| 298 | + const char *zFileArg; |
| 292 | 299 | Blob file; |
| 293 | 300 | int i; |
| 294 | | - |
| 301 | + int fDoubleDash; /* True if "--" flag is provided */ |
| 295 | 302 | zAs = find_option("as",0,1); |
| 303 | + fDoubleDash = verify_all_options2(); |
| 296 | 304 | if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE"); |
| 297 | | - verify_all_options(); |
| 298 | 305 | db_begin_transaction(); |
| 299 | 306 | content_rcvid_init("#!fossil unversioned add"); |
| 300 | 307 | for(i=3; i<g.argc; i++){ |
| 301 | 308 | zIn = zAs ? zAs : g.argv[i]; |
| 302 | 309 | if( zIn[0]==0 ){ |
| | @@ -310,18 +317,23 @@ |
| 310 | 317 | } |
| 311 | 318 | if( zError ){ |
| 312 | 319 | fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn); |
| 313 | 320 | } |
| 314 | 321 | blob_init(&file,0,0); |
| 315 | | - blob_read_from_file(&file, g.argv[i], ExtFILE); |
| 322 | + zFileArg = g.argv[i]; |
| 323 | + if(fDoubleDash>0 && fDoubleDash<=i |
| 324 | + && fossil_strcmp("-",zFileArg)==0){ |
| 325 | + zFileArg = "./-" /* do not treat "-" as stdin! */; |
| 326 | + } |
| 327 | + blob_read_from_file(&file, zFileArg, ExtFILE); |
| 316 | 328 | unversioned_write(zIn, &file, mtime); |
| 317 | 329 | blob_reset(&file); |
| 318 | 330 | } |
| 319 | 331 | db_end_transaction(0); |
| 320 | 332 | }else if( memcmp(zCmd, "cat", nCmd)==0 ){ |
| 321 | 333 | int i; |
| 322 | | - verify_all_options(); |
| 334 | + verify_all_options2(); |
| 323 | 335 | db_begin_transaction(); |
| 324 | 336 | for(i=3; i<g.argc; i++){ |
| 325 | 337 | Blob content; |
| 326 | 338 | if( unversioned_content(g.argv[i], &content)==0 ){ |
| 327 | 339 | blob_write_to_file(&content, "-"); |
| | @@ -334,12 +346,12 @@ |
| 334 | 346 | const char *zTFile; /* Temporary file */ |
| 335 | 347 | const char *zUVFile; /* Name of the unversioned file */ |
| 336 | 348 | char *zCmd; /* Command to run the text editor */ |
| 337 | 349 | Blob content; /* Content of the unversioned file */ |
| 338 | 350 | |
| 339 | | - verify_all_options(); |
| 340 | | - if( g.argc!=4) usage("edit UVFILE"); |
| 351 | + verify_all_options2(); |
| 352 | + if( g.argc!=4) usage("edit [--] UVFILE"); |
| 341 | 353 | zUVFile = g.argv[3]; |
| 342 | 354 | zEditor = fossil_text_editor(); |
| 343 | 355 | if( zEditor==0 ) fossil_fatal("no text editor - set the VISUAL env variable"); |
| 344 | 356 | zTFile = fossil_temp_filename(); |
| 345 | 357 | if( zTFile==0 ) fossil_fatal("cannot find a temporary filename"); |
| | @@ -370,11 +382,11 @@ |
| 370 | 382 | unversioned_write(zUVFile, &content, mtime); |
| 371 | 383 | db_end_transaction(0); |
| 372 | 384 | blob_reset(&content); |
| 373 | 385 | }else if( memcmp(zCmd, "export", nCmd)==0 ){ |
| 374 | 386 | Blob content; |
| 375 | | - verify_all_options(); |
| 387 | + verify_all_options2(); |
| 376 | 388 | if( g.argc!=5 ) usage("export UVFILE OUTPUT"); |
| 377 | 389 | if( unversioned_content(g.argv[3], &content) ){ |
| 378 | 390 | fossil_fatal("no such uv-file: %Q", g.argv[3]); |
| 379 | 391 | } |
| 380 | 392 | blob_write_to_file(&content, g.argv[4]); |
| | @@ -430,11 +442,11 @@ |
| 430 | 442 | g.argv[2] = "--uv-noop"; |
| 431 | 443 | sync_unversioned(syncFlags); |
| 432 | 444 | }else if( memcmp(zCmd, "remove", nCmd)==0 || memcmp(zCmd, "rm", nCmd)==0 |
| 433 | 445 | || memcmp(zCmd, "delete", nCmd)==0 ){ |
| 434 | 446 | int i; |
| 435 | | - verify_all_options(); |
| 447 | + verify_all_options2(); |
| 436 | 448 | db_begin_transaction(); |
| 437 | 449 | for(i=3; i<g.argc; i++){ |
| 438 | 450 | db_multi_exec( |
| 439 | 451 | "UPDATE unversioned" |
| 440 | 452 | " SET hash=NULL, content=NULL, mtime=%lld, sz=0 WHERE name=%Q", |
| | @@ -448,11 +460,11 @@ |
| 448 | 460 | g.argv[1] = "sync"; |
| 449 | 461 | g.argv[2] = "--uv-noop"; |
| 450 | 462 | sync_unversioned(syncFlags); |
| 451 | 463 | }else if( memcmp(zCmd, "touch", nCmd)==0 ){ |
| 452 | 464 | int i; |
| 453 | | - verify_all_options(); |
| 465 | + verify_all_options2(); |
| 454 | 466 | db_begin_transaction(); |
| 455 | 467 | for(i=3; i<g.argc; i++){ |
| 456 | 468 | db_multi_exec( |
| 457 | 469 | "UPDATE unversioned SET mtime=%lld WHERE name=%Q", |
| 458 | 470 | mtime, g.argv[i] |
| 459 | 471 | |