Skip to content

Conversation

@chrisant996
Copy link
Contributor

This compensates for a recent 🚨 breaking change 🚨 in git:

Git has changed how it stores refs, and how it stores the current branch info. In a repo with reftables, Cmder shows the branch name as ".invalid".

The changes here update Cmder's Lua prompt (i.e. for Clink) to replace ".invalid" with "Loading..." until the git status command finishes in the background, and then it can update the prompt with the accurate branch name.

The changes here also move the " -> remote" logic from clink-completions/git_prompt.lua directly into the Cmder prompt implementation (otherwise it can't work properly with reftables).

There were also changes necessary in clink-completions to support git reftables, and the clink-completions repo has already been updated accordingly (and the git_prompt.lua script has been completely deleted since it really always belonged as built into Cmder anyway).

To test git reftables, you can use the latest version of git to create a new repo: git init test_repo && cd test_repo. Without these changes, the Cmder prompt will be incorrect. With these changes, the Cmder prompt should briefly showing "Loading..." and then show the correct branch name. It won't say "Loading..." again until you change to a different repo.

Or you can simulate the behavior by running set CLINK_DEBUG_GIT_REFTABLE=1.

Also move the " -> remote" logic from clink-completions/git_prompt.lua
directly into the Cmder prompt implementation (otherwise it can't work
properly with reftables).
"git branch" does not work in a newly inited repo.  So in a newly inited
using reftables, the branch name was not able to be retrieved, and the
"Loading..." placeholder remained indefinitely.

This change updates it to try again with "git branch --show-current"
when "git branch" prints empty output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant