git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] Introduce -t, --table for status/add commands
@ 2023-10-20 18:39 Jacob Stopak
  2023-10-20 18:39 ` [RFC PATCH 1/5] status: introduce -t, --table flag Jacob Stopak
                   ` (6 more replies)
  0 siblings, 7 replies; 62+ messages in thread
From: Jacob Stopak @ 2023-10-20 18:39 UTC (permalink / raw)
  To: git; +Cc: Jacob Stopak

This is a proposal / proof-of-concept for a new table-based output
format for the git status command, and for dry runs (-n) of the git add
command. This could be extended to create visual dry runs for other
other commands like rm, mv, restore, stash, commit, and clean.

For some context, earlier this year I released a tool called Git-Sim
(https://github.com/initialcommit-com/git-sim) which allows users to do
visual dry runs of many Git commands, which are rendered as high quality
output image files. Simulating commands like status, add, rm, mv, restore,
stash, and commit creates a table with 3 columns to represent the way file
changes "move around" as a result of the command being simulated.

I've gotten positive feedback from users about this visual approach to
simulating git commands, which is more intuitive than pure terminal text
for both newer users to understand how git works and for visual people.

As a result, I was thinking of ways to integrate these types of visual
formats directly into Git. A table-based output format with colored
highlighting for the commands mentioned above is low hanging fruit.

Teach 'git status' the new -t, --table flag, which displays the status
output in a 3-column table format, preserving terminology and color
coding from the default git status "long output" format (note that the
column headers are shortened here for the small width of this email, and
also I just realized that the tables below might not look right on the
mailing list due to the differing character width, but it looks correct
in the terminal so please test there it's more fun anyway :D):

$ git status -t
-------------------------------------------------------------------------
|    Untracked files    | Changes n...or commit | Changes t...committed |
-------------------------------------------------------------------------
|         poiu          |                       |                       |
|     status-table/     |                       |                       |
|                       |                       |         asdf          |
|                       |        table.c        |                       |
|                       |      wt-status.c      |                       |
-------------------------------------------------------------------------

Teach 'git add' the new -t, --table flag to be used ONLY in combination
with the '-n' flag for dry runs. Instead of simply printing out the
added filenames, the full status table format is displayed, along with
arrows that visually show how the added files are being moved around:

$ git add -nt poiu wt-status.c
-------------------------------------------------------------------------
|    Untracked files    | Changes n...or commit | Changes t...committed |
-------------------------------------------------------------------------
|         poiu -----------------------------------------> poiu          |
|     status-table/     |                       |                       |
|                       |                       |         asdf          |
|                       |        table.c        |                       |
|                       |      wt-status.c ----------> wt-status.c      |
-------------------------------------------------------------------------

Other notes:

* The width of the table and columns are dynamically set based on the
  width of the terminal.

* Long paths are shortened to include the maximum number of characters
  from both ends of the path that will fit, with a '...' in the middle.

* Color coding matches the default output of 'git status', with
  untracked files and working dir mods in red, and staged changes in
  green. If needed, arrows are drawn in cyan.

As stated above, the dry run version of the table format can be applied
to various other commands like rm, mv, restore, stash, commit, and clean
which all move file changes around in a way that can be represented in
the table format. New columns may need to be added or arrows reversed
to show changes moving in various directions. Note that some of these
commands don't appear to have a dry run (-n) option yet, so it could be
added for consistency (if not already in use) and for use with the new
table format.

Since this is an RFC patch series, I probably did some illegal and dumb
things in my code changes just to get it into a demo-able state. I am a
bit wary of having made changes to files like "read-cache.c" and
"read-cache-ll.h" to pass in the wt_status info, and there are probably
betters ways to do some other things too.

Feedback on both the new format itself and the implementation is very
much appreciated!

Jacob Stopak (5):
  status: introduce -t, --table flag
  status: handle long paths with -t, --table flag
  status: add advice arg for -t, --table flag
  add: add -t, --table flag for visual dry runs
  add: set unique color for -t, --table arrows

 Makefile         |   1 +
 builtin/add.c    |  46 +++++++--
 builtin/commit.c |   4 +-
 read-cache-ll.h  |   9 +-
 read-cache.c     |  32 ++++++-
 table.c          | 245 +++++++++++++++++++++++++++++++++++++++++++++++
 table.h          |   6 ++
 wt-status.c      |  74 +++++++++-----
 wt-status.h      |   3 +
 9 files changed, 378 insertions(+), 42 deletions(-)
 create mode 100644 table.c
 create mode 100644 table.h

-- 
2.42.0.402.gbe8243af7b.dirty


^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2024-01-06  7:06 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20 18:39 [RFC PATCH 0/5] Introduce -t, --table for status/add commands Jacob Stopak
2023-10-20 18:39 ` [RFC PATCH 1/5] status: introduce -t, --table flag Jacob Stopak
2023-10-20 18:39 ` [RFC PATCH 2/5] status: handle long paths with " Jacob Stopak
2023-10-20 18:39 ` [RFC PATCH 3/5] status: add advice arg for " Jacob Stopak
2023-10-20 18:39 ` [RFC PATCH 4/5] add: add -t, --table flag for visual dry runs Jacob Stopak
2023-10-20 18:39 ` [RFC PATCH 5/5] add: set unique color for -t, --table arrows Jacob Stopak
2023-10-20 18:48 ` [RFC PATCH 0/5] Introduce -t, --table for status/add commands Dragan Simic
2023-10-20 21:48   ` Jacob Stopak
2023-10-20 23:02     ` Dragan Simic
2023-10-20 23:28       ` Junio C Hamano
2023-10-22  6:04         ` Jacob Stopak
2023-10-22  6:52           ` Dragan Simic
2023-10-22  5:52       ` Jacob Stopak
2023-10-22  6:38         ` Dragan Simic
2023-10-22 10:30           ` Oswald Buddenhagen
2023-10-22 12:55             ` Dragan Simic
2023-10-23 10:52               ` Oswald Buddenhagen
2023-10-23 14:34                 ` Dragan Simic
2023-10-23 17:30                   ` Jacob Stopak
2023-10-23 17:59                     ` Dragan Simic
2023-10-23 18:16                     ` Oswald Buddenhagen
2023-10-23 19:29                       ` Jacob Stopak
2023-10-23 20:19                         ` Oswald Buddenhagen
2023-10-23 20:51                           ` Dragan Simic
2023-10-23 21:14                             ` Oswald Buddenhagen
2023-10-23 21:19                               ` Dragan Simic
2023-10-23 23:17                           ` Jacob Stopak
2023-10-24  1:10                             ` Dragan Simic
2023-10-24  2:03                               ` Junio C Hamano
2023-10-24  2:21                                 ` Dragan Simic
2024-01-05 19:14                                   ` Dragan Simic
2024-01-06  4:44                                     ` Jacob Stopak
2024-01-06  7:06                                       ` Dragan Simic
2023-10-23 20:29                         ` Dragan Simic
2023-10-23 19:01                     ` Junio C Hamano
2023-10-23 19:04                       ` Dragan Simic
2023-10-23 20:47                         ` Oswald Buddenhagen
2023-10-23 20:59                           ` Dragan Simic
2023-10-23 21:23                             ` Jacob Stopak
2023-10-23 21:26                               ` Dragan Simic
2023-10-23 21:12                       ` Jacob Stopak
2023-10-22 15:50             ` Jacob Stopak
2023-10-26 22:46 ` [RFC PATCH v2 0/6] Noobify format for status, add, restore Jacob Stopak
2023-10-26 22:46   ` [RFC PATCH v2 1/6] status: add noob format from status.noob config Jacob Stopak
2023-10-30  1:32     ` Junio C Hamano
2023-10-30  1:38       ` Dragan Simic
2023-10-30  6:06       ` Jacob Stopak
2023-10-26 22:46   ` [RFC PATCH v2 2/6] status: handle long paths in noob format Jacob Stopak
2023-10-26 22:46   ` [RFC PATCH v2 3/6] add: implement noob mode Jacob Stopak
2023-10-26 22:46   ` [RFC PATCH v2 4/6] add: set unique color for noob mode arrows Jacob Stopak
2023-10-26 22:46   ` [RFC PATCH v2 5/6] restore: implement noob mode Jacob Stopak
2023-10-26 22:46   ` [RFC PATCH v2 6/6] status: add advice status hints as table footer Jacob Stopak
2023-10-27 13:32   ` [RFC PATCH v2 0/6] Noobify format for status, add, restore Dragan Simic
2023-10-27 17:13     ` Jacob Stopak
2023-10-28  0:06       ` Dragan Simic
2023-10-28  2:52         ` Jacob Stopak
2023-10-28  5:55           ` Dragan Simic
2023-10-28 15:21             ` Jacob Stopak
2023-10-28 16:20               ` Dragan Simic
2023-10-28 17:35                 ` Jacob Stopak
2023-10-28 17:41                   ` Dragan Simic
2023-10-28 18:05                     ` Jacob Stopak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).