Re: [PATCH] git-add--interactive: manual hunk editing mode

From: Thomas Rast <hidden>
Date: 2016-06-15 22:44:52

[Wrong button at first, sorry for the double mail Junio]

Junio C Hamano wrote:
If you change '-' to ' ', or remove '+', then you are temporarily
reverting the change you have made since HEAD to your working tree copy.
If you do not change anything, you are taking something that was in your
working tree copy.  Both are simpler and easier to explain operations.
[...]
Once you start to [support truly free editing of the hunk],
you would need to worry about the case where
the hunk extended to include later lines overlaps with the hunk after the
one we are currently looking at, and run coalesce_overlapping_hunks to
concatenate them into a larger single hunk.  But to be able to do that,
you would need to keep track of the number of lines in a hunk yourself
anyway, which would mean that you cannot rely on --recount anymore.  The
extension recently made to "git apply" becomes redundant and unused code.

In short, declaring that you are supporting the use to change ' ' to '-'
means you are opening a whole can of worms, and I asked the question
because I did not know if you are really prepared to deal with it.
This issue is why I feed the entire patch (not just the edited hunk)
to git-apply --check.  That's really the only promise this feature
makes: if you hand it a patch that does not apply, it will refuse.  If
you do hand it a hunk where you manually inserted some extra context,
then added some extra changes that weren't in the original hunk, well,
tough.  (You asked for a gun _and_ loaded it _and_ pointed it at your
foot!)

That being said, we could of course add a notice of the form

  # Do not edit in any other ways unless you know what you are doing.

if that constitutes appropriate "trigger safety".

- Thomas

-- 
Thomas Rast
trast@student.ethz.ch



Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help