threads / patch / 5113

patchIntroducing cg-xxdiff for conflict resolution

Subject: [PATCH] Introducing cg-xxdiff for conflict resolution

## tl;dr

9 messages between Aug 4, 2006 and Nov 3, 2006. Diffs are folded; open one to read it.

replies: 8people: 3as markdown or json

Martin Langhoff· Aug 4, 2006, 03:34 UTC · lore

This is a bit of a crude but really useful shortcut for conflict resolution. The name is bad, but matches git-xxdiff which has been around for like... ages

As Cogito doesn't make use of the index during merges/applies, cg-xxdiff is somewhat more brittle and cannot not help during conflict resolution when using cg-patch.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
---
 Makefile  |    3 ++-
 cg-xxdiff |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletions(-)
Show changes to 2 files +35 −1

Makefile, cg-xxdiff

diff --git a/Makefile b/Makefile
index ba9bf9a..dc21702 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,8 @@ SCRIPT=	cg-object-id cg-add cg-admin-lso
 	cg-export cg-help cg-init cg-log cg-merge cg-mkpatch cg-patch \
 	cg-fetch cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \
 	cg cg-admin-ls cg-push cg-branch-chg cg-admin-cat cg-clean \
-	cg-admin-setuprepo cg-switch cg-mv cg-admin-rewritehist cg-tag-show
+	cg-admin-setuprepo cg-switch cg-mv cg-admin-rewritehist cg-tag-show \
+	cg-xxdiff
 
 LIB_SCRIPT=cg-Xlib cg-Xmergefile cg-Xfetchprogress cg-Xfollowrenames
 
diff --git a/cg-xxdiff b/cg-xxdiff
new file mode 100755
index 0000000..7a1a863
--- /dev/null
+++ b/cg-xxdiff
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+USAGE='<path-with-conflict>'
+SUBDIRECTORY_OK=No
+. git-sh-setup
+
+FILE=$1
+
+# Sanity checks
+if test ! -n "$FILE"
+then
+	echo Need a path
+	exit 1
+fi
+
+git cat-file blob `git rev-parse HEAD`:$FILE > $FILE~ours
+if test $? -gt 0
+then 
+	echo "Error - $FILE is not tracked by git or does not have a conflict"
+	exit 1
+fi
+echo Written $FILE~ours
+
+git cat-file blob `git rev-parse FETCH_HEAD`:$FILE > $FILE~branch
+if  test $? -gt 0
+then 
+	echo "Error - $FILE is not tracked by git or does not have a conflict"
+	exit 1
+fi
+echo Written $FILE~branch
+echo Resolved file will be saved as $FILE~merged
+
+xxdiff -wbB --show-merged-pane --merged-filename $FILE~merged $FILE~ours $FILE~branch
-- 
1.4.2.rc2.ge1f7
Petr Baudis· Sep 24, 2006, 16:50 UTC · re: Martin Langhoff · lore

Re: [PATCH] Introducing cg-xxdiff for conflict resolution

Dear diary, on Fri, Aug 04, 2006 at 05:34:07AM CEST, I got a letter where Martin Langhoff <martin@catalyst.net.nz> said that...

> This is a bit of a crude but really useful shortcut for conflict resolution.
> The name is bad, but matches git-xxdiff which has been around for like... ages
Yes, the name is horrible. :-)
Show 5 quoted lines
> As Cogito doesn't make use of the index during merges/applies, cg-xxdiff
> is somewhat more brittle and cannot not help during conflict resolution when
> using cg-patch.
> 
> Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>

Hmm, I think this would be generally more useful during the actual merge phase - if merge returns error, you fire up git-magic-conflict-resolution-driver and have fun.

Which reminds me that I should make some more effort to unify cg-Xmergeonefile and git-merge-one-file...

> +. git-sh-setup
Uh-oh. :-)
> +git cat-file blob `git rev-parse FETCH_HEAD`:$FILE > $FILE~branch
Cogito does not use FETCH_HEAD.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
Martin Langhoff· Sep 24, 2006, 17:02 UTC · re: Petr Baudis · lore

Re: [PATCH] Introducing cg-xxdiff for conflict resolution

On 9/24/06, Petr Baudis <pasky@suse.cz> wrote:
> Hmm, I think this would be generally more useful during the actual merge
> phase - if merge returns error, you fire up
> git-magic-conflict-resolution-driver and have fun.

Well, in many cases the conflict markers are just ok and exactly what I want. If the two sides of the conflict are clear, the resolution is usually clear as well. OTOH, it may be a big mess where xxdiff gives more visual cues as to WTF is going on...

IOW I don't want it to be part of the merge automagically...
> > +. git-sh-setup
>
> Uh-oh. :-)

Is that bad? <blush> I am not doing anything too cogito-specific, and I just don't know what cg-Xlib will do for me...

> > +git cat-file blob `git rev-parse FETCH_HEAD`:$FILE > $FILE~branch
>
> Cogito does not use FETCH_HEAD.

eeek. you ar right. I mix and match git and cogito as you can see. Not so smart. I see cg-merge uses merging, merge-base and merging-sym -- I'll rework it using those...

cheers,
martin
Petr Baudis· Sep 24, 2006, 17:12 UTC · re: Martin Langhoff · lore

Re: [PATCH] Introducing cg-xxdiff for conflict resolution

Dear diary, on Sun, Sep 24, 2006 at 07:02:28PM CEST, I got a letter where Martin Langhoff <martin.langhoff@gmail.com> said that...

Show 11 quoted lines
> On 9/24/06, Petr Baudis <pasky@suse.cz> wrote:
> >Hmm, I think this would be generally more useful during the actual merge
> >phase - if merge returns error, you fire up
> >git-magic-conflict-resolution-driver and have fun.
> 
> Well, in many cases the conflict markers are just ok and exactly what
> I want. If the two sides of the conflict are clear, the resolution is
> usually clear as well. OTOH, it may be a big mess where xxdiff gives
> more visual cues as to WTF is going on...
> 
> IOW I don't want it to be part of the merge automagically...

In that case I think the most natural way for this tool to interface would be in part of some kind of cg-resolve swiss-army knife for resolving conflicts:

	cg-resolve --mine	for taking just the version from _my_
				side of the merge
	cg-resolve --other	dtto for the other side of the merge
	cg-resolve -g		graphically resolve
				(vimdiff/xxdiff/meld/...)
	surely more would be invented over time
Show 6 quoted lines
> >> +. git-sh-setup
> >
> >Uh-oh. :-)
> 
> Is that bad? <blush> I am not doing anything too cogito-specific, and
> I just don't know what cg-Xlib will do for me...
Well, all the Cogito scripts should have some consistent form. :-)
But I can adjust such details when applying your patch.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
Martin Langhoff· Sep 24, 2006, 17:22 UTC · re: Petr Baudis · lore

Re: [PATCH] Introducing cg-xxdiff for conflict resolution

On 9/24/06, Petr Baudis <pasky@suse.cz> wrote:
Show 10 quoted lines
> In that case I think the most natural way for this tool to interface
> would be in part of some kind of cg-resolve swiss-army knife for
> resolving conflicts:
>
>        cg-resolve --mine       for taking just the version from _my_
>                                side of the merge
>        cg-resolve --other      dtto for the other side of the merge
>        cg-resolve -g           graphically resolve
>                                (vimdiff/xxdiff/meld/...)
>        surely more would be invented over time

Sounds reasonable. But I think we have to keep in mind that you only know if the conflict is nasty after you have a go at fixing it. And I sometimes find that I try with cg-xxdiff... and I go back to the plain old conflict. That is why it doesn't clobber the file -- to protect a manual merge in process.

> Well, all the Cogito scripts should have some consistent form. :-)
heh - consistency? overrated! ;-)
> But I can adjust such details when applying your patch.

Great! -- I'm travelling and at an airport "free access" computer. It should be illegal to run airports without free wifi in this day and age.

cheers,
martin
Petr Baudis· Sep 24, 2006, 17:28 UTC · re: Martin Langhoff · lore

Re: [PATCH] Introducing cg-xxdiff for conflict resolution

Dear diary, on Sun, Sep 24, 2006 at 07:22:35PM CEST, I got a letter where Martin Langhoff <martin.langhoff@gmail.com> said that...

Show 17 quoted lines
> On 9/24/06, Petr Baudis <pasky@suse.cz> wrote:
> >In that case I think the most natural way for this tool to interface
> >would be in part of some kind of cg-resolve swiss-army knife for
> >resolving conflicts:
> >
> >       cg-resolve --mine       for taking just the version from _my_
> >                               side of the merge
> >       cg-resolve --other      dtto for the other side of the merge
> >       cg-resolve -g           graphically resolve
> >                               (vimdiff/xxdiff/meld/...)
> >       surely more would be invented over time
> 
> Sounds reasonable. But I think we have to keep in mind that you only
> know if the conflict is nasty after you have a go at fixing it. And I
> sometimes find that I try with cg-xxdiff... and I go back to the plain
> old conflict. That is why it doesn't clobber the file -- to protect a
> manual merge in process.
Oh yes, I wanted to complain about that. ;-)

Yes, sometimes it is useful to go back, but I guess most of the time probably not (not speaking from the experience though) and I hate tools which leave random copies of a file I have tracked in a VCS around and I have to collect their garbage manually.

The tool should just have a way to tell it "cancel" in case of trouble and restore the original state of the file. And of course

	cg-resolve --remerge	re-run the 3-way merge on the file
would be useful anyway.
Show 5 quoted lines
> >But I can adjust such details when applying your patch.
> 
> Great! -- I'm travelling and at an airport "free access" computer. It
> should be illegal to run airports without free wifi in this day and
> age.
Heartily agreed.

We should always suggest the locals to build yet another airport right near the old one to promote free market and competition!

And when one of them bankrupts it could make for a nice paintball arena, I guess.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
Martin Langhoff· Nov 2, 2006, 23:40 UTC · re: Petr Baudis · lore

Re: [PATCH] Introducing cg-xxdiff for conflict resolution

On 9/25/06, Petr Baudis <pasky@suse.cz> wrote:
Show 7 quoted lines
> > >But I can adjust such details when applying your patch.
> >
> > Great! -- I'm travelling and at an airport "free access" computer. It
> > should be illegal to run airports without free wifi in this day and
> > age.
>
> Heartily agreed.
Paski, did this one get dropped? Change of heart? Heart attack?
cheers,
Petr Baudis· Nov 3, 2006, 00:11 UTC · re: Martin Langhoff · lore

Re: [PATCH] Introducing cg-xxdiff for conflict resolution

Dear diary, on Fri, Nov 03, 2006 at 12:40:38AM CET, I got a letter where Martin Langhoff <martin.langhoff@gmail.com> said that...

Show 10 quoted lines
> On 9/25/06, Petr Baudis <pasky@suse.cz> wrote:
> >> >But I can adjust such details when applying your patch.
> >>
> >> Great! -- I'm travelling and at an airport "free access" computer. It
> >> should be illegal to run airports without free wifi in this day and
> >> age.
> >
> >Heartily agreed.
> 
> Paski, did this one get dropped? Change of heart? Heart attack?

Hmm, I thought we've agreed to go for the cg-resolve solution instead...?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
Martin Langhoff· Nov 3, 2006, 02:41 UTC · re: Petr Baudis · lore

Re: [PATCH] Introducing cg-xxdiff for conflict resolution

On 11/3/06, Petr Baudis <pasky@suse.cz> wrote:
> > Paski, did this one get dropped? Change of heart? Heart attack?
>
> Hmm, I thought we've agreed to go for the cg-resolve solution
> instead...?

Oops. That wasn't my reading. Misunderstood. In any case, if you go back a bit in the conversation, the usage model I find this useful is one where it makes sense to try different tools that have entirely different parameters. That is why it makes sense to call them differently.

So cg-meld [meld params] , is different from cg-xxdiff [xxdiff params] and cg-wiggle [wiggle params] makes more sense to me and can be maintained by different people (those who like meld probably dont' use xxdiff ;-)

And from a packaging perspective, cg-resolve will depend on a zillion things.
cheers,

← back to recent threads