Update the Lua git prompt to support repos with git reftables. #3056
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.