Johannes Schindelin 059fda1902 checkout/fetch/pull/pack-objects: allow -h outside a repository
When we taught these commands about the sparse index, we did not account
for the fact that the `cmd_*()` functions _can_ be called without a
gitdir, namely when `-h` is passed to show the usage.

A plausible approach to address this is to move the
`prepare_repo_settings()` calls right after the `parse_options()` calls:
The latter will never return when it handles `-h`, and therefore it is
safe to assume that we have a `gitdir` at that point, as long as the
built-in is marked with the `RUN_SETUP` flag.

However, it is unfortunately not that simple. In `cmd_pack_objects()`,
for example, the repo settings need to be fully populated so that the
command-line options `--sparse`/`--no-sparse` can override them, not the
other way round.

Therefore, we choose to imitate the strategy taken in `cmd_diff()`,
where we simply do not bother to prepare and initialize the repo
settings unless we have a `gitdir`.

This fixes https://github.com/git-for-windows/git/issues/3688

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-02-08 09:54:44 -08:00
..
2022-01-10 11:52:56 -08:00
2021-12-21 15:03:17 -08:00
2022-01-12 15:11:43 -08:00
2021-10-28 09:57:09 -07:00
2021-02-25 16:43:30 -08:00
2021-12-06 09:55:06 -08:00
2021-10-23 10:45:25 -07:00
2022-01-10 11:52:56 -08:00
2021-04-14 13:47:21 -07:00
2021-09-28 10:31:02 -07:00
2022-01-10 11:52:53 -08:00
2022-01-03 16:24:15 -08:00
2022-01-03 16:24:15 -08:00
2022-01-10 11:52:56 -08:00
2022-01-28 16:45:52 -08:00
2022-01-05 13:31:00 -08:00
2021-11-03 13:25:36 -07:00