public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: "Ulrich Windl" <Ulrich.Windl@rz•uni-regensburg.de>
Cc: <git@vger•kernel.org>
Subject: Re: Extended splitting for "git add --interactive"
Date: Wed, 26 Nov 2014 12:24:59 -0800	[thread overview]
Message-ID: <xmqqtx1lpv50.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqq3895rdr1.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Wed, 26 Nov 2014 10:57:38 -0800")

Junio C Hamano <gitster@pobox•com> writes:

> "Ulrich Windl" <Ulrich.Windl@rz•uni-regensburg.de> writes:
>
>> Another split that is not possible is a split across an empty line, like:
>>
>> +AAA
>> +     <empty line (in reality)>
>> +BBB
>
> Likewise.  An empty line is not that special.  AAA may be adding one
> block of lines "if (condition) { ... }" and BBB may be another, and
> it often happens that you would want to separate these into two
> changes, with or without an empty line in between.
>
>    +if (foo) {
>    +  do foo thing
>    +}
>    +if (bar) {
>    +  do bar thing
>    +}
>    
> Having said all that, I am not opposed to a usable idea to allow the
> user to specify where in a contiguous block of -*+* to break a hunk
> and how.

Of course, splitting at blank or at any arbitrary point that the
implementor of this new feature decides to be good is not end of the
world.  If the split at that chosen point is undesirable, the user
can join them back.  But then the feature did not help such a user
very much.  So that selection of "any arbitrary point" has to be
fairly a good heuristic, making majority of users happy, to be worth
for users to try.  If they try splitting with the heuristics and get
a good result 80% of times, 20% of time they instead may need to
join the wrong splits back, but overall it will be a win.

In an extreme case, we could have an option to split a run of zero
or more "-" lines followed by zero or more "+" lines into one line
per hunk, and let the user pick the line they want, which would
solve your original issue of turning "-A-B+C+D" into "-A+C" and
"-B+D", while allowing them to be commited with a different
splitting, e.g. "-A" and "-B+C+D".

But at that point, I suspect most people may choose to (e)dit the
patch themselves instead.  I dunno.

  reply	other threads:[~2014-11-26 20:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-26 14:55 Extended splitting for "git add --interactive" Ulrich Windl
2014-11-26 18:57 ` Junio C Hamano
2014-11-26 20:24   ` Junio C Hamano [this message]
2014-11-27  8:55   ` Antw: " Ulrich Windl
2014-11-27 10:14     ` Johan Herland
2014-11-27 15:46       ` Brandon McCaig

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=xmqqtx1lpv50.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=Ulrich.Windl@rz$(echo .)uni-regensburg.de \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox