git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Better visual separation of hunks in `git add -p`

From
DSDragan Simic <dsimic@manjaro.org>
Date
Mar 28, 2024, 18:14 UTC
Message-ID
<a9cffbe4aadd319760635ca6d5b4f465@manjaro.org>
In-Reply-To
<xmqqo7ayuwpi.fsf@gitster.g>
On 2024-03-28 17:50, Junio C Hamano wrote:
Show 49 quoted lines
> Eugenio Bargiacchi <svalorzen@gmail.com> writes:
> 
>> I'm looking for a way to print some sort of separator between hunks
>> when running `git add -p`, as I have a bit of trouble detecting when
>> the previous hunk begins and the current one starts. Being able to
>> print an empty line or a couple lines filled with "=======" would
>> really help me out.
> 
> Hmph, my hope when I designed that particular UI was that the
> command prompt for the previous interaction followed by the hunk
> header of the current hunk would give us clear enough separation.
> 
> For example, after answering "n" to the prompt for the previous
> hunk, we'd see
> 
>     ...
>     +   (merge bff85a338c bl/doc-key-val-sep-fix later to maint).
>     +
>       * Other code cleanup, docfix, build fix, etc.
>         (merge f0e578c69c rs/use-xstrncmpz later to maint).
>         (merge 83e6eb7d7a ba/credential-test-clean-fix later to maint).
>     (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? n
>     @@ -233,3 +245,6 @@ Fixes since v2.44
>         (merge 781fb7b4c2 as/option-names-in-messages later to maint).
>         (merge 51d41dc243 jk/doc-remote-helpers-markup-fix later to 
> maint).
>         (merge e1aaf309db pb/ci-win-artifact-names-fix later to maint).
>     +   (merge ad538c61da jc/index-pack-fsck-levels later to maint).
>     +   (merge 67471bc704 ja/doc-formatting-fix later to maint).
>     ...
>     (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]?
> 
> The '@' (the first character of the hunk header line for the current
> hunk) and "(1/2" are surrounded by lines that begin with a space,
> and the hope was that it was sufficient "separator" already.
> 
> These days (long after I stopped mucking with the interactive add
> code actively), the prompt line is painted in prompt_color (you can
> tweak it with the color.interactive.prompt configuration variable,
> it defaults to BOLD BLUE) while the first part of the hunk header
> line is painted in the fraginfo color (default CYAN), which should
> give you even more visual distinction.
> 
> Perhaps
> 
>     [color "interactive"]
> 	prompt = bold red reverse
> 
> would be sufficient?  I dunno.

Here's a possible solution, or better said a new configuration option, which I've been thinking about for a while... When running "add -p", displayed chunks can sometimes become confusing or a bit hard on the eyes, but simply clearing the screen _before_ displaying any new step (i.e. a new chunk, interactive help, etc.) could make it much easier on the eyes. It would be a new option, of course.

Thoughts?
Previous: Eugenio BargiacchiNext: Junio C Hamano
Message 4 of 14 in “Better visual separation of hunks in `git add -p`”
  1. Eugenio BargiacchiMar 28, 2024
  2. Junio C HamanoMar 28, 2024
  3. Eugenio BargiacchiMar 28, 2024
  4. Dragan SimicMar 28, 2024
  5. Junio C HamanoMar 28, 2024
  6. Dragan SimicMar 28, 2024
  7. Eugenio BargiacchiMar 28, 2024
  8. Dragan SimicMar 28, 2024
  9. Eugenio BargiacchiMar 28, 2024
  10. Dragan SimicMar 28, 2024
  11. Junio C HamanoMar 28, 2024
  12. Dragan SimicMar 28, 2024
  13. Eugenio BargiacchiMar 28, 2024
  14. Dragan SimicMar 28, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.