forked from git/git
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Executing git <cmd> -h crashes if git doesn't run inside a reporsitory #3688
Labels
Comments
It also happens with a regular install. As a matter of fact, it even happens with a Linux version of Git. |
dscho
added a commit
to dscho/git
that referenced
this issue
Feb 7, 2022
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. This fixes git-for-windows#3688 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho
added a commit
to dscho/git
that referenced
this issue
Feb 7, 2022
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 git-for-windows#3688 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
I opened gitgitgadget#1139 and plan on sending it to the Git mailing list as soon as the PR build gives me confidence in addition to the passing test suite on my machine. |
dscho
added a commit
to dscho/git
that referenced
this issue
Feb 8, 2022
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 git-for-windows#3688 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Thank you very much for the quick response. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup
defaults?
to the issue you're seeing?
Not in my environment. But the problem didn't occur with MinGit 2.34.1 busybox (2.34.1.windows.1)
The problem started with version 2.35.0
Details
PowerShell 5
Minimal, Complete, and Verifiable example
this will help us understand the issue.
The help for the corresponding command should be displayerd
git crashes with error:
BUG: repo-settings.c:23: Cannot add settings for uninitialized repository
URL to that repository to help us with testing?
** insert URL here **
The text was updated successfully, but these errors were encountered: