Skip to content
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

Invalid git core.abbrev values cause failure to open repositories #4272

Closed
davidkna opened this issue Aug 16, 2022 · 10 comments · Fixed by #4277
Closed

Invalid git core.abbrev values cause failure to open repositories #4272

davidkna opened this issue Aug 16, 2022 · 10 comments · Fixed by #4277
Labels
🐛 bug Something isn't working as expected.

Comments

@davidkna
Copy link
Member

davidkna commented Aug 16, 2022

Bug Report

Current Behavior

none of the git modules are working in a rather large (private) monorepo. for a smaller public repo, they do present. i do not have any submodules. i'd be happy to see if theres any debug flags to help isolate the problem. i'm just concerned that the new git crate is failing on this repo. my git version is 2.37.2

@daniel-white (#4266)

@davidkna
Copy link
Member Author

@daniel-white Please post the output of STARSHIP_LOG=trace starship module git_status. Is the repo owned by your system user? Do you know if the repo follows a special setup, for instance to improve monorepo performance?

@daniel-white
Copy link
Contributor

daniel-white commented Aug 16, 2022

nope we just normally use git to manage it. we use nx but thats tooling on the inside, not with git.

as for the ownership of the directory, its owned by my user account.

[TRACE] - (starship): Parsed arguments: Cli {
    command: Module {
        name: Some(
            "git_status",
        ),
        list: false,
        properties: Properties {
            status_code: None,
            pipestatus: None,
            terminal_width: 80,
            path: None,
            logical_path: None,
            cmd_duration: None,
            keymap: "viins",
            jobs: 0,
        },
    },
}
[DEBUG] - (starship::config): STARSHIP_CONFIG is not set
[DEBUG] - (starship::config): Using default config path: /Users/danielwhite/.config/starship.toml
[TRACE] - (starship::utils): Trying to read from "/Users/danielwhite/.config/starship.toml"
[TRACE] - (starship::utils): File read successfully
[TRACE] - (starship::config): Config file content: "
[character]
success_symbol = "[\\$](bold green)"
error_symbol = "[\\$](bold red)"

[aws]
disabled = true

[nodejs]
symbol = "⬢"

[gcloud]
disabled = true

# [env_var.APPLE_ARCH]
# symbol = "💻"
# format = "$symbol [$env_value]($style)"
# style = "white"
"
[DEBUG] - (starship::config): Config parsed: Table({"character": Table({"success_symbol": String("[\\$](bold green)"), "error_symbol": String("[\\$](bold red)")}), "aws": Table({"disabled": Boolean(true)}), "nodejs": Table({"symbol": String("⬢")}), "gcloud": Table({"disabled": Boolean(true)})})
[TRACE] - (starship::context): Received completed pipestatus of None
[TRACE] - (starship::config): No config found for "git_status": Option "git_status" not found
[TRACE] - (starship::modules): Took 1.631791ms to compute module "git_status"
[TRACE] - (starship::config): No config found for "git_status": Option "git_status" not found
[TRACE] - (starship::context): Received completed pipestatus of None
[TRACE] - (starship::config): No config found for "git_branch": Option "git_branch" not found
[TRACE] - (starship::modules): Took 1.554ms to compute module "git_branch"
[TRACE] - (starship::config): No config found for "git_branch": Option "git_branch" not found

@davidkna
Copy link
Member Author

@daniel-white It seems like the repo isn't being discovered. Please post a list of the files in the base level of the .git directory. Logging is a bit lacking for this step. If possible, please also share the log messages with #4273 applied.

@Byron Do you have any ideas on how to best debug this or on possible causes? In particular, do you know any gix/ein commands that could help with debugging?

@daniel-white
Copy link
Contributor

COMMIT_EDITMSG
FETCH_HEAD
HEAD
ORIG_HEAD
config
description
fork-settings
hooks
index
info
issuetracker
logs
objects
packed-refs
refs

@daniel-white
Copy link
Contributor

also i tried installing gitoxide with cargo install gitoxide, and its requiring me to install a cmake toolchain :/

@davidkna
Copy link
Member Author

davidkna commented Aug 16, 2022

@daniel-white try --no-default-features --features small (default-features = false should also avoid cmake for starship builds)

@daniel-white
Copy link
Contributor

daniel-white commented Aug 16, 2022

so this is interesting

$ gix config
Error: The value for 'core.abbrev' cannot be empty

where that works in the other repo.

setting that to auto allows gix config then starship to run.

i wonder if theres a problem in gitoxide that makes this mandatory where libgit2 and the like more forgiving.

one can repro if with git config core.abbrev "" and git config --unset core.abbrev restores it

@davidkna
Copy link
Member Author

@daniel-white Thanks for the update!

@davidkna davidkna changed the title git modules not working in a large monorepo Invalid git core.abbrev values cause failure to open repositories Aug 16, 2022
@Byron
Copy link
Contributor

Byron commented Aug 17, 2022

@Byron Do you have any ideas on how to best debug this or on possible causes? In particular, do you know any gix/ein commands that could help with debugging?

Indeed, the only way to see what's going on is to run gix - since it will use discover() to open a Repository, failing to do so will fail the whole command. Tracing is not available in gitoxide yet.

Thanks everyone for debugging this, even though the error is quite intentional and definitely worth a thought.

$ gix config
Error: The value for 'core.abbrev' cannot be empty

If a lesson is to be learned here, then it's probably that gitoxide should be more fault tolerant where possible, and with core.abbrev it's definitely possible to set it to a sensible value in this case. It's interesting that git itself refuses to work on such a repo as well with…

❯ git log
error: missing value for 'core.abbrev'
fatal: bad config variable 'core.abbrev' in file '.git/config' at line 8

…in my case.

As a catch-22 though, since gix config wants to initialize a Repository, it fails on that and one wouldn't be able to run a gix command on such repository ever again.

I will change this behaviour and review other places as well to make startup as forgiving as possible.

@Byron
Copy link
Contributor

Byron commented Aug 17, 2022

I have implemented this by interpreting configuration values leniently by default, which is behaviour more suitable to API users or starship in this case, while allowing to opt-in to strict and 'correct' mode which errors on unsupported values to force them to be fixed, similar to what git does. The gix program was also adjusted to use the 'strict' mode so it would choke similarly to git, while allowing gix config to be lenient automatically.

A new release will be created in the course of my day and starship should be able to pick up the fixes in the course of the same day (I am 6 hours ahead of starship maintainers).

Byron added a commit to Byron/starship that referenced this issue Aug 17, 2022
This release comes with lenient configuration handling by default,
allowing to open repositories even their configuration values are
invalid (even for git), as long as there are viable defaults.

Furthermore this release adds the ability to open submodule repsitories.

Fixes starship#4266 and
fixes starship#4272
andytom pushed a commit that referenced this issue Aug 18, 2022
* upgrade `gitoxide` to v0.21

This release comes with lenient configuration handling by default,
allowing to open repositories even their configuration values are
invalid (even for git), as long as there are viable defaults.

Furthermore this release adds the ability to open submodule repsitories.

Fixes #4266 and
fixes #4272

* Assure an object cache is set to speed up `commit.describe()`

Related to #4275 bringing
performance to spitting distance compared to git.
Indyandie pushed a commit to Indyandie/starship that referenced this issue Jul 26, 2023
* upgrade `gitoxide` to v0.21

This release comes with lenient configuration handling by default,
allowing to open repositories even their configuration values are
invalid (even for git), as long as there are viable defaults.

Furthermore this release adds the ability to open submodule repsitories.

Fixes starship#4266 and
fixes starship#4272

* Assure an object cache is set to speed up `commit.describe()`

Related to starship#4275 bringing
performance to spitting distance compared to git.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working as expected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants