Re: [PATCH v3] git-add--interactive: manual hunk editing mode
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 9, 2008, 19:59 UTC
- Message-ID
- <7vlk1egz19.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <alpine.DEB.1.00.0806091709350.1783@racer>
Johannes Schindelin <Johannes.Schindelin@gmx.de> 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
5so 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
5anywhere 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
5It 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
4with 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