The script allows a person to review and apply a 3 way merge of a given file. I find it useful for my work especially with the merge process we chose.
We have a process where we bring lots of different types of code (java, javascript, sql) together in a merge. A lot of parallel development happens in different branches, so when those branches merge there is inevitably a merge conflict. The merge engineer is usually only familiar with one or two of the source code types being merged. We wanted a process by which we could assign out the task to merge different file types to different engineers. We did not really find a good way to do this. Here is the process we ended. 1) Merge engineer merges two branches 2) Merge results in conflicts 3) Merge engineer does a best effort attempt at resolving merges. 4) Any remaining ugly merges are committed with their merge annotations 5) Build is now broken 6) Merge engineer emails responsible engineers informing them of the conflicts and instructing them to fix 7) Each Engineer merges their individual files by hand 8) Each engineer commits the fixed files. Not necessarily ideal, but it is the best process we could come up with given our constraints. I tend to use git remerge in step 7. Since the merge annotations are ugly and difficult to understand I wanted to use a three way merge to see the conflict and resolve the conflict. Git really does not have a command like mergetool to look at a resolved file. So I created a script. The next thing I would like to do with the script is make it use the preconfigured user preferred merge tool. Right now I use meld. #!/bin/bash -x usage() { cat << EOF usage: $0 [merge revision] [--] file Launch meld in a three way comparison, allows remerging files already merged. OPTIONS: merge revision: The revision that contains the merge. Defaults to HEAD --: Seperate the args from the file name. Conventionaly git argument style file: The name of the file in the repository meld will be used to redo the merge EOF } if [[ $# == 1 ]] ; then export TARGET_FILE=$1 export MERGE_VERSION=HEAD elif [[ $# == 2 ]] ; then export TARGET_FILE=$2 export MERGE_VERSION=$1 elif [[ $# == 3 && ${2}a == "--a" ]] ; then export TARGET_FILE=$3 export MERGE_VERSION=$1 else usage exit fi if [[ `git log -1 $MERGE_VERSION | grep -o "^Merge:"`a != "Merge:a" ]] ; then echo "Not a merge commit: $MERGE_VERSION" exit 1 fi export LEFT_VERSION=`git log -1 $MERGE_VERSION | grep "^Merge:" | sed -e 's/Merge: //g' | grep -o "^[a-f0-9]\+"` export RIGHT_VERSION=`git log -1 $MERGE_VERSION | grep "^Merge:" | grep -o "[^ ]\+\$"` export BASE_VERSION=`git merge-base $LEFT_VERSION $RIGHT_VERSION` export LEFT_FILE=`tempfile -p $(basename $TARGET_FILE) -s -${LEFT_VERSION:0:6}` export RIGHT_FILE=`tempfile -p $(basename $TARGET_FILE) -s -${RIGHT_VERSION:0:6}` export BASE_FILE=`tempfile -p $(basename $TARGET_FILE) -s -${BASE_VERSION:0:6}` git show $LEFT_VERSION:$TARGET_FILE > $LEFT_FILE git show $RIGHT_VERSION:$TARGET_FILE > $RIGHT_FILE git show $BASE_VERSION:$TARGET_FILE > $BASE_FILE meld --output $TARGET_FILE $LEFT_FILE $BASE_FILE $RIGHT_FILE #meld --auto-merge --output $TARGET_FILE $LEFT_FILE $BASE_FILE $RIGHT_FILE rm $LEFT_FILE $RIGHT_FILE $BASE_FILE -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.