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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thomas Rast <trast@xxxxxxxxxxxxxxx> writes:

> Junio C Hamano wrote:
> ...
>> > +# To remove '-' lines, make them ' ' lines (context).
>> > +# To remove '+' lines, delete them.
>> > +# Lines starting with # will be removed.
>> 
>> Don't you want to say "Do not touch lines that begin with ' '"?
>
> Why?  You can make them '-' instead if you really want to :-)

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 allow changing ' ' to '-' or insert '+' at random places,
however, you are letting the user commit lines that is neither from HEAD
nor from the working tree.

If the goal of "e" action in "add -i" is to support that operation (I am
not saying that it is a bad thing to support), you have to deal with an
issue that your patch so far did not have to deal with, and it would
require a much larger change to the way how "add -i" is structured.

When you give the user a hunk like this to edit:

  @@ -4,9 +4,6 @@ GIT v1.6.0 Release Notes
   User visible changes
   --------------------

  -[[Note that none of these are not merged to 'master' as of this writing
  -but they will be before 1.6.0 happens]]
  -
   With the default Makefile settings, most of the programs are now
   installed outside your $PATH, except for "git", "gitk", "git-gui" and
   some server side programs that need to be accessible for technical

the user may want to change the line before the line that has "User
visible changes", or the lines toward the end of the hunk. The user may
want to edit the line that ends with "for technical" for rewording the
sentence, but the rest of the sentence is outside the context, and these
lines somehow needs to be summoned to the editing session for completing
the updated sentence.  In order to support that, you need to be able to
extend the context on demand in either direction, beyond the original "git
diff" output you captured in $hunk[$i]{TEXT} (sorry, I misspelled this as
$mode->{TEXT} in the previous message).

Once you start to do that, 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.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux