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

Add status for subdirectories that are git repositories #797

Closed
wants to merge 25 commits into from

Conversation

alpn
Copy link

@alpn alpn commented Jan 31, 2021

This PR adds an optional Repo column, showing git information about repositories located directly under the currently searched path, as requested in #730 and #420.

image

Currently it piggybacks the —git flag (and works in conjunction with it)

	modified:   src/fs/feature/git.rs
…directories that are git repos (ogham#730)

	modified:   src/options/view.rs
	modified:   src/output/table.rs
	modified:   src/output/render/git.rs
	modified:   src/output/table.rs
--no-default-features configuration

	modified:   src/fs/feature/mod.rs
	modified:   src/fs/fields.rs
	modified:   src/fs/feature/git.rs
	modified:   src/fs/feature/mod.rs
	modified:   src/fs/fields.rs
	modified:   src/output/render/git.rs
	modified:   src/output/table.rs
@ariasuni ariasuni added features › git Things to do with Git features › ui Things to do with the UI and removed features › git Things to do with Git features › ui Things to do with the UI labels Jun 22, 2021
@ariasuni
Copy link
Collaborator

ariasuni commented Jun 27, 2021

To be honest I don’t really care about this feature so it wasn’t in my priorities, but it looks very small and clean so I think I’d like to merge it.

However:

  • What’s X and V? These labels are not intuitive in my opinion
  • I wonder if it should be the same as --git or split into its own flag

Edit: also, could you fix the small conflict with master?

@ariasuni
Copy link
Collaborator

ariasuni commented Jun 30, 2021

In fact I think it’s a cool feature if it works with git submodules. Do you think you could check that?

recent trend in the git ecosystem (see - https://github.com/github/renaming)

	modified:   src/output/render/git.rs
@alpn
Copy link
Author

alpn commented Jun 30, 2021

Thanks for the feedback @ariasuni

The X and V labels indicate the status of the the entire repository as either dirty (e.g there are uncommitted changes) or clean (the equivalent of git status returning “nothing to commit, working tree clean“) respectively.
It's somewhat inspired by oh-my-zsh, and the screenshot that @YAMLcase provided in #730.
How would you suggest to make it more intuitive?

Submodules already get detected as repos in their own right, and as such, their status will be shown as well.

@YAMLcase
Copy link

How would you suggest to make it more intuitive?

One option:
Nothing or an underscore/dash for clean, 1-9 for number of changed files or lines. 9 would indicate "9 or more" like some badge systems that stick to a single digit.

@alpn
Copy link
Author

alpn commented Jul 22, 2021

Thanks @YAMLcase, but honestly I prefer to keep it simple and stick to an explicit binary indicator (i.e, either clear or dirty)
However, here’s another option inspired by your comment:

image

Do you find it more intuitive @ariasuni?

I too was debating about adding a separate flag vs piggybacking --git, but had eventually decided to go with the latter because:

  1. Having used this feature myself for a few months now, I never felt like a special flag was missing.
  2. It’s simpler, and requires less changes to the code base.

That being said, I’m open to adding it if you think it’s crucial.

Otherwise, I’ve fixed the conflicts with master so it’s should be mergeable now.

@adamshand
Copy link

I'd love to see this merged!

@alpn
Copy link
Author

alpn commented Oct 10, 2021

Up to date with upstream again.
@ariasuni please let me know if there’s anything else I could do to get it merged.

Copy link

@bew bew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the branch name, you're showing only short branch names.
It's not uncommon to work with medium to long branch names like fix-for-this-long-feature-name, I fear the result would be a lot of blank spaces..
Would it be possible to add an option to limit the size of the displayed branch name ? (like 10 or 15 chars max)

src/fs/feature/git.rs Outdated Show resolved Hide resolved
	modified:   src/fs/feature/git.rs
	modified:   src/fs/feature/git.rs
@alpn
Copy link
Author

alpn commented Nov 14, 2021

For the branch name, you're showing only short branch names. It's not uncommon to work with medium to long branch names like fix-for-this-long-feature-name, I fear the result would be a lot of blank spaces.. Would it be possible to add an option to limit the size of the displayed branch name ? (like 10 or 15 chars max)

Thanks @bew, good point!
Added “indicative” truncation when branch name exceeds 10 chars, so this:

image

Becomes this:

image

Also fixed the other issue.

@arazabishov
Copy link

This is awesome! Thank you for making this change. My 2 cents, assuming that git status is used to get branch/status info.

  • Some git repos are massive and running git status on them can be very slow. It would be great to have a flag or a config option to switch off the clean/dirty column.
  • With branch names we have several options that are faster than git status, such as git rev-parse --abbrev-ref HEAD.

@ariasuni
Copy link
Collaborator

Exa uses libgit2 directly (which is slow anyway…)…

@roland-5
Copy link

Is there option to change from libgit2 to https://github.com/Byron/gitoxide ?

@ariasuni
Copy link
Collaborator

It’s not very clear to me if gitoxide has a way to get status info (not even talking about the fact it has to be either a crate, or the output of the gix command for status info has to have a porcelain mode), though it sounds promising.

@arazabishov
Copy link

What is left on this PR to get addressed before it can be merged?

…-repos and -—git-repos-no-status

The latter skips git status lookup and thereby faster
@alpn
Copy link
Author

alpn commented Oct 9, 2022

Thanks for the feedback @arazabishov

I’ve just added two dedicated flags for this feature:

--git-repos - shows both the status, and the branch name (like in the screenshots above)
--git-repos-no-status - skips the status lookup altogether and is hence much faster, as expected :)

Running exa with --git-repos-no-status returns almost immediately, even for directories with lots of repos (including, e.g linux, and openbsd)

@alpn
Copy link
Author

alpn commented Aug 12, 2023

Fixed some minor conflicts, so it's gtg again.
Would still love to see this one merged in @ariasuni :)

@ariasuni
Copy link
Collaborator

ariasuni commented Sep 9, 2023

Closing this, since exa is unmaintained (see #1243), and this has been merged in the active fork eza. Thanks!

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.

7 participants