Monday, March 28, 2011

Remote git diffs with bbdiff

  1. See previous post about key exchange.
  2. Add the following to .gitconfig:
    [diff]
        tool = "bbdiff"
    [difftool]
        prompt = false
    [difftool "bbdiff"]
        cmd = /home/mihaip/bin/bbdiff "$REMOTE" "$LOCAL"
    
  3. Create bbdiff on the remote machine with the following contents:
    #!/bin/sh
    
    source_machine=${SSH_CLIENT%% *}
    for arg in "$@"
    do
      readlink -fn $arg
      if [[ $arg == /tmp/* ]]
      then
        scp $arg mihaip@$source_machine:$arg
      fi
      echo -n " "
    done | xargs ssh mihaip@$source_machine /usr/local/bin/bbdiff --wait --resume