Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
| Artifact ID: | 5b19223401d68ed90b49c8023c87032b23f042692e3539a3b6e261c009e5de5b |
|---|---|
| Page Name: | branch/double-dash-flag |
| Date: | 2019-09-27 11:50:36 |
| Original User: | stephan |
| Mimetype: | text/x-markdown |
| Parent: | 8c84b2a79575026b954a5abe2ad288751bc892e83fa425eadf46b6a01730c19d (diff) |
| Next | 6075be4e19e9dbe94c3b4691dc005625381afca76e4b1bea44bdb82d1b558b47 |
The double-dash-flag branch aims to add support for the conventional interpretation of a -- flag: all arguments after the first instance of -- are to be treated as non-flag arguments (e.g. file/wiki/branch/whatever names).
This feature request is from: https://fossil-scm.org/forum/forumpost/64acc6b653
The implementation is not 100% compliant with POSIX/Unix conventions because it cannot be without Breaking Stuff, but it "should" be close enough to be useful/conventional for the contexts where using -- makes sense in Fossil. For example, uv add treats a filename of - as stdin by default (and has valid use cases enabled by that), and -- could be used to make uv add treat - as a filename (that's the original use case for which conventional -- support was proposed).
Fossil's historical handling of -- is really weird: the first time find_option() encounters --, it removes that flag and stops processing arguments. Subsequent calls to find_option() then never see -- and thus treat all arguments as potential flags (even those after the prior position of --). Since that behaviour was never useful, and potentially confusing, it is unexpected that the changes made in this branch will break any historical usage of the CLI commands.
The placement of the -- flag is significant, of course::
fossil branch new FOO BAR --private
If a user insisted on having a branch named - and did:
fossil branch new -- - BAR --private
then --private would be seen as a non-flag argument. Anyone using -- for this purpose would necessarily be using a newer version of fossil where -- has well-defined semantics, and therefore would not place --private after --.
Commands which accept a filename as the value of a flag are unaffected by these changes, provided the flag comes before --:
fossil foo -R - -- -a -b -c
Would (both before and after this change) treat - as a repository file name, but this change will cause the subsequent -a -b -c flags to be interpreted as non-flags. The current (trunk, as of this writing) interpretation of -a -b -c, because of the "one-time-swallowing" of --, depends on what order those flags were checked for via find_option().
(ONGOING) List of commands/subcommands extended to support --
(Please keep this list alphabetized by command/subcommand name.)
branch new: you might recall Johnny Cash's song The Branch Named --Sue.uv add: unconditionally reads in its contents viablob_read_from_file(), which internally treats-as stdin. Thus adding--support here requires (A) thatuv addknow that--was provided, (B) that--was provided before-, and (C) special-casing-in that case (only) to not read fromstdin. Hopefully we don't have many such cases.uv cat | edit | export | rm