Skip to content

git: Fix ordering of `--end-of-options` and mark commands as supporting the separator

Patrick Steinhardt requested to merge pks-git-end-of-options into master

Git commands support two kinds of separators to disambiguate command line options: --end-of-options tells it that from here on, option parsing has concluded and that all remaining options are to be considered normal positional command line parameters. And -- typically separates revisions from paths for positional arguments, like for example in git-log(1). A command using both would thus e.g. like the following:

$ git log --follow --end-of-options HEAD -- Makefile

As it turns out, our Git DSL puts both types of separators in the same place though, ending up with the following equivalent instead:

$ git log --follow HEAD --end-of-options -- Makefile

This command does work the same in this case, but it is not how it's intended to work given that we may now potentially interpret "HEAD" as an option. While we do validate that no positional arguments start with leading dashes, this is rather about safety in depth.

Fix this bug and move --end-of-options immediately after all flags and before the positional arguments.

Subsequent commits adjust commands to be marked as supporting the separator on a case by case basis.

Merge request reports

Loading