Re: [PATCH v3] git-add--interactive: manual hunk editing mode
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:43
Johannes Schindelin [off-list ref] writes:
But like I said, Junio convinced me that it makes not much sense to split somewhere else than common lines, and you have that already with the "s" command in add -i.
That needs clarifying. What I would have convinced you is not quite
"somewhere else than common lines". It is more like "don't split between
two deleted lines that is followed by addition, or two added lines that
immediately follow deletion, without thinking".
Splitting the left into the right:
1 1
-2 -2
+two +two
3 3
-4
+four
5
so that only the first change is applicable makes sense and can easily be
explained. This is "common lines" case.
The example I gave you long time ago about split that does not make much
sense was to split this:
1
-2
-3
-4
+two, three
+four
5
anywhere between "-2 .. +four" without giving the user any other ways to
control the result.
But you _can_ give users a meaningful split by reordering lines.
1
-2
-3
+two, three
-4
+four
5
It makes sense to then split this immediately before "-4" to apply "only
the first change that is to remove two lines and rewrite it with one
line", i.e.:
1
-2
-3
+two, three
4
with the leftover part, whose lines differ if the above is applied or not,
presented as the next hunk to the user:
(if the above is unused) (if the above is used)
3 two, three
-4 -4
+four +four
5 5