Thread (3 messages) 3 messages, 3 authors, 2024-03-28

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

From: Eugenio Bargiacchi <hidden>
Date: 2024-03-28 17:10:16

Thank you for the suggestion, it already helps a bit.

The problem only using indentations as a visual separator, for me, is
that if the code snipped already has indentations, then the ones added
by 'git add' do not really stand up, and instead become part of a very
long uninterrupted stream of text. In addition to this, given that the
snippet is colored, the result is a very bright and flashy wall of
text that can be a bit much to sift through (were it all the same
color it would be worse though). Being able to break up the hunks
visually with some whitespace would really go a long way.

In any case, for now I'll try to pick up the most obnoxious colors for
the prompt that I can :) Hopefully in the future this will be an
available option for difficult people like me.

On Thu, 28 Mar 2024 at 17:50, Junio C Hamano [off-list ref] wrote:
Eugenio Bargiacchi [off-list ref] writes:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help