All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Thomas Rast <trast@student.ethz.ch>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Shawn Pearce <spearce@spearce.org>,
	Ramkumar Ramachandra <artagnon@gmail.com>,
	Jens Lehmann <Jens.Lehmann@web.de>,
	Christian Couder <chriscool@tuxfamily.org>,
	git <git@vger.kernel.org>
Subject: Re: Summer of Code project ideas due this Friday
Date: Thu, 10 Mar 2011 12:54:29 -0800	[thread overview]
Message-ID: <7vtyfa3ddm.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20110310192851.GB19257@sigill.intra.peff.net> (Jeff King's message of "Thu, 10 Mar 2011 14:28:51 -0500")

Jeff King <peff@peff.net> writes:

>> I think the end-result would be a nice feature. I suspect that it would
>> not involve conversion from --cc, but more like using the difference
>> between the HEAD and the working tree, generated as if there is no
>> multi-stage index.
>
> The trouble is that I would like to see the combined diff, then say "OK"
> and have it apply the result to the index. But because we work on a
> per-hunk basis, you need to match the combined diff hunks to the regular
> diff hunks, taking into account that hunks could be split.  Which maybe
> is straightforward, but I haven't convinced myself yet that there are no
> corner cases where they don't line up.

Forgetting for now the implementation, I _think_ what you would want is
for "git add -p" to notice that you are resolving conflicts, and do not
bother you about cleanly merged parts (I take it is a given that you would
always want to add them to the index without even inspecting when running
"add -p"), and make the per-hunk selection loop ask only about the parts
that originally had conflicts.

But it is rather hard to arrange.  Neither "--cc" nor "-c" during the
merge is about showing conflicts but is about showing the result with
respect to the two originals.  If you resolved conflicts in your editor
already, there are no lines with "<<</>>>" markers that are different from
either original to cause the "conflicted parts" to appear in their output.
If your conflict resolution ended up in taking what one side did, "--cc"
will hide it as a non-event.  So at least you would be using "-c" to
implement this.

Also, you have to remember that "add -p" is about adding the state you
deem Ok incrementally to the index, that once you add a path to the index
the higher stages for the path will collapse to stage #0, and that "-c"
and "--cc" make their comparison based on what you have in higher stages.

I would imagine that a workable implementation might look like this:

 0. The solution introduces a new index extension, "PRSF" (partial
    resolution so far)".  This is a mapping from pathname to a blob object
    name.

 1. "git add -p" notices that you are in the middle of conflict
    resolution, by noticing that you have higher stages to the path.

 2. Look up the path from the PRSF extension.  If there is no entry for
    the path, recreate the content-level 3-way merge using the content of
    three stages (i.e. the state immediately after the mergy operation
    that caused the conflicts before you touched the corresponding file in
    your working tree), and register this image (with the full glory of
    "<<</>>>" conflict markers) to the extension.  If there already is an
    entry in the extension for the path, skip this step.

 3. The patch the user will see in the interactive hunk selection is the
    difference between the working tree and the PRSF image, not your
    regular index (nor the HEAD version). This allows you to see how you
    resolved the conflict incrementally so far.

 4. Choosing a hunk to "apply" would not affect the index entry for the
    path, as it would collapse its higher stages.  It instead updates the
    blob registered in the PRSF extension using the hunk you are applying.

If you are running "git add -p" incrementally (i.e. edit a little, review
with diff, then "add -p" the part you are sure about, and repeat the whole
thing), the next invocation of "git add -p" would notice that you still
have unresolved conflicts in PRSF.  It will skip the step 2 above and the
step 3 will let you review the remaining difference between the PRSF image
(which you updated in step 4 during the last round) and what you have in
the working tree.  The step 4 will update the PRSF image for the next
invocation of "git add -p".  And you continue until you are done.

At the end (we would probably need a good way to detect the user might
want to declare "end" automatically for a good user experience), use the
PRSF image to collapse the higher stages for the path down to stage 0.

  reply	other threads:[~2011-03-10 20:55 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-03 18:08 Google Summer of Code 2011 Shawn Pearce
2011-03-03 18:59 ` Jeff King
2011-03-03 19:04   ` Shawn Pearce
2011-03-03 20:33     ` Jeff King
2011-03-03 21:25       ` Jakub Narebski
2011-03-09 16:38         ` Jeff King
2011-03-09 16:39       ` Jeff King
2011-03-09 16:47         ` Shawn Pearce
2011-03-09 17:49       ` Jeff King
2011-03-09 17:52         ` Shawn Pearce
2011-03-09 21:58           ` Summer of Code project ideas due this Friday Jeff King
2011-03-10  0:10             ` Jonathan Nieder
2011-03-10 16:30               ` Jeff King
2011-03-10 17:31                 ` Shawn Pearce
2011-03-10 21:43                   ` Alexander Miseler
2011-03-10 17:15               ` Thomas Rast
2011-03-10 18:17                 ` Santi Béjar
2011-03-10 18:46                 ` Jeff King
2011-03-10 19:21                   ` Junio C Hamano
2011-03-10 19:28                     ` Jeff King
2011-03-10 20:54                       ` Junio C Hamano [this message]
2011-03-10 21:42                         ` Jeff King
2011-03-10 22:58                           ` Junio C Hamano
2011-03-10 23:09                             ` Jeff King
2011-03-11 13:31                   ` Thomas Rast
2011-03-10 17:39               ` Jakub Narebski
2011-03-11 13:28                 ` Thomas Rast
2011-03-12  0:20                 ` History surgery with fast-import (Re: Summer of Code project ideas due this Friday) Jonathan Nieder
2011-03-13 17:08               ` Summer of Code project ideas due this Friday Ramkumar Ramachandra
2011-03-10  0:19             ` Nguyen Thai Ngoc Duy
2011-03-10 16:31               ` Jeff King
2011-03-10 21:40             ` Alexander Miseler
2011-03-10 22:18               ` Jeff King
2011-03-11 14:17                 ` Alexander Miseler
2011-03-12 19:47                   ` Alexander Miseler
2011-03-11 12:18             ` Alexander Miseler
2011-03-11 12:52               ` Ilari Liusvaara
2011-03-11 13:48                 ` Nguyen Thai Ngoc Duy
2011-03-11 14:10                   ` Alexander Miseler
2011-03-11 14:27                     ` Nguyen Thai Ngoc Duy
2011-03-11 22:42                       ` Sam Vilain
2011-03-12 21:41                       ` Alexander Miseler
2011-03-11 12:43             ` Ævar Arnfjörð Bjarmason
2011-03-11 14:24               ` code.sculptor
2011-03-17 23:40             ` Summer of Code project ideas Jakub Narebski
2011-03-22 20:31               ` Heiko Voigt
2011-03-22 22:55               ` J.H.
2011-03-25  1:11               ` Pat Thoyts
2011-03-25 13:02                 ` Jakub Narebski
2011-03-03 21:04 ` Google Summer of Code 2011 Ramkumar Ramachandra
2011-03-03 22:08   ` Jonathan Nieder
2011-03-07 12:15   ` Sverre Rabbelier
2011-03-08 12:33     ` Ramkumar Ramachandra
2011-03-08 12:49       ` Sverre Rabbelier
2011-03-03 22:38 ` Jens Lehmann
2011-03-05  4:05 ` Christian Couder
2011-03-06 19:24 ` Sam Vilain
2011-03-07 19:40 ` Heiko Voigt
2011-03-07 20:50   ` Fredrik Gustafsson
2011-03-09 21:52     ` Heiko Voigt
2011-03-09 23:16       ` Fredrik Gustafsson
2011-03-10 22:46         ` Heiko Voigt
2011-03-09 15:18 ` Thomas Rast

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=7vtyfa3ddm.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Jens.Lehmann@web.de \
    --cc=artagnon@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=spearce@spearce.org \
    --cc=trast@student.ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.