From c1a3af31f02fdd9462ed5169356b6d43baac344e Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 26 Mar 2021 15:15:24 -0400 Subject: [PATCH] Improve Beyond Compare integration with git --- bash_aliases.d/git | 13 ++++++------- git_bc3diff | 14 -------------- git_bc3merge | 10 ---------- git_bcdiff | 12 ++++++++++++ git_bcmerge | 8 ++++++++ gitignore | 4 ++++ 6 files changed, 30 insertions(+), 31 deletions(-) delete mode 100755 git_bc3diff delete mode 100755 git_bc3merge create mode 100755 git_bcdiff create mode 100755 git_bcmerge diff --git a/bash_aliases.d/git b/bash_aliases.d/git index af6c4a5..113104a 100644 --- a/bash_aliases.d/git +++ b/bash_aliases.d/git @@ -18,13 +18,12 @@ function git-config-joshs() git config --global alias.mktarxz '!function f { name="$1"; pos="$2"; if [ "$pos" == "" ]; then pos=HEAD; fi; git archive --prefix="$name"/ "$pos" | xz > ../"$name".tar.xz; }; f' git config --global alias.amd 'am --committer-date-is-author-date' git config --global push.default upstream - git config --global alias.bcdiff 'difftool -y -t bc3' - git config --global alias.bcdiffc 'difftool -y -t bc3 --cached' - git config --global difftool.bc3.cmd 'git_bc3diff "$LOCAL" "$REMOTE"' - git config --global alias.bcmerge 'mergetool -y -t bc3' - git config --global mergetool.bc3.cmd \ - 'git_bc3merge "$LOCAL" "$REMOTE" "$MERGED"' - git config --global mergetool.bc3.trustExitCode false + git config --global alias.bcdiff 'difftool -y -t bc' + git config --global alias.bcdiffc 'difftool -y -t bc --cached' + git config --global difftool.bc.cmd 'git_bcdiff "$LOCAL" "$REMOTE" "$MERGED"' + git config --global alias.bcmerge 'mergetool -y -t bc' + git config --global mergetool.bc.cmd \ + 'git_bcmerge "$LOCAL" "$REMOTE" "$BASE" "$MERGED"' git config --global alias.authors '!git log --pretty="%an" | sort | uniq -c | sort -n' } function git-config-local-personal() diff --git a/git_bc3diff b/git_bc3diff deleted file mode 100755 index d5bc2b0..0000000 --- a/git_bc3diff +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -if [[ $(uname) =~ CYGWIN ]]; then - path1=$(cygpath -w "$1") - path2=$(cygpath -w "$2") - '/cygdrive/c/apps/Beyond Compare 3/BCompare.exe' "$path1" "$path2" /title1=Base /leftreadonly & -else - bcompare "$1" "$2" -title1=Base -leftreadonly & -fi - -# git will remove the temporary file as soon as the difftool command exits; -# sleep to give Beyond Compare a chance to load the file and display the diff -# before the file is removed. -sleep 1 diff --git a/git_bc3merge b/git_bc3merge deleted file mode 100755 index 927b8d2..0000000 --- a/git_bc3merge +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -if [[ $(uname) =~ CYGWIN ]]; then - local=$(cygpath -w "$1") - remote=$(cygpath -w "$2") - merged=$(cygpath -w "$3") - '/cygdrive/c/apps/Beyond Compare 3/BCompare.exe' "$local" "$remote" /title1=Local /title2=Remote /savetarget="$merged" -else - bcompare "$1" "$2" -title1=Local -title2=Remote -savetarget="$3" -fi diff --git a/git_bcdiff b/git_bcdiff new file mode 100755 index 0000000..f868f4f --- /dev/null +++ b/git_bcdiff @@ -0,0 +1,12 @@ +#!/bin/bash + +local_fname="$1" +remote_fname="$2" +merged_fname="$3" + +bcompare "$local_fname" "$remote_fname" -title1="$merged_fname" -title2="$merged_fname" -leftreadonly & + +# git will remove the temporary file as soon as the difftool command exits; +# sleep to give Beyond Compare a chance to load the file and display the diff +# before the file is removed. +sleep 0.5 diff --git a/git_bcmerge b/git_bcmerge new file mode 100755 index 0000000..a542a83 --- /dev/null +++ b/git_bcmerge @@ -0,0 +1,8 @@ +#!/bin/bash + +local_fname="$1" +remote_fname="$2" +base_fname="$3" +merged_fname="$4" + +exec bcompare "$local_fname" "$remote_fname" "$base_fname" "$merged_fname" -title1="$merged_fname : local" -title2="$merged_fname : remote" -savetarget="$merged_fname" diff --git a/gitignore b/gitignore index ba50dd3..1c02014 100644 --- a/gitignore +++ b/gitignore @@ -6,3 +6,7 @@ tags /.todo /.bundle/ +/.issues +/.ruby-version +/.ruby-gemset +/_local/