Index: src/add.c ================================================================== --- src/add.c +++ src/add.c @@ -244,11 +244,11 @@ } /* ** COMMAND: add ** -** Usage: %fossil add ?OPTIONS? FILE1 ?FILE2 ...? +** Usage: %fossil add ?OPTIONS? ?--? FILE1 ?FILE2 ...? ** ** Make arrangements to add one or more files or directories to the ** current checkout at the next commit. ** ** When adding files or directories recursively, filenames that begin @@ -276,10 +276,12 @@ ** -f|--force Add files without prompting ** --ignore Ignore unmanaged files matching patterns from ** the comma separated list of glob patterns. ** --clean Also ignore files matching patterns from ** the comma separated list of glob patterns. +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: addremove, rm */ void add_cmd(void){ int i; /* Loop counter */ @@ -295,11 +297,11 @@ zIgnoreFlag = find_option("ignore",0,1); forceFlag = find_option("force","f",0)!=0; if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); db_must_be_within_tree(); if( zCleanFlag==0 ){ zCleanFlag = db_get("clean-glob", 0); } @@ -332,11 +334,11 @@ if( isDir==1 ){ vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore, RepoFILE); }else if( isDir==0 ){ fossil_warning("not found: %s", zName); }else{ - char *zTreeName = &zName[nRoot]; + const char *zTreeName = &zName[nRoot]; if( !forceFlag && glob_match(pIgnore, zTreeName) ){ Blob ans; char cReply; char *prompt = mprintf("file \"%s\" matches \"ignore-glob\". " "Add it (a=all/y/N)? ", zTreeName); @@ -418,11 +420,11 @@ /* ** COMMAND: rm ** COMMAND: delete ** COMMAND: forget* ** -** Usage: %fossil rm|delete|forget FILE1 ?FILE2 ...? +** Usage: %fossil rm|delete|forget ?OPTIONS? ?--? FILE1 ?FILE2 ...? ** ** Remove one or more files or directories from the repository. ** ** The 'rm' and 'delete' commands do NOT normally remove the files from ** disk. They just mark the files as no longer being part of the project. @@ -442,10 +444,12 @@ ** --soft Skip removing files from the checkout. ** This supersedes the --hard option. ** --hard Remove files from the checkout. ** --case-sensitive Override the case-sensitive setting. ** -n|--dry-run If given, display instead of run actions. +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: addremove, add */ void delete_cmd(void){ int i; @@ -458,11 +462,11 @@ dryRunFlag = find_option("dry-run","n",0)!=0; softFlag = find_option("soft",0,0)!=0; hardFlag = find_option("hard",0,0)!=0; /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); db_must_be_within_tree(); db_begin_transaction(); if( g.argv[1][0]=='f' ){ /* i.e. "forget" */ removeFiles = 0; @@ -824,12 +828,12 @@ /* ** COMMAND: mv ** COMMAND: rename* ** -** Usage: %fossil mv|rename OLDNAME NEWNAME -** or: %fossil mv|rename OLDNAME... DIR +** Usage: %fossil mv|rename ?OPTIONS? ?--? OLDNAME NEWNAME +** or: %fossil mv|rename ?OPTIONS? ?--? OLDNAME... DIR ** ** Move or rename one or more files or directories within the repository tree. ** You can either rename a file or directory or move it to another subdirectory. ** ** The 'mv' command does NOT normally rename or move the files on disk. @@ -850,10 +854,12 @@ ** --soft Skip moving files within the checkout. ** This supersedes the --hard option. ** --hard Move files within the checkout. ** --case-sensitive Override the case-sensitive setting. ** -n|--dry-run If given, display instead of run actions. +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: changes, status */ void mv_cmd(void){ int i; @@ -872,18 +878,18 @@ dryRunFlag = find_option("dry-run","n",0)!=0; softFlag = find_option("soft",0,0)!=0; hardFlag = find_option("hard",0,0)!=0; /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); vid = db_lget_int("checkout", 0); if( vid==0 ){ fossil_fatal("no checkout in which to rename files"); } if( g.argc<4 ){ - usage("OLDNAME NEWNAME"); + usage("?OPTIONS? ?--? OLDNAME NEWNAME"); } zDest = g.argv[g.argc-1]; db_begin_transaction(); if( g.argv[1][0]=='r' ){ /* i.e. "rename" */ moveFiles = 0; @@ -910,11 +916,11 @@ }else{ origType = (file_isdir(g.argv[2], RepoFILE) == 1); } destType = file_isdir(zDest, RepoFILE); if( origType==-1 && destType!=1 ){ - usage("OLDNAME NEWNAME"); + usage("?OPTIONS? ?--? OLDNAME NEWNAME"); }else if( origType==1 && destType==2 ){ fossil_fatal("cannot rename '%s' to '%s' since another file named" " '%s' exists", g.argv[2], zDest, zDest); }else if( origType==0 && destType!=1 ){ Blob orig; Index: src/branch.c ================================================================== --- src/branch.c +++ src/branch.c @@ -49,10 +49,16 @@ } /* ** fossil branch new NAME BASIS ?OPTIONS? ** argv0 argv1 argv2 argv3 argv4 +** +** Or: +** +** fossil branch new ?OPTIONS? NAME BASIS +** +** with the "--" flag before NAME *or* BASIS. */ void branch_new(void){ int rootid; /* RID of the root check-in - what we branch off of */ int brid; /* RID of the branch check-in */ int noSign; /* True if the branch is unsigned */ @@ -73,11 +79,11 @@ noSign = find_option("nosign","",0)!=0; zColor = find_option("bgcolor","c",1); isPrivate = find_option("private",0,0)!=0; zDateOvrd = find_option("date-override",0,1); zUserOvrd = find_option("user-override",0,1); - verify_all_options(); + verify_all_options2(); if( g.argc<5 ){ usage("new BRANCH-NAME BASIS ?OPTIONS?"); } db_find_and_open_repository(0, 0); noSign = db_get_boolean("omitsign", 0)|noSign; @@ -351,18 +357,21 @@ ** -c|--closed List closed branches. ** -r Reverse the sort order ** -t Show recently changed branches first ** ** fossil branch new BRANCH-NAME BASIS ?OPTIONS? +** fossil branch new ?OPTIONS? -- BRANCH-NAME BASIS ** ** Create a new branch BRANCH-NAME off of check-in BASIS. ** Supported options for this subcommand include: ** --private branch is private (i.e., remains local) ** --bgcolor COLOR use COLOR instead of automatic background ** --nosign do not sign contents on this branch ** --date-override DATE DATE to use instead of 'now' ** --user-override USER USER to use instead of the current default +** -- All arguments after this are treated as +** non-flags. ** ** DATE may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in ** year-month-day form, it may be truncated, the "T" may be ** replaced by a space, and it may also name a timezone offset ** from UTC as "-HH:MM" (westward) or "+HH:MM" (eastward). Index: src/checkin.c ================================================================== --- src/checkin.c +++ src/checkin.c @@ -352,11 +352,11 @@ /* ** COMMAND: changes ** COMMAND: status ** -** Usage: %fossil changes|status ?OPTIONS? ?PATHS ...? +** Usage: %fossil changes|status ?OPTIONS? ?--? ?PATHS ...? ** ** Report the change status of files in the current checkout. If one or ** more PATHS are specified, only changes among the named files and ** directories are reported. Directories are searched recursively. ** @@ -439,10 +439,12 @@ ** --all Display all managed files, i.e. all of the above. ** --extra Display unmanaged files. ** --differ Display modified and extra files. ** --merge Display merge contributors. ** --no-merge Do not display merge contributors. +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: extras, ls */ void status_cmd(void){ /* Affirmative and negative flag option tables. */ @@ -526,11 +528,11 @@ if( find_option("dotfiles", 0, 0) || db_get_boolean("dotfiles", 0) ){ scanFlags = SCAN_ALL; } /* We should be done with options. */ - verify_all_options(); + verify_all_options2(); /* Check for changed files. */ vfile_check_signature(vid, useHash ? CKSIG_HASH : 0); /* Search for unmanaged files if requested. */ @@ -647,11 +649,11 @@ } /* ** COMMAND: ls ** -** Usage: %fossil ls ?OPTIONS? ?PATHS ...? +** Usage: %fossil ls ?OPTIONS? ?--? ?PATHS ...? ** ** List all files in the current checkout. If PATHS is included, only the ** named files (or their children if directories) are shown. ** ** The ls command is essentially two related commands in one, depending on @@ -675,10 +677,12 @@ ** --age Show when each file was committed. ** -v|--verbose Provide extra information about each file. ** -t Sort output in time order. ** -r VERSION The specific check-in to list. ** -R|--repository FILE Extract info from repository FILE. +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: changes, extras, status */ void ls_cmd(void){ int vid; @@ -700,11 +704,11 @@ zRev = find_option("r","r",1); timeOrder = find_option("t","t",0)!=0; if( zRev!=0 ){ db_find_and_open_repository(0, 0); - verify_all_options(); + verify_all_options2(); ls_cmd_rev(zRev,verboseFlag,showAge,timeOrder); return; }else if( find_option("R",0,1)!=0 ){ fossil_fatal("the -r is required in addition to -R"); } @@ -805,11 +809,11 @@ } /* ** COMMAND: extras ** -** Usage: %fossil extras ?OPTIONS? ?PATH1 ...? +** Usage: %fossil extras ?OPTIONS? ?--? ?PATH1 ...? ** ** Print a list of all files in the source tree that are not part of the ** current checkout. See also the "clean" command. If paths are specified, ** only files in the given directories will be listed. ** @@ -829,10 +833,12 @@ ** --dotfiles include files beginning with a dot (".") ** --header Identify the repository if there are extras ** --ignore ignore files matching patterns from the argument ** --rel-paths Display pathnames relative to the current working ** directory. +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: changes, clean, status */ void extras_cmd(void){ Blob report = BLOB_INITIALIZER; @@ -850,11 +856,11 @@ } if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL; /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( zIgnoreFlag==0 ){ zIgnoreFlag = db_get("ignore-glob", 0); } pIgnore = glob_create(zIgnoreFlag); @@ -876,11 +882,11 @@ } /* ** COMMAND: clean ** -** Usage: %fossil clean ?OPTIONS? ?PATH ...? +** Usage: %fossil clean ?OPTIONS? ?--? ?PATH ...? ** ** Delete all "extra" files in the source tree. "Extra" files are files ** that are not officially part of the checkout. If one or more PATH ** arguments appear, then only the files named, or files contained with ** directories named, will be removed. @@ -953,10 +959,12 @@ ** deleted. ** --no-prompt This option disables prompting the user for input ** and assumes an answer of 'No' for every question. ** --temp Remove only Fossil-generated temporary files. ** -v|--verbose Show all files as they are removed. +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: addremove, extras, status */ void clean_cmd(void){ int allFileFlag, allDirFlag, dryRunFlag, verboseFlag; @@ -1010,11 +1018,11 @@ } if( zCleanFlag==0 && !verilyFlag ){ zCleanFlag = db_get("clean-glob", 0); } if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL; - verify_all_options(); + verify_all_options2(); pIgnore = glob_create(zIgnoreFlag); pKeep = glob_create(zKeepFlag); pClean = glob_create(zCleanFlag); nRoot = (int)strlen(g.zLocalRoot); /* Always consider symlinks. */ @@ -1938,12 +1946,12 @@ /* ** COMMAND: ci* ** COMMAND: commit ** -** Usage: %fossil commit ?OPTIONS? ?FILE...? -** or: %fossil ci ?OPTIONS? ?FILE...? +** Usage: %fossil commit ?OPTIONS? ?--? ?FILE...? +** or: %fossil ci ?OPTIONS? ?--? ?FILE...? ** ** Create a new version containing all of the changes in the current ** checkout. You will be prompted to enter a check-in comment unless ** the comment has been specified on the command-line using "-m" or a ** file containing the comment using -M. The editor defined in the @@ -2020,10 +2028,12 @@ ** --hash verify file status using hashing rather ** than relying on file mtimes ** --tag TAG-NAME assign given tag TAG-NAME to the check-in ** --date-override DATETIME DATE to use instead of 'now' ** --user-override USER USER to use instead of the current default +** -- Treat all following arguments as files, +** even if they look like flags. ** ** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in ** year-month-day form, it may be truncated, the "T" may be replaced by ** a space, and it may also name a timezone offset from UTC as "-HH:MM" ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" @@ -2123,11 +2133,11 @@ db_must_be_within_tree(); noSign = db_get_boolean("omitsign", 0)|noSign; if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } useCksum = db_get_boolean("repo-cksum", 1); outputManifest = db_get_manifest_setting(); - verify_all_options(); + verify_all_options2(); /* Get the ID of the parent manifest artifact */ vid = db_lget_int("checkout", 0); if( vid==0 ){ useCksum = 1; Index: src/clone.c ================================================================== --- src/clone.c +++ src/clone.c @@ -80,11 +80,11 @@ /* ** COMMAND: clone ** -** Usage: %fossil clone ?OPTIONS? URI FILENAME +** Usage: %fossil clone ?OPTIONS? URI ?--? FILENAME ** ** Make a clone of a repository specified by URI in the local ** file named FILENAME. ** ** URI may be one of the following form: ([...] mean optional) @@ -118,10 +118,12 @@ ** --save-http-password Remember the HTTP password without asking ** --ssh-command|-c SSH Use SSH as the "ssh" command ** --ssl-identity FILENAME Use the SSL identity if requested by the server ** -u|--unversioned Also sync unversioned content ** -v|--verbose Show more statistics in output +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: init */ void clone_cmd(void){ char *zPassword; @@ -145,11 +147,11 @@ zDefaultUser = find_option("admin-user","A",1); clone_ssh_find_options(); url_proxy_options(); /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( g.argc < 4 ){ usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY"); } db_open_config(0, 0); Index: src/content.c ================================================================== --- src/content.c +++ src/content.c @@ -310,28 +310,33 @@ } /* ** COMMAND: artifact* ** -** Usage: %fossil artifact ARTIFACT-ID ?OUTPUT-FILENAME? ?OPTIONS? +** Usage: %fossil artifact ARTIFACT-ID ?OPTIONS? ?--? ?OUTPUT-FILENAME? ** ** Extract an artifact by its artifact hash and write the results on ** standard output, or if the optional 4th argument is given, in ** the named output file. ** ** Options: ** -R|--repository FILE Extract artifacts from repository FILE +** -- Treat all following arguments as files, +** even if they look like flags and treat +** output filename "-" as a literal filename +** instead of an alias for stdout. ** ** See also: finfo */ void artifact_cmd(void){ int rid; Blob content; const char *zFile; db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); - if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?FILENAME? ?OPTIONS?"); - zFile = g.argc==4 ? g.argv[3] : "-"; + verify_all_options2(); + if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?OPTIONS? ?--? ?FILENAME?"); + zFile = g.argc==4 ? get_dash_filename_arg(3) : "-"; rid = name_to_rid(g.argv[2]); if( rid==0 ){ fossil_fatal("%s",g.zErrMsg); } content_get(rid, &content); Index: src/db.c ================================================================== --- src/db.c +++ src/db.c @@ -2213,12 +2213,12 @@ /* ** COMMAND: new* ** COMMAND: init ** -** Usage: %fossil new ?OPTIONS? FILENAME -** or: %fossil init ?OPTIONS? FILENAME +** Usage: %fossil new ?OPTIONS? ?--? FILENAME +** or: %fossil init ?OPTIONS? ?--? FILENAME ** ** Create a repository for a new project in the file named FILENAME. ** This command is distinct from "clone". The "clone" command makes ** a copy of an existing project. This command starts a new project. ** @@ -2238,10 +2238,12 @@ ** Options: ** --template FILE Copy settings from repository file ** --admin-user|-A USERNAME Select given USERNAME as admin user ** --date-override DATETIME Use DATETIME as time of the initial check-in ** --sha1 Use a initial hash policy of "sha1" +** -- Treat all following arguments as files, +** even if they look like flags. ** ** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in ** year-month-day form, it may be truncated, the "T" may be replaced by ** a space, and it may also name a timezone offset from UTC as "-HH:MM" ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" @@ -2260,11 +2262,11 @@ zTemplate = find_option("template",0,1); zDate = find_option("date-override",0,1); zDefaultUser = find_option("admin-user","A",1); bUseSha1 = find_option("sha1",0,0)!=0; /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( g.argc!=3 ){ usage("REPOSITORY-NAME"); } @@ -2902,11 +2904,11 @@ } /* ** COMMAND: open ** -** Usage: %fossil open FILENAME ?VERSION? ?OPTIONS? +** Usage: %fossil open ?OPTIONS? ?--? FILENAME ?VERSION? ** ** Open a connection to the local repository in FILENAME. A checkout ** for the repository is created with its root at the working directory. ** If VERSION is specified then that version is checked out. Otherwise ** the latest version is checked out. No files other than "manifest" @@ -2920,10 +2922,13 @@ ** --nested Allow opening a repository inside an opened checkout ** --force-missing Force opening a repository with missing content ** --setmtime Set timestamps of all files to match their SCM-side ** times (the timestamp of the last checkin which modified ** them). +** -- Treat all following arguments as files, even if they +** look like flags. Use before the FILENAME or VERSION, +** but not both. ** ** See also: close */ void cmd_open(void){ int emptyFlag; @@ -2940,11 +2945,11 @@ forceMissingFlag = find_option("force-missing",0,0)!=0; allowNested = find_option("nested",0,0)!=0; setmtimeFlag = find_option("setmtime",0,0)!=0; /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( g.argc!=3 && g.argc!=4 ){ usage("REPOSITORY-FILENAME ?VERSION?"); } if( !allowNested && db_open_local(0) ){ Index: src/diff.c ================================================================== --- src/diff.c +++ src/diff.c @@ -2534,11 +2534,11 @@ /* ** COMMAND: annotate ** COMMAND: blame ** COMMAND: praise ** -** Usage: %fossil annotate|blame|praise ?OPTIONS? FILENAME +** Usage: %fossil annotate|blame|praise ?OPTIONS? ?--? FILENAME ** ** Output the text of a file with markings to show when each line of the file ** was last modified. The version currently checked out is shown by default. ** Other versions may be specified using the -r option. The "annotate" command ** shows line numbers and omits the username. The "blame" and "praise" commands @@ -2565,10 +2565,12 @@ ** -o|--origin VERSION The origin check-in. By default this is the ** root of the repository. Set to "trunk" or ** similar for a reverse annotation. ** -w|--ignore-all-space Ignore white space when comparing lines ** -Z|--ignore-trailing-space Ignore whitespace at line end +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: info, finfo, timeline */ void annotate_cmd(void){ const char *zRevision; /* Revision name, or NULL for current check-in */ @@ -2597,11 +2599,11 @@ } fileVers = find_option("filevers",0,0)!=0; db_must_be_within_tree(); /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( g.argc<3 ) { usage("FILENAME"); } Index: src/diffcmd.c ================================================================== --- src/diffcmd.c +++ src/diffcmd.c @@ -780,11 +780,11 @@ /* ** COMMAND: diff ** COMMAND: gdiff ** -** Usage: %fossil diff|gdiff ?OPTIONS? ?FILE1? ?FILE2 ...? +** Usage: %fossil diff|gdiff ?OPTIONS? ?--? ?FILE1? ?FILE2 ...? ** ** Show the difference between the current version of each of the FILEs ** specified (as they exist on disk) and that same file as it was checked ** out. Or if the FILE arguments are omitted, show the unsaved changes ** currently in the working check-out. @@ -839,10 +839,12 @@ ** --unified Unified diff ** -v|--verbose Output complete text of added or deleted files ** -w|--ignore-all-space Ignore white space when comparing lines ** -W|--width Width of lines in side-by-side diff ** -Z|--ignore-trailing-space Ignore changes to end-of-line whitespace +** -- Treat all following arguments as files, +** even if they look like flags. */ void diff_cmd(void){ int isGDiff; /* True for gdiff. False for normal diff */ int isInternDiff; /* True for internal diff */ int verboseFlag; /* True if -v or --verbose flag is used */ @@ -900,11 +902,11 @@ if( zDiffCmd==0 ) zDiffCmd = diff_command_external(isGDiff); } zBinGlob = diff_get_binary_glob(); fIncludeBinary = diff_include_binary_files(); determine_exec_relative_option(1); - verify_all_options(); + verify_all_options2(); if( g.argc>=3 ){ int i; Blob fname; pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) ); memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1)); Index: src/file.c ================================================================== --- src/file.c +++ src/file.c @@ -1999,11 +1999,11 @@ } /* ** COMMAND: touch* ** -** Usage: %fossil touch ?OPTIONS? ?FILENAME...? +** Usage: %fossil touch ?OPTIONS? ?--? ?FILENAME...? ** ** For each file in the current checkout matching one of the provided ** list of glob patterns and/or file names, the file's mtime is ** updated to a value specified by one of the flags --checkout, ** --checkin, or --now. @@ -2028,10 +2028,12 @@ ** and each file it touches. ** -n|--dry-run Outputs which files would require touching, ** but does not touch them. ** -q|--quiet Suppress warnings, e.g. when skipping unmanaged ** or out-of-tree files. +** -- Treat all following arguments as non-flags, even if +** they look like flags. ** ** Only one of --now, --checkin, and --checkout may be used. The ** default is --now. ** ** Only one of -g or -G may be used. If neither is provided and no @@ -2100,11 +2102,11 @@ fossil_print("Timestamp = current system time.\n"); } } } - verify_all_options(); + verify_all_options2(); db_must_be_within_tree(); vid = db_lget_int("checkout", 0); if(vid==0){ fossil_fatal("Cannot determine checkout version."); Index: src/finfo.c ================================================================== --- src/finfo.c +++ src/finfo.c @@ -21,11 +21,11 @@ #include "finfo.h" /* ** COMMAND: finfo ** -** Usage: %fossil finfo ?OPTIONS? FILENAME +** Usage: %fossil finfo ?OPTIONS? ?--? FILENAME ** ** Print the complete change history for a single file going backwards ** in time. The default mode is -l. ** ** For the -l|--log mode: If "-b|--brief" is specified one line per revision @@ -53,10 +53,12 @@ ** to stdout (only in print mode) ** -s|--status select status mode (print a status indicator for FILE) ** -W|--width Width of lines (default is to auto-detect). Must be ** >22 or 0 (= no limit, resulting in a single line per ** entry). +** -- Treat all following arguments as files, even if they +** look like flags. ** ** See also: artifact, cat, descendants, info, leaves */ void finfo_cmd(void){ db_must_be_within_tree(); @@ -65,11 +67,11 @@ Blob line; Blob fname; int vid; /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( g.argc!=3 ) usage("-s|--status FILENAME"); vid = db_lget_int("checkout", 0); if( vid==0 ){ fossil_fatal("no checkout to finfo files in"); @@ -120,11 +122,11 @@ Blob record; Blob fname; const char *zRevision = find_option("revision", "r", 1); /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); file_tree_name(g.argv[2], &fname, 0, 1); if( zRevision ){ historical_blob(zRevision, blob_str(&fname), &record, 1); }else{ @@ -169,11 +171,11 @@ }else{ iWidth = -1; } /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( g.argc!=3 ){ usage("?-l|--log? ?-b|--brief? FILENAME"); } file_tree_name(g.argv[2], &fname, 0, 1); @@ -235,19 +237,21 @@ } /* ** COMMAND: cat ** -** Usage: %fossil cat FILENAME ... ?OPTIONS? +** Usage: %fossil cat ?OPTIONS? ?--? FILENAME ... ** ** Print on standard output the content of one or more files as they exist ** in the repository. The version currently checked out is shown by default. ** Other versions may be specified using the -r option. ** ** Options: ** -R|--repository FILE Extract artifacts from repository FILE ** -r VERSION The specific check-in containing the file +** -- Treat all following arguments as files, +** even if they look like flags. ** ** See also: finfo */ void cat_cmd(void){ int i; @@ -255,11 +259,11 @@ const char *zRev; db_find_and_open_repository(0, 0); zRev = find_option("r","r",1); /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); for(i=2; i0 && g.argDashDashIndex<=nArgPos + && fossil_strcmp("-",zName)==0){ + zName = "./-"; + } + return zName; +}; + +/* + ** Only for debugging during "--"-related refactoring. To be deleted + ** before merging with trunk. + */ +void dump_g_argv(){ int i; - for(i=1; i2 ) fossil_print("%.79c\n",'-'); Index: src/regexp.c ================================================================== --- src/regexp.c +++ src/regexp.c @@ -787,11 +787,11 @@ } /* ** COMMAND: grep ** -** Usage: %fossil grep [OPTIONS] PATTERN FILENAME +** Usage: %fossil grep [OPTIONS] ?--? PATTERN FILENAME ** ** Attempt to match the given POSIX extended regular expression PATTERN ** over all historic versions of FILENAME. For details of the supported ** RE dialect, see https://fossil-scm.org/fossil/doc/trunk/www/grep.md ** @@ -798,10 +798,13 @@ ** Options: ** ** -i|--ignore-case Ignore case ** -l|--files-with-matches List only checkin ID for versions that match ** -v|--verbose Show each file as it is analyzed +** -- Treat all following arguments as non-flags, +** even if they look like flags. Use this before +** the PATTERN or FILENAME, but not both. */ void re_grep_cmd(void){ u32 flags = 0; int bVerbose = 0; ReCompiled *pRe; @@ -811,11 +814,11 @@ if( find_option("ignore-case","i",0)!=0 ) ignoreCase = 1; if( find_option("files-with-matches","l",0)!=0 ) flags |= GREP_EXISTS; if( find_option("verbose","v",0)!=0 ) bVerbose = 1; db_find_and_open_repository(0, 0); - verify_all_options(); + verify_all_options2(); if( g.argc<4 ){ usage("REGEXP FILENAME"); } zErr = re_compile(&pRe, g.argv[2], ignoreCase); if( zErr ) fossil_fatal("%s", zErr); Index: src/stash.c ================================================================== --- src/stash.c +++ src/stash.c @@ -259,11 +259,11 @@ const char *zComment; /* Comment to add to the stash */ int stashid; /* ID of the new stash */ int vid; /* Current checkout */ zComment = find_option("comment", "m", 1); - verify_all_options(); + verify_all_options2(); if( zComment==0 ){ Blob prompt; /* Prompt for stash comment */ Blob comment; /* User comment reply */ #if defined(_WIN32) || defined(__CYGWIN__) int bomSize; @@ -511,12 +511,12 @@ ** COMMAND: stash ** ** Usage: %fossil stash SUBCOMMAND ARGS... ** ** fossil stash -** fossil stash save ?-m|--comment COMMENT? ?FILES...? -** fossil stash snapshot ?-m|--comment COMMENT? ?FILES...? +** fossil stash save ?-m|--comment COMMENT? ?--? ?FILES...? +** fossil stash snapshot ?-m|--comment COMMENT? ?--? ?FILES...? ** ** Save the current changes in the working tree as a new stash. ** Then revert the changes back to the last check-in. If FILES ** are listed, then only stash and revert the named files. The ** "save" verb can be omitted if and only if there are no other @@ -562,20 +562,25 @@ ** directory would be if STASHID were applied. With gdiff, ** gdiff-command is used instead of internal diff logic. ** ** SUMMARY: ** fossil stash -** fossil stash save ?-m|--comment COMMENT? ?FILES...? -** fossil stash snapshot ?-m|--comment COMMENT? ?FILES...? +** fossil stash save ?-m|--comment COMMENT? ?--? ?FILES...? +** fossil stash snapshot ?-m|--comment COMMENT? ?--? ?FILES...? ** fossil stash list|ls ?-v|--verbose? ?-W|--width ? ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS? ** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS? ** fossil stash pop ** fossil stash apply|goto ?STASHID? ** fossil stash drop|rm ?STASHID? ?-a|--all? ** fossil stash diff ?STASHID? ?DIFF-OPTIONS? ** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS? +** +** Options: +** -- For commands which support it, treat all following +** arguments as non-flags, even if they look like flags. +** */ void stash_cmd(void){ const char *zCmd; int nCmd; int stashid = 0; Index: src/tar.c ================================================================== --- src/tar.c +++ src/tar.c @@ -582,11 +582,11 @@ } /* ** COMMAND: tarball* ** -** Usage: %fossil tarball VERSION OUTPUTFILE [OPTIONS] +** Usage: %fossil tarball ?OPTIONS? VERSION ?--? OUTPUTFILE ** ** Generate a compressed tarball for a specified version. If the --name ** option is used, its argument becomes the name of the top-level directory ** in the resulting tarball. If --name is omitted, the top-level directory ** name is derived from the project name, the check-in date and time, and @@ -600,10 +600,13 @@ ** Options: ** -X|--exclude GLOBLIST Comma-separated list of GLOBs of files to exclude ** --include GLOBLIST Comma-separated list of GLOBs of files to include ** --name DIRECTORYNAME The name of the top-level directory in the archive ** -R REPOSITORY Specify a Fossil repository +** -- Treat all following arguments as non-flags, even if +** they look like flags. Use before the VERSION or +** OUTPUTFILE, but not both. */ void tarball_cmd(void){ int rid; Blob tarball; const char *zName; @@ -617,11 +620,11 @@ zInclude = find_option("include", 0, 1); if( zInclude ) pInclude = glob_create(zInclude); db_find_and_open_repository(0, 0); /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( g.argc!=4 ){ usage("VERSION OUTPUTFILE"); } g.zOpenRevision = g.argv[2]; Index: src/undo.c ================================================================== --- src/undo.c +++ src/undo.c @@ -420,12 +420,12 @@ /* ** COMMAND: undo ** COMMAND: redo* ** -** Usage: %fossil undo ?OPTIONS? ?FILENAME...? -** or: %fossil redo ?OPTIONS? ?FILENAME...? +** Usage: %fossil undo ?OPTIONS? ?--? ?FILENAME...? +** or: %fossil redo ?OPTIONS? ?--? ?FILENAME...? ** ** Undo the changes to the working checkout caused by the most recent ** of the following operations: ** ** (1) fossil update (5) fossil stash apply @@ -447,10 +447,12 @@ ** A single level of undo/redo is supported. The undo/redo stack ** is cleared by the commit and checkout commands. ** ** Options: ** -n|--dry-run do not make changes but show what would be done +** -- Treat all following arguments as non-flags, even if +** they look like flags. ** ** See also: commit, status */ void undo_cmd(void){ int isRedo = g.argv[1][0]=='r'; @@ -460,11 +462,11 @@ if( !dryRunFlag ){ dryRunFlag = find_option("explain", 0, 0)!=0; } db_must_be_within_tree(); - verify_all_options(); + verify_all_options2(); db_begin_transaction(); undo_available = db_lget_int("undo_available", 0); if( dryRunFlag ){ if( undo_available==0 ){ fossil_print("No undo or redo is available\n"); Index: src/unversioned.c ================================================================== --- src/unversioned.c +++ src/unversioned.c @@ -218,27 +218,30 @@ ** of each UV-file is retained. Changes to an UV-file are permanent and cannot ** be undone, so use appropriate caution with this command. ** ** Subcommands: ** -** add FILE ... Add or update one or more unversioned files in +** add ?--? FILE ... Add or update one or more unversioned files in ** the local repository so that they match FILEs ** on disk. Changes are not pushed to other ** repositories until the next sync. ** -** add FILE --as UVFILE Add or update a single file named FILE on disk +** add FILE --as UVFILE +** add --as UVFILE -- FILE +** Add or update a single file named FILE on disk ** and UVFILE in the repository unversioned file ** namespace. This variant of the 'add' command allows ** the name to be different in the repository versus ** what appears on disk, but it only allows adding ** a single file at a time. ** -** cat FILE ... Concatenate the content of FILEs to stdout. +** cat ?--? FILE ... Concatenate the content of FILEs to stdout. ** -** edit FILE Bring up FILE in a text editor for modification. +** edit ?--? FILE Bring up FILE in a text editor for modification. ** -** export FILE OUTPUT Write the content of FILE into OUTPUT on disk +** export ?--? FILE OUTPUT +** Write the content of FILE into OUTPUT on disk ** ** list | ls Show all unversioned files held in the local ** repository. ** ** revert ?URL? Restore the state of all unversioned files in the @@ -247,11 +250,11 @@ ** ** Options: ** -v|--verbose Extra diagnostic output ** -n|--dryrun Show what would have happened ** -** remove|rm|delete FILE ... +** remove|rm|delete ?--? FILE ... ** Remove unversioned files from the local repository. ** Changes are not pushed to other repositories until ** the next sync. ** ** sync ?URL? Synchronize the state of all unversioned files with @@ -261,16 +264,19 @@ ** ** Options: ** -v|--verbose Extra diagnostic output ** -n|--dryrun Show what would have happened ** -** touch FILE ... Update the TIMESTAMP on all of the listed files +** touch ?--? FILE ... Update the TIMESTAMP on all of the listed files ** ** Options: ** ** --mtime TIMESTAMP Use TIMESTAMP instead of "now" for the "add", ** "edit", "remove", and "touch" subcommands. +** -- For commands which support this, it means to treat +** all subsequent arguments as file names even if they +** start with a "-". */ void unversioned_cmd(void){ const char *zCmd; int nCmd; const char *zMtime = find_option("mtime", 0, 1); @@ -287,16 +293,16 @@ } if( memcmp(zCmd, "add", nCmd)==0 ){ const char *zError = 0; const char *zIn; const char *zAs; + const char *zFileArg; Blob file; int i; - zAs = find_option("as",0,1); - if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE"); - verify_all_options(); + verify_all_options2(); + if( zAs && g.argc!=4 ) usage("add --as UVFILE ?--? DISKFILE"); db_begin_transaction(); content_rcvid_init("#!fossil unversioned add"); for(i=3; i Width of lines (default is to auto-detect). Must be >20 ** or 0 (= no limit, resulting in a single line per entry). ** --setmtime Set timestamps of all files to match their SCM-side ** times (the timestamp of the last checkin which modified ** them). +** -- Treat all following arguments as non-flags, even if +** they look like flags. Use before the VERSION or +** FILES..., but not both. ** ** See also: revert */ void update_cmd(void){ int vid; /* Current version */ @@ -149,11 +152,11 @@ forceMissingFlag = find_option("force-missing",0,0)!=0; debugFlag = find_option("debug",0,0)!=0; setmtimeFlag = find_option("setmtime",0,0)!=0; /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); db_must_be_within_tree(); vid = db_lget_int("checkout", 0); user_select(); if( !dryRunFlag && !internalUpdate ){ @@ -757,11 +760,11 @@ } /* ** COMMAND: revert ** -** Usage: %fossil revert ?-r REVISION? ?FILE ...? +** Usage: %fossil revert ?-r REVISION? ?--? ?FILE ...? ** ** Revert to the current repository version of FILE, or to ** the version associated with baseline REVISION if the -r flag ** appears. ** @@ -773,10 +776,12 @@ ** If a file is reverted accidentally, it can be restored using ** the "fossil undo" command. ** ** Options: ** -r REVISION revert given FILE(s) back to given REVISION +** -- Treat all following arguments as files, even +** if they look like flags. ** ** See also: redo, undo, update */ void revert_cmd(void){ Manifest *pCoManifest; /* Manifest of current checkout */ @@ -789,11 +794,11 @@ int i; Stmt q; undo_capture_command_line(); zRevision = find_option("revision", "r", 1); - verify_all_options(); + verify_all_options2(); if( g.argc<2 ){ usage("?OPTIONS? [FILE] ..."); } if( zRevision && g.argc<3 ){ Index: src/wiki.c ================================================================== --- src/wiki.c +++ src/wiki.c @@ -1364,12 +1364,12 @@ ** ** Usage: %fossil wiki (export|create|commit|list) WikiName ** ** Run various subcommands to work with wiki entries or tech notes. ** -** %fossil wiki export PAGENAME ?FILE? -** %fossil wiki export ?FILE? -t|--technote DATETIME|TECHNOTE-ID +** %fossil wiki export PAGENAME ?--? ?FILE? +** %fossil wiki export -t|--technote DATETIME|TECHNOTE-ID ?--? ?FILE? ** ** Sends the latest version of either a wiki page or of a tech note ** to the given file or standard output. ** If PAGENAME is provided, the wiki page will be output. For ** a tech note either DATETIME or TECHNOTE-ID must be specified. If @@ -1425,10 +1425,15 @@ ** year-month-day form, it may be truncated, the "T" may be replaced by ** a space, and it may also name a timezone offset from UTC as "-HH:MM" ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" ** means UTC. ** +** Options: +** -- For commands which support this, it means to treat +** all subsequent arguments as file names even if they +** start with a "-". +** */ void wiki_cmd(void){ int n; db_find_and_open_repository(0, 0); if( g.argc<3 ){ @@ -1436,25 +1441,24 @@ } n = strlen(g.argv[2]); if( n==0 ){ goto wiki_cmd_usage; } - if( strncmp(g.argv[2],"export",n)==0 ){ const char *zPageName; /* Name of the wiki page to export */ const char *zFile; /* Name of the output file (0=stdout) */ const char *zETime; /* The name of the technote to export */ int rid; /* Artifact ID of the wiki page */ int i; /* Loop counter */ char *zBody = 0; /* Wiki page content */ Blob body; /* Wiki page content */ Manifest *pWiki = 0; /* Parsed wiki page content */ - zETime = find_option("technote","t",1); + verify_all_options2(); if( !zETime ){ if( (g.argc!=4) && (g.argc!=5) ){ - usage("export PAGENAME ?FILE?"); + usage("export PAGENAME ?--? ?FILE?"); } zPageName = g.argv[3]; rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" " ORDER BY x.mtime DESC LIMIT 1", @@ -1464,14 +1468,14 @@ zBody = pWiki->zWiki; } if( zBody==0 ){ fossil_fatal("wiki page [%s] not found",zPageName); } - zFile = (g.argc==4) ? "-" : g.argv[4]; + zFile = g.argc==4 ? "-" : get_dash_filename_arg(4); }else{ if( (g.argc!=3) && (g.argc!=4) ){ - usage("export ?FILE? --technote DATETIME|TECHNOTE-ID"); + usage("export --technote DATETIME|TECHNOTE-ID ?--? ?FILE?"); } rid = wiki_technote_to_rid(zETime); if ( rid==-1 ){ fossil_fatal("ambiguous tech note id: %s", zETime); } @@ -1479,11 +1483,11 @@ zBody = pWiki->zWiki; } if( zBody==0 ){ fossil_fatal("technote [%s] not found",zETime); } - zFile = (g.argc==3) ? "-" : g.argv[3]; + zFile = g.argc==3 ? "-" : get_dash_filename_arg(3); } for(i=strlen(zBody); i>0 && fossil_isspace(zBody[i-1]); i--){} zBody[i] = 0; blob_init(&body, zBody, -1); blob_append(&body, "\n", 1); @@ -1499,20 +1503,22 @@ Manifest *pWiki = 0; /* Parsed wiki page content */ const char *zMimeType = find_option("mimetype", "M", 1); const char *zETime = find_option("technote", "t", 1); const char *zTags = find_option("technote-tags", NULL, 1); const char *zClr = find_option("technote-bgcolor", NULL, 1); + verify_all_options2(); if( g.argc!=4 && g.argc!=5 ){ - usage("commit|create PAGENAME ?FILE? [--mimetype TEXT-FORMAT]" + usage("commit|create PAGENAME [--mimetype TEXT-FORMAT]" " [--technote DATETIME] [--technote-tags TAGS]" - " [--technote-bgcolor COLOR]"); + " [--technote-bgcolor COLOR] ?--? ?FILE?"); } zPageName = g.argv[3]; if( g.argc==4 ){ blob_read_from_channel(&content, stdin, -1); }else{ - blob_read_from_file(&content, g.argv[4], ExtFILE); + const char * zFilename = get_dash_filename_arg(4); + blob_read_from_file(&content, zFilename, ExtFILE); } if( !zMimeType || !*zMimeType ){ /* Try to deduce the mime type based on the prior version. */ if ( !zETime ){ rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" Index: src/zip.c ================================================================== --- src/zip.c +++ src/zip.c @@ -747,11 +747,11 @@ zInclude = find_option("include", 0, 1); if( zInclude ) pInclude = glob_create(zInclude); db_find_and_open_repository(0, 0); /* We should be done with options.. */ - verify_all_options(); + verify_all_options2(); if( g.argc!=4 ){ usage("VERSION OUTPUTFILE"); } g.zOpenRevision = g.argv[2]; @@ -780,11 +780,11 @@ } /* ** COMMAND: zip* ** -** Usage: %fossil zip VERSION OUTPUTFILE [OPTIONS] +** Usage: %fossil zip ?OPTIONS? VERSION ?--? OUTPUTFILE ** ** Generate a ZIP archive for a check-in. If the --name option is ** used, its argument becomes the name of the top-level directory in the ** resulting ZIP archive. If --name is omitted, the top-level directory ** name is derived from the project name, the check-in date and time, and @@ -798,19 +798,22 @@ ** Options: ** -X|--exclude GLOBLIST Comma-separated list of GLOBs of files to exclude ** --include GLOBLIST Comma-separated list of GLOBs of files to include ** --name DIRECTORYNAME The name of the top-level directory in the archive ** -R REPOSITORY Specify a Fossil repository +** -- Treat all following arguments as non-flags, even if +** they look like flags. Use before the VERSION or +** OUTPUTFILE, but not both. */ void zip_cmd(void){ archive_cmd(ARCHIVE_ZIP); } /* ** COMMAND: sqlar* ** -** Usage: %fossil sqlar VERSION OUTPUTFILE [OPTIONS] +** Usage: %fossil sqlar ?OPTIONS? VERSION ?--? OUTPUTFILE ** ** Generate an SQLAR archive for a check-in. If the --name option is ** used, its argument becomes the name of the top-level directory in the ** resulting SQLAR archive. If --name is omitted, the top-level directory ** name is derived from the project name, the check-in date and time, and @@ -824,10 +827,13 @@ ** Options: ** -X|--exclude GLOBLIST Comma-separated list of GLOBs of files to exclude ** --include GLOBLIST Comma-separated list of GLOBs of files to include ** --name DIRECTORYNAME The name of the top-level directory in the archive ** -R REPOSITORY Specify a Fossil repository +** -- Treat all following arguments as non-flags, even if +** they look like flags. Use before the VERSION or +** OUTPUTFILE, but not both. */ void sqlar_cmd(void){ archive_cmd(ARCHIVE_SQLAR); }