All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] git-add--interactive: Preserve diff heading when splitting hunks
Date: Mon, 12 May 2014 14:07:15 -0700	[thread overview]
Message-ID: <xmqqvbtapuyk.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20140512183955.GB31164@sigill.intra.peff.net> (Jeff King's message of "Mon, 12 May 2014 14:39:55 -0400")

Jeff King <peff@peff.net> writes:

> One, there is a slightly funny artifact in that the hunk header comes
> from the top of the context line, and that top is a different position
> for each of the split hunks. So in a file like:
>
>   header_A
>       content
>   header_B
>       one
>       two
>       three
>       four
>
> you might have a diff like:
>
>   @@ ... @@ header_A
>    header_B
>        one
>        two
>   +    new line 1
>        three
>   +    new line 2
>        four
>
> The hunk header for "new line 1" is "A", because "B" itself is part of
> the context. But the hunk header for "new line 2", if it were an
> independent hunk, would be "B". We print "A" because we copy it from the
> original hunk.
>
> It probably won't matter much in practice (and I can even see an
> argument that "A" is the "right" answer).

I tend to agree with both points.

> And figuring out "B" here
> would be prohibitively difficult, I would think, as it would require
> applying the funcname rules internal to git-diff to a hunk that git-diff
> itself never actually sees.

You can actually apply a split hunk being proposed to a temporary
file and then ask "git diff" about it, so I do not think difficult
is too much of an issue, but I doubt we would want to see header_B,
exactly because when the user says "Split this hunk", s/he is very
well aware that the second one is artificial and was split from the
original hunk whose header said header_A.

> Since the output from your patch is strictly better than what we saw
> before, I think there is no reason we cannot leave such an improvement
> to later (or never).

Yes.

  parent reply	other threads:[~2014-05-12 21:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-11 16:09 [PATCH] git-add--interactive: Preserve diff heading when splitting hunks Ævar Arnfjörð Bjarmason
2014-05-11 17:52 ` Junio C Hamano
2014-05-12 18:39 ` Jeff King
2014-05-12 19:42   ` Ævar Arnfjörð Bjarmason
2014-05-12 20:09     ` Jeff King
2014-05-12 21:07   ` Junio C Hamano [this message]
2014-05-12 21:12     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqvbtapuyk.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.