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

Show git submodule #42

Closed
pablogipi opened this issue May 3, 2023 · 22 comments
Closed

Show git submodule #42

pablogipi opened this issue May 3, 2023 · 22 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@pablogipi
Copy link

At the moment if you go to a folder thta is a git submodule, flex-prompt show the parent repo states/branch instead of the submodule's.
Would be gret to have parameter for the git module to get the status/branch from the submodule if present, instead of showing the parent repo.

Thanks.

@chrisant996 chrisant996 added the enhancement New feature or request label May 11, 2023
@chrisant996
Copy link
Owner

@pablogipi Can you clarify the request?

  1. Are you asking to use --ignore-submodules=none so that status INCLUDES all submodules?
  2. Are you asking to show status for ONLY the current submodule, when the current working directory is in a submodule?
  3. Are you asking for some other behavior?

If you're just asking for # 1, i.e. add an optional :submodules arg to simply force using --ignore-submodules=none, then that's easy, and I'm adding that.

But if you're asking for # 2, then it quickly gets murky. Git doesn't seem to have a way to do that, so it would have to be 100% custom code. It would require running additional git commands to find all submodules and their respective directories, compare against the current working directory, and filter away modified files that are from a different submodule/repo than the current directory. And it would raise many questions about confusing/quirky situations:

  • What about when not in submodule -- should it hide status of submodules?
  • What about the branch display -- should it reflect the submodule, or the repo?
  • What about the "detached HEAD" display?
  • What about the ahead/behind counts?
  • Etc.

@pablogipi
Copy link
Author

Hello Chris.
I think Im talking more about the second option.

  • I would hide the status for submodules if not inside one.
  • The branch is the most important for me, it should reflect the current submodule branch.
  • detached HEAD and ahead/behind should be for the current submodule.

cmder-powerline-prompt works in this way, it gives preference for submodules when you ire inside it, which is relly really useful.
Here is the module for git

We can do a test with option 1 as an starter.

Thanks

@chrisant996 chrisant996 added bug Something isn't working and removed enhancement New feature or request labels May 16, 2023
@chrisant996
Copy link
Owner

That's interesting, because that's the project that was the original source for clink-flex-prompt, and that's mentioned near the top of the README in this repo.

You stated that both the branch status and file status are being shown from the parent.

Are you sure the file status is inaccurate?

I see something a little different:

  • Re: file status -- for me, both cmder-powerline-prompt and clink-flex-prompt report the file status the same: in the parent the parent file status is reported, and in a submodule the submodule file status is reported.
  • Re: branch info -- for me, clink-flex-prompt reports branch info from the parent (not sure yet why).

@pablogipi
Copy link
Author

Yes, that is exactly what motivated me to open this issue.
When I switched from powerline-prompt to clink-flex-prompt I noticed that in my submodules the branch that was shown was the parent instead of the submodule's branch.
Cheers

@chrisant996
Copy link
Owner

Ok, what misled me was the statement that "flex-prompt show the parent repo states/branch instead of the submodule's". But it's only the branch info that's inaccurate.

And I see why. I'll make a fix.

@pablogipi
Copy link
Author

Thanks Chris!!

@chrisant996
Copy link
Owner

When support for worktrees was added, detection of submodules got broken.

@pablogipi
Copy link
Author

I'll check scoop to update it in my systems.
Thanks for the fix!

@pablogipi
Copy link
Author

Tested today and working fine, thanks
I was wondering, I think it would be useful to ad an icon besides the usual branch icon in the prompt to add hint that the current path is inside a submodule rather than in a regular git repo.
What do you think?

@chrisant996
Copy link
Owner

I was wondering, I think it would be useful to ad an icon besides the usual branch icon in the prompt to add hint that the current path is inside a submodule rather than in a regular git repo.
What do you think?

Which icon do you suggest?

@pablogipi
Copy link
Author

He! Apparently in devicons there is one for submodules:

https://icons8.com/icons/set/git-submodule

image

I think is can go between the git logo and the branch icon.

image

Thanks!

@chrisant996
Copy link
Owner

chrisant996 commented Jun 1, 2023

@pablogipi There's been a misunderstanding. Text terminals can't use graphical icon files.

You'd have to look in Nerd Fonts Cheat Sheet for icons that can potentially be available in some customized nerd fonts. Many such icons end up illegible at the small font sizes typically used in terminal windows.

For example, like this:

image

In the screenshot I searched for "submodule" and there are two nerd icons available matching that keyword (searching for "folder" or other keywords may find other potentially suitable icons).

In the screenshot I hovered over the first one, which makes a menu show up for "COPY" options. If you click "Icon" it copies the selected nerd icon character into the clipboard, and then you can paste it into a terminal window.

Here is what that icon actually looks like in Windows Terminal, when using a nerd font that includes that icon (not all nerd fonts include all icons):

image

By the way, the second icon from the screen shot isn't available in most nerd fonts, and it pastes as the "character not present in font" symbol. This is why it's important to test whether a proposed icon is available in nerd fonts. Also, just because it's available in one nerd font doesn't mean it's available in others. The icons currently used by clink-flex-prompt are available in most nerd fonts; it takes time and effort to find suitable icons and verify them.

Those are the reasons why my response to the suggestion to use a different icon for submodules was to ask "which icon?" Because there are very few options, very little control available, and a lot of verification effort is required. So, while I agree that using another icon could be nice, I definitely need specified suggestions, and ideally the suggestions need to have been verified to be truly viable (i.e. that the icon is legible enough to be recognizable and that the icon is actually present in most nerd fonts).

Also, are you suggesting to show several icons in a row? One for "git", one for "submodule", and one for "branch"? Or are you suggesting to replace the "git" icon with a "submodule" icon? Or are you suggesting to replace the "branch" icon with a "submodule" icon?

@pablogipi
Copy link
Author

Yep I know, the links I sent before were for the devicons that are part of the NerdFonts.
And yes I agree that some of these icons don't look really good when rendered as fonts.
My idea is to have several icons in a row, one for git, then optionally the submodule icon and then the branch icon.
The folder icon probably is going to look awkward, even when is the submodule icon.

@chrisant996
Copy link
Owner

I was looking for a specific suggestion of a textual Unicode codepoint to use, since that's the only thing that can actually be used. A link to an image file isn't usable.

I would prefer something legible.

In this case, the majority of the work is hunting down possible icons and verifying how widely they're actually available in nerd fonts. That involves many hours, and it's work that others can do just as easily as myself. If you or someone else does the work of finding a suitable icon, then it's pretty quick for me to add code to use it.

@chrisant996 chrisant996 added the enhancement New feature or request label Jun 1, 2023
@chrisant996
Copy link
Owner

NerdFonts recently released a v3 of the fonts and icons.

It's a major change in what icons are available, which Unicode codepoint they're available at, and how wide they are.

The good news is there's a submodule icon and it's double-wide now so it's very legible.

The bad news is:

  • flexprompt doesn't know about the new nerdfont v3 changes, and things can look wrong with the v3 fonts.
  • The NF v3 redesign creates new compatibility problems between fonts. E.g. if some terminal windows use NF v2 fonts and some use NF v3 fonts, then there isn't a "global" configuration for flexprompt that can work in both kinds of cases. People will have to consistently use v2 or v3 for all windows, OR they can opt to set environment variables in different windows to tell flexprompt which kind of icons the window is using.
  • The configuration wizard is going to need a bit of new work done on it to help detect what icons to actually show.

Ugh.

@pablogipi
Copy link
Author

I think is better to stick to v2.
Looking at https://www.nerdfonts.com/cheat-sheet I propose any of these ones as good options:

  • nf_md_consolidate
  • nf_md_import
  • nf_md_layers
  • nf_md_pot

@chrisant996
Copy link
Owner

I think is better to stick to v2.

I think you mean supporting v2 is worthwhile. Yes, of course.

But I can't make v3 not exist, and I can't make people not use it, and it has better icons. If you're saying flexprompt shouldn't even add support for v3 at all, then that wouldn't make sense. I'll be adding support for v3, which means making the wizard help figure out which one is being used, so that flexprompt can support both v2 and v3 (obviously not at the same time on a given computer).

Looking at https://www.nerdfonts.com/cheat-sheet I propose any of these ones as good options:

  • nf_md_consolidate
  • nf_md_import
  • nf_md_layers
  • nf_md_pot

I'll take a look at them and their availability, thanks for the suggestions!

@pablogipi
Copy link
Author

No, I mean stick to v2 for the submodule icon.

@chrisant996
Copy link
Owner

No, I mean stick to v2 for the submodule icon.

Do you recognize the consequences of that proposal? It would mean flexprompt would be incompatible with the current versions of NerdFonts, and people would be unable to use flexprompt (with icons) with NerdFonts anymore. That wouldn't make any sense.

Maybe the meaning of "v2" and "v3" was unclear? It refers to the version of the fonts themselves. A font cannot be "both" v2 and v3. A v2 nerd font and a v3 nerd font have different icons at different Unicode codepoints. If flexprompt "sticks to v2" that means it will not work when using a v3 font, and that is very unacceptable.

As I said, I will make flexprompt support v2 when you use v2, and support v3 when you use v3.

@chrisant996
Copy link
Owner

Full support is coming for:

  • mono icon fonts (icons are the same width as other characters)
  • double-width icon fonts (icons are double the width of other characters)
  • nerd fonts v2 fonts
  • nerd fonts v3 fonts (released Apr 2023)

Plus, an option to use color emoji in Windows Terminal for certain icons.

@pablogipi
Copy link
Author

Uuuh that's great, thanks for the update!

@chrisant996
Copy link
Owner

chrisant996 commented Jun 18, 2023

The combination of Clink v1.4.28 and clink-flex-prompt v0.14 should handle showing an icon for git submodule, and supporting different versions and widths of nerdfonts, and supporting certain color emoji in Windows Terminal.

The new releases have been published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants