lsd icon indicating copy to clipboard operation
lsd copied to clipboard

Create a git integration

Open Peltoche opened this issue 6 years ago • 18 comments

Peltoche avatar Dec 04 '18 19:12 Peltoche

Can you explain what kind of git integration you're looking to add?

alichtman avatar Dec 06 '18 22:12 alichtman

Hello @alichtman,

There is no defined specs yet. This feature is already implemented by the colorls and the exa projects, I think it can be a good start to check how they do it.

Peltoche avatar Dec 07 '18 12:12 Peltoche

There is an example on the exa website: https://the.exa.website/features/git

Basically there is a new column that displays the git status for the files in the listed directory. (new, modified etc..)

ysf avatar Dec 11 '18 22:12 ysf

Seems cool. I think that we can do something even better with the icons support. I don't know if we should add a new icons for the git status or just override the existing one. We can also add a new column of course.

Peltoche avatar Dec 12 '18 10:12 Peltoche

Another tool to check out that displays the git status of files is ranger. I like their use of icons, and I also like that they display the git status of entire repos too, so you could ls -l the current directory and see which repos are dirty. Screenshot.

cjbassi avatar Feb 23 '19 21:02 cjbassi

Maybe add a option or a flag to hide files based on the .gitignore file

leomikezee avatar Mar 12 '19 06:03 leomikezee

I definitely support this. Would be useful to be able to see the current git status of files and also being able to hide files based on the .gitignore file.

patevs avatar Apr 20 '20 02:04 patevs

+1 from me! I'd really love to have this as well, it's the only thing I still miss from exa/colorls!

aseifert avatar Oct 14 '20 10:10 aseifert

+1!!!!

sherifabdlnaby avatar Jan 08 '21 00:01 sherifabdlnaby

I like this idea; maybe I can do it. Is there already someone on this issue ?

About the icons, if we want funny glyphs, my suggestions are (from https://www.nerdfonts.com/cheat-sheet) * check (-): nf-fa-check f00c * modified (M): nf-fa-gear f013 * uknown (?): nf-fa-user_secret f21b * ignored (!) : nf-mdi-ghost f79f (or nf-fa-exclamation f12a) * new (+) : nf-mdi-login_variant fafb Capture d’écran 2021-02-28 à 13 11 49

The display should be with two columns (staged, not staged)

To get git info, I can use libgit2 (https://github.com/rust-lang/git2-rs)

Is there any other constraint ?

hpwxf avatar Feb 28 '21 12:02 hpwxf

Hi @hpwxf , There is noone working on this right now, please feel free to take this up and thanks for contributing to LSD!

as the icons part, maybe we should have @meain 's attention, for my personal opinion, it is cute! XD

PS: I was thinking to work on a configuration file for the icons after the theme one, so do not let the glyphs stop your progress

zwpaper avatar Mar 01 '21 09:03 zwpaper

Hey @hpwxf, thanks a lot for taking looking into this. I have not been able to fully think through it but here are few things that I wanted to mention.

I don't think separating the output of ls to two columns would be a good idea, this should be just a "block" similar to size or date. As for the representation, we could use how git-status represents it with two items (working tree and index). This would make the data familiar to read. We kinda loose the details on partially staged files for example if we stick to just one char/icon.

About the icons, I think icons should be optional as this feature should also be usable by people who do not have the proper fonts setup. We could have this configurable and make it use icons, but I am not also worried if having two icons close together would look good.

Related to the implementation, when listing a top level folder lsd should be able to notify even if there is some change in some file that is under a specific folder.

meain avatar Mar 01 '21 14:03 meain

To define a status for a directory, I suggest to use a kind of max on the status of the files inside. I use this order:

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum GitStatus {
    /// No changes
    Unmodified,
    /// Entry is ignored item in workdir
    Ignored,
    /// Entry does not exist in old version
    New,
    /// Type of entry changed between old and new
    Typechange,
    /// Entry does not exist in new version
    Deleted,
    /// Entry was renamed between old and new
    Renamed,
    /// Entry content changed between old and new
    Modified,
    /// Entry in the index is conflicted
    Conflicted,
}

it means that a conflict will always be shown whatever the other modifications; if no conflict, the second most important status is Modified...

Below, a output example (fancy icons will come later). For this example, in the previous commit, each sub/directory contained two files file1 and file2. Snapshot

Is it what you expect ?

hpwxf avatar Mar 02 '21 19:03 hpwxf

@hpwxf That sounds good.

meain avatar Mar 04 '21 04:03 meain

Completely unsolicited, but Git Integration in a manner similar to colorls in the grid view would be really nice for at a glance information.

typkrft avatar Aug 09 '21 02:08 typkrft

Completely unsolicited, but Git Integration in a manner similar to colorls in the grid view would be really nice for at a glance information.

After this PR is merged, this seems to be a doable improvement.

hpwxf avatar Aug 11 '21 13:08 hpwxf

I love lsd, I prefer it over exa but I miss the Git Integration, why has this feature not been considered yet?

sherifabdlnaby avatar Sep 11 '22 11:09 sherifabdlnaby

For sure, PR #495 should be updated.

Is there only this remark https://github.com/Peltoche/lsd/pull/495#issuecomment-965972260 to solve?

hpwxf avatar Sep 11 '22 11:09 hpwxf

Any news on this?

LucaAngioloni avatar Feb 11 '23 15:02 LucaAngioloni

Thank you to ask. It seems useful to update my PR. I will try to do on next Wednesday (Feb 15th). I hope the code hasn't changed too much since my first version.

hpwxf avatar Feb 12 '23 13:02 hpwxf

@hpwxf Thanks for the interest. I unfortunately don't have much time these days to look into major features in lsd. I'm fine if @zwpaper can take up review of this one. Just wanted to give you a heads up so as to not waste your time.

meain avatar Feb 15 '23 19:02 meain

Hi @meain @hpwxf, I also do not have much time for this significant feature, but luckily we have already done most of the work previously, let's keep going and I will try my best to make it happen.

zwpaper avatar Feb 16 '23 03:02 zwpaper

I'm rebasing my previous work on master branch. --git option seems to work again.

I have many #[cfg(feature = "git")] to support git as an optional feature.

What do you prefer? default feature or optional feature ?

hpwxf avatar Feb 19 '23 11:02 hpwxf

I'm thinking it could be enabled on systems that support it. Don't think there is any point in keeping it optional.

meain avatar Feb 19 '23 16:02 meain

Ok; the only unsupported arches are:

  • ~arm-unknown-linux-gnueabihf~ (now supported by removing non necessary features from git2-rs)
  • i686-pc-windows-gnu

Before the PR, I've just something to check about

  • [x] display of git symbols even if --icons=never
  • [x] Simplify the deactivation of the git feature (when not supported; cf list above)
  • [x] proper icons for fancy theme; any suggestion is welcome (cf https://github.com/Peltoche/lsd/issues/7#issuecomment-787442823)
  • [ ] issues related in https://github.com/Peltoche/lsd/pull/495#issuecomment-965972260

and it should be done (hopefully in a few days).

hpwxf avatar Feb 19 '23 22:02 hpwxf

It's almost done. To fix issues shown in my previous PR, I need to know how to manage the case where we have:

  1. a sub-directory 'subdir' that uses git (but not the current one): show or not a git status for subdir?
  2. a sub-directory that uses git and the current one also uses git + option --tree: show git status related to current dir or a status as if we use git status inside each subdirectory?

In other words, do you consider that the output of exa -l --git [--tree] is what we want?

Here my demo to plau this demo.zip

And some comparisons on it between exa and my proposal.

Case 1.: exa-1 lsd-1

Case 2.: exa-2

lsd-2

hpwxf avatar Feb 26 '23 20:02 hpwxf

hi @hpwxf, in my opinion, I would vote +1 for the exa output, as git status also output like this.

zwpaper avatar Feb 28 '23 06:02 zwpaper

I'm waiting two days for any other suggestions, and then I push my PR.

hpwxf avatar Mar 03 '23 11:03 hpwxf

/close

zwpaper avatar May 25 '23 09:05 zwpaper

/close

zwpaper avatar May 25 '23 09:05 zwpaper