Skip to contentSkip to conversation

Introducing cg-xxdiff for conflict resolution

PATCH In review Martin Langhoff 3 participants 9 messages Jun 15, 2016 – Aug 11, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Introducing cg-xxdiff for conflict resolution

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.

---
 Makefile  |    3 ++-
 cg-xxdiff |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletions(-)
Makefile +2 -1
index ba9bf9a..dc21702 100644
@@ -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
 
cg-xxdiff new file +33 -0
new file mode 100755
index 0000000..7a1a863
@@ -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
Signature · 1 line
1.4.2.rc2.ge1f7
#1 lore raw

Dear diary, on Fri, Aug 04, 2006 at 05:34:07AM CEST, I got a letter where Martin Langhoff <[email protected]> said that...

Quoted 2 lines

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. :-)

Quoted 5 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.

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...

Quoted 1 line

+. git-sh-setup

Uh-oh. :-)

Quoted 1 line

+git cat-file blob git rev-parse FETCH_HEAD:$FILE > $FILE~branch

Cogito does not use FETCH_HEAD.

Signature · 5 lines
				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*',/((..)*)$/)
#2 lore raw
Quoted 3 lines · Petr Baudis

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...

Quoted 3 lines
Quoted 1 line

+. 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...

Quoted 3 lines
Quoted 1 line

+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

#3 lore raw

Dear diary, on Sun, Sep 24, 2006 at 07:02:28PM CEST, I got a letter where Martin Langhoff <[email protected]> said that...

Quoted 11 lines · Petr Baudis
Quoted 3 lines

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

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+. 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.

Signature · 5 lines
				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*',/((..)*)$/)
#4 lore raw
Quoted 10 lines · Petr Baudis

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.

Quoted 1 line

Well, all the Cogito scripts should have some consistent form. :-)

heh - consistency? overrated! ;-)

Quoted 1 line

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

#5 lore raw

Dear diary, on Sun, Sep 24, 2006 at 07:22:35PM CEST, I got a letter where Martin Langhoff <[email protected]> said that...

Quoted 12 lines · Petr Baudis
Quoted 10 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

Quoted 5 lines

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.

Quoted 5 lines
Quoted 1 line

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.

Signature · 5 lines
				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*',/((..)*)$/)
#6 lore raw
Quoted 7 lines · Petr Baudis
Quoted 5 lines
Quoted 1 line

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,

#8 lore raw
In reply to Petr Baudis
Quoted 4 lines · Petr Baudis
Quoted 1 line

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,

#7 lore raw
In reply to Martin Langhoff

Dear diary, on Fri, Nov 03, 2006 at 12:40:38AM CET, I got a letter where Martin Langhoff <[email protected]> said that...

Quoted 10 lines · Petr Baudis
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

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...?

Signature · 4 lines
				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