Giter Club home page Giter Club logo

Comments (2)

mentalisttraceur avatar mentalisttraceur commented on June 1, 2024

Oh that could be super useful!

I propose --sort git as the option flag.

Design Thoughts

Matching the order of git status output is probably the most intuitive.

git status prints file names with staged changes first, then file names with unstaged changes, and then finally untracked names (and within those groups, the sort is alphabetical/lexical).

exa has to adapt that a bit because it only has one entry per path (a file with both staged and unstanged changes only gets one entry, whereas in git status it gets listed twice) and because it might also be listing files that are in .gitignore. But I think the closer we get to an intuitive match between the two the better.

So I propose to sort by like this:

  1. paths with staged changes go before paths without staged changes,
  2. within that, paths with unstaged changes get sorted before paths without unstaged changes, and
  3. within that, new status N gets sorted before M (this last thing deviates from git status but I think it would make a big difference in certain situations, because then you reduce the frequency and unpredictability of where you need to notice N vs M distinctions in the listing... also in practice for it has been true for years that I occasionally find myself wishing that git status grouped by renamed/added/deleted/modified within staged/unstaged/untracked before the lexical sort).

Sorting staged-changes before no-staged-changes also matches a decision already made in --git output: staged status is the left character, unstaged status is the right character. So when you scan visually, it would work out really nicely - for example (modified from Exa --git documentation):

$ exa --long --git
Permissions Size User Date Modified Git Name
.rw-r--r--   155 ben  25 Nov 17:23   NM unselectable.scss
.rw-r--r--   612 ben  24 Nov 16:04   M- media.scss
.rw-r--r--   260 ben  25 Nov 17:23   -M icon.scss
.rw-r--r--    59 ben  25 Nov 17:23   -N plain-link.scss
.rw-r--r--    96 ben  21 Nov 14:20   -- hoverable.scss

Which corresponds to:

$ git status
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   media.scss
        new file:   unselectable.scss

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   icon.scss
        modified:   unselectable.scss

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        plain-link.scss

P.S. a third reason for making has-staged-changes versus does-not-have-staged-changes as the primary sort is that right before a commit, the most important/salient difference is what's staged - and any deliberate use of the staging area (staging smaller pieces for individual commits instead of basically ignoring the staged/unstaged difference and committing all outstanging changes at once), it's really helpful to have a fast-and-easy-to-visually-parse cue of staged-vs-unstaged.

from exa.

heafnerj avatar heafnerj commented on June 1, 2024

Sounds excellent to me.

from exa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.