{"thread":{"id":"12624","subject":"Checking the merge conflicts","startedAt":"2008-03-11T00:31:01Z","lastAt":"2008-03-11T00:31:01Z","messageCount":1,"participants":["Santi Béjar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"71632","messageId":"8aa486160803101731t1a8caa8bva73dc64021290c72@mail.gmail.com","threadId":"12624","inReplyTo":null,"subject":"Checking the merge conflicts","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-03-11T00:31:01Z","receivedAt":"2008-03-11T00:31:01Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Hi *,\n\n  sometimes I want to check how a conflicting merge was performed.\n\"git diff --cc\" is not exactly what I want because it suppress a hunk\nwhen the merge is equal to one of the parents (at the file and hunk\nlevel). But I want to know which one was chosen. So I've made this\nsimple shell. Yes, it is ugly and all but does what I want.\n\n[git-checkmerge]\n#!/bin/sh\nmerge=${1:-HEAD}\nbranch1=$(git rev-parse $merge^1) || exit\nbranch2=$(git rev-parse $merge^2) || exit\ntmpdir=$(mktemp -t -d git-checkmerge.XXXXXXXXX)\nnewrepo=$tmpdir/checkmerge\ngit clone -s $PWD $newrepo\ncd $newrepo\ngit config user.name checkmerge\ngit config user.email checkmerge@checkmerge\ngit checkout $branch1\ngit merge $branch2\ngit diff -R $merge\n\nI recreates the merge with conflict marks included, and shows the diff\nbetween the \"recreated merge\" and the \"merge\".\n\nFor example with:\n\n$ git-checkmerge 83a2cbbd5873afd99c6cfa01296532ed9a19bdac\n[noisy output]\ndiff --git a/Makefile b/Makefile\nindex d2fefa1..bd0d05f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -304,12 +304,7 @@ LIB_H = \\\n        run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \\\n        tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \\\n        utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h \\\n-<<<<<<< HEAD:Makefile\n        mailmap.h remote.h parse-options.h transport.h diffcore.h\nhash.h ll-merge.h fsck.h pack-revindex.h\n-=======\n-       mailmap.h remote.h parse-options.h transport.h diffcore.h\nhash.h fsck.h \\\n-       pack-revindex.h\n->>>>>>> 34cd62eb91600109378c8121c1fecd924a9af177:Makefile\n\n DIFF_OBJS = \\\n        diff.o diff-lib.o diffcore-break.o diffcore-order.o \\\n@@ -333,11 +328,7 @@ LIB_OBJS = \\\n        color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \\\n        convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \\\n        transport.o bundle.o walker.o parse-options.o ws.o archive.o branch.o \\\n-<<<<<<< HEAD:Makefile\n        ll-merge.o alias.o fsck.o pack-revindex.o\n-=======\n-       alias.o fsck.o pack-revindex.o\n->>>>>>> 34cd62eb91600109378c8121c1fecd924a9af177:Makefile\n\n BUILTIN_OBJS = \\\n        builtin-add.o \\\n\n(sorry if it get refilled/truncated)\n\nyou can see that in both conflicting hunks the first change was chosen.\n\nIt does all what I want (although slowly, does not support different\nstrategies,...),\nbut if there is interest ...\n\nSanti\n"}]}