Checking the merge conflicts

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

 



Hi *,

  sometimes I want to check how a conflicting merge was performed.
"git diff --cc" is not exactly what I want because it suppress a hunk
when the merge is equal to one of the parents (at the file and hunk
level). But I want to know which one was chosen. So I've made this
simple shell. Yes, it is ugly and all but does what I want.

[git-checkmerge]
#!/bin/sh
merge=${1:-HEAD}
branch1=$(git rev-parse $merge^1) || exit
branch2=$(git rev-parse $merge^2) || exit
tmpdir=$(mktemp -t -d git-checkmerge.XXXXXXXXX)
newrepo=$tmpdir/checkmerge
git clone -s $PWD $newrepo
cd $newrepo
git config user.name checkmerge
git config user.email checkmerge@checkmerge
git checkout $branch1
git merge $branch2
git diff -R $merge

I recreates the merge with conflict marks included, and shows the diff
between the "recreated merge" and the "merge".

For example with:

$ git-checkmerge 83a2cbbd5873afd99c6cfa01296532ed9a19bdac
[noisy output]
diff --git a/Makefile b/Makefile
index d2fefa1..bd0d05f 100644
--- a/Makefile
+++ b/Makefile
@@ -304,12 +304,7 @@ LIB_H = \
        run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
        tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
        utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h \
-<<<<<<< HEAD:Makefile
        mailmap.h remote.h parse-options.h transport.h diffcore.h
hash.h ll-merge.h fsck.h pack-revindex.h
-=======
-       mailmap.h remote.h parse-options.h transport.h diffcore.h
hash.h fsck.h \
-       pack-revindex.h
->>>>>>> 34cd62eb91600109378c8121c1fecd924a9af177:Makefile

 DIFF_OBJS = \
        diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@ -333,11 +328,7 @@ LIB_OBJS = \
        color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
        convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \
        transport.o bundle.o walker.o parse-options.o ws.o archive.o branch.o \
-<<<<<<< HEAD:Makefile
        ll-merge.o alias.o fsck.o pack-revindex.o
-=======
-       alias.o fsck.o pack-revindex.o
->>>>>>> 34cd62eb91600109378c8121c1fecd924a9af177:Makefile

 BUILTIN_OBJS = \
        builtin-add.o \

(sorry if it get refilled/truncated)

you can see that in both conflicting hunks the first change was chosen.

It does all what I want (although slowly, does not support different
strategies,...),
but if there is interest ...

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