Skip to content

Instantly share code, notes, and snippets.

@IgorInger
Forked from ecerulm/diffmerge-diff.sh
Created February 21, 2012 23:43
Show Gist options
  • Save IgorInger/1879881 to your computer and use it in GitHub Desktop.
Save IgorInger/1879881 to your computer and use it in GitHub Desktop.
Cygwin Git: wrappers for diffmerge and winmerge. http://rubenlaguna.com/wp/2010/08/05/visual-difftool-cygwin-git/
#!/bin/sh
# Use SourceGear DiffMerge as mergetool for git in cygwin.
# git config --global mergetool.diffmerge.cmd "diffmergetool.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
# git config --global mergetool.diffmerge.trustExitCode false
# git difftool -t diffmerge branch1..branch2
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
library=githelperfunctions.sh
source $library
echo Launching DiffMerge.exe - diffmerge-diff.sh:
set_path_vars "$1" "$2" "$3" "$4"
echo "$diffmergewinpath" -t1=LOCAL -t2=REMOTE --caption=$caption $localwinpath $remotewinpath
"$diffmergewinpath" -t1=LOCAL -t2=REMOTE --caption="$caption" "$localwinpath" "$remotewinpath"
#!/bin/sh
# Use SourceGear DiffMerge as mergetool for git in cygwin.
# git config --global mergetool.diffmerge.cmd "diffmergetool.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
# git config --global mergetool.diffmerge.trustExitCode false
# git mergetool -t diffmerge
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
library=githelperfunctions.sh
source $library
echo Launching DiffMerge.exe - diffmerge-merge.sh:
set_path_vars "$1" "$2" "$3" "$4"
echo "$diffmergewinpath" --merge -t1=LOCAL -t2=MERGED -t3=REMOTE --result=$mergedwinpath --caption=$caption $localwinpath $basewinpath $remotewinpath
"$diffmergewinpath" --merge -t1=LOCAL -t2=MERGED -t3=REMOTE --result="$mergedwinpath" --caption="$caption" "$localwinpath" "$basewinpath" "$remotewinpath"
unix2dos "$merged"
#!/bin/sh
NUMBER=1879881
TMP_PATH=/tmp/gist-$NUMBER
FILES="diffmerge-diff.sh diffmerge-merge.sh githelperfunctions.sh winmerge-diff.sh winmerge-merge.sh"
if [ -e $TMP_PATH ]
then
rm -rf $TMP_PATH
fi
git clone git://gist.github.com/$NUMBER.git $TMP_PATH
for FILE in $FILES
do
cp $TMP_PATH/$FILE /usr/local/bin/$FILE
done
rm -rf $TMP_PATH
rm git-diffmerge-installer.sh
# Setup git
# Diffmerge
git config --global difftool.diffmerge.cmd "diffmerge-diff.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
git config --global difftool.diffmerge.prompt false
git config --global mergetool.diffmerge.cmd "diffmerge-merge.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
git config --global mergetool.diffmerge.trustExitCode false
# Winmerge
git config --global difftool.winmerge.cmd "winmerge-diff.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
git config --global difftool.winmerge.prompt false
git config --global mergetool.winmerge.cmd "winmerge-merge.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
git config --global mergetool.winmerge.trustExitCode false
#!/bin/sh
#
# Git gerrit push
#
if [ -z "$1" ]; then
REMOTE=origin
else
REMOTE=$1
fi
BRANCH=$(git symbolic-ref HEAD)
case $BRANCH in
refs/heads/*)
BRANCH=$(basename $BRANCH)
;;
*)
echo "I can't figure out which branch you are on."
exit 1
;;
esac
git push $REMOTE HEAD:refs/for/$BRANCH
# Helper functions
convert_path () {
file=$1
if [ "$file" == '/dev/null' ] || [ ! -e "$file" ]
then
file="/tmp/nulla"
`echo "">$file`
fi
echo `cygpath -w -a "$file"`
}
set_path_vars () {
local=$1
remote=$2
base=$3
merged=$4
echo ========= Cygwin paths =======
echo "LOCAL : $local"
echo "REMOTE : $remote"
echo "BASE : $base"
echo "MERGED : $merged"
localwinpath=$(convert_path "$local")
remotewinpath=$(convert_path "$remote")
basewinpath=$(convert_path "$base")
mergedwinpath=$(convert_path "$merged")
echo ========= Win paths =======
echo "LOCAL : $localwinpath"
echo "REMOTE : $remotewinpath"
echo "BASE : $basewinpath"
echo "MERGED : $mergedwinpath"
caption=`basename "$merged"`
diffmergewinpath="C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe"
winmergewinpath="C:/Program Files/WinMerge/WinMergeU.exe"
# diffmergewinpath=`cygpath -u C:/Program Files/SourceGear/DiffMerge/DiffMerge.exe`
# winmergewinpath=`cygpath -u \"C:\Program Files\WinMerge\WinMergeU.exe\"`
}
#!/bin/sh
# Use winmerge as mergetool for git in cygwin.
# git config --global difftool.winmerge.cmd "winmerge-diff.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\""
# git config --global mergetool.winmerge.trustExitCode false
# git difftool -t winmerge branch1..branch2
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
# Reference: http://winmerge.org/docs/manual/CommandLine.html
library=githelperfunctions.sh
source $library
echo Launching winmerge.exe - winmerge-diff.sh:
set_path_vars "$1" "$2" "$3" "$4"
echo "$winmergewinpath" /dl LOCAL.$caption /dr TO_VERSION.$caption $localwinpath $remotewinpath
"$winmergewinpath" /dl "LOCAL.$caption" /dr "TO_VERSION.$caption" "$localwinpath" "$remotewinpath"
#!/bin/sh
# Use winmerge as mergetool for git in cygwin.
# git config --global mergetool.winmerge.cmd "winmerge-merge.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
# git config --global mergetool.winmerge.trustExitCode false
# git mergetool -t diffmerge
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
# Reference: http://winmerge.org/docs/manual/CommandLine.html
library=githelperfunctions.sh
source $library
echo Launching winmerge.exe - winmerge-merge.sh:
set_path_vars "$1" "$2" "$3" "$4"
# -- use WinMergeU conflictFile
echo "$winmergewinpath" $mergedwinpath
"$winmergewinpath" "$mergedwinpath"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment