]> git.ipfire.org Git - thirdparty/git.git/commit - scalar.c
scalar: accept -C and -c options before the subcommand
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 28 Jan 2022 14:31:57 +0000 (14:31 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Jan 2022 23:14:38 +0000 (15:14 -0800)
commit2ae8eb5d71028f0289b4b38663d07b6eefee23a6
tree3077549f2891d09315bbb18d52245a81594b4124
parentb23dac905bde28da47543484320db16312c87551
scalar: accept -C and -c options before the subcommand

The `git` executable has these two very useful options:

-C <directory>:
switch to the specified directory before performing any actions

-c <key>=<value>:
temporarily configure this setting for the duration of the
specified scalar subcommand

With this commit, we teach the `scalar` executable the same trick.

Note: It might look like a good idea to try to reuse the
`handle_options()` function in `git.c` instead of replicating only the
`-c`/`-C` part. However, that function is not only not in `libgit.a`, it
is also intricately entangled with the rest of the code in `git.c` that
is necessary e.g. to handle `--paginate`. Besides, no other option
handled by that `handle_options()` function is relevant to Scalar,
therefore the cost of refactoring vastly would outweigh the benefit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/scalar/scalar.c
contrib/scalar/scalar.txt
contrib/scalar/t/t9099-scalar.sh