Ecco uno script (originariamente di Toby White) che ho violato per confrontare l'intera struttura di directory in FileMerge piuttosto che aprire ciascun file singolarmente.
#!/bin/sh
#
# This script was written by Toby White under an unknown license, and published
# on the Git mailing list:
#
# http://kerneltrap.org/mailarchive/git/2007/11/21/435536
#
# Superficial changes were made by Nathan de Vries to allow the script to be
# run under Leopard.
#
# Adapted by Daniel Miller : http://stackoverflow.com/a/12957945/10840
# - allow changes to be saved back to the working copy when diffing against HEAD
# - work when FileMerge is already open
# - always compare archived copies so ignored files are excluded from the diff
# - allow diff of unstaged changes (no arguments); creates a dangling commit
#
# Known issues:
# - Always uses the same two directories (/tmp/git-opendiff-old and
# /tmp/git-opendiff-new); THEY WILL BE DELETED IF THEY ALREADY EXIST.
# Ugly, I know, but it makes the script work even if FileMerge is open.
# - Does not show unstaged changes.
if test "$1" = -h; then
echo "usage: $0 [--cached | <ref>] [<ref>]"
exit
elif test $# = 0; then
# diff unstaged changes
# http://stackoverflow.com/a/12010656/10840
NEW=$(git stash create)
OLD=HEAD
elif test "$1" = --cached; then
# diff staged changes
OLD=HEAD
NEW=`git write-tree`
shift
fi
if test $# -gt 0; then
OLD="$1"; shift
fi
test $# -gt 0 && test -z "$CACHED" && NEW="$1"
TMP_OLD=/tmp/git-opendiff-old
TMP_NEW=/tmp/git-opendiff-new
test -d $TMP_OLD && rm -rf $TMP_OLD; mkdir $TMP_OLD
test -d $TMP_NEW && rm -rf $TMP_NEW; mkdir $TMP_NEW
TMP_OLD=$TMP_OLD/$OLD; mkdir -p $TMP_OLD
git archive --format=tar $OLD | (cd $TMP_OLD; tar xf -)
if test -z "$NEW"; then
SAVE_TO=$(git rev-parse --show-cdup)
test -z "$cdup" && SAVE_TO=.
git archive --format=tar HEAD | (cd $TMP_NEW; tar xf -)
opendiff $TMP_OLD $TMP_NEW -merge $SAVE_TO
else
TMP_NEW=$TMP_NEW/$NEW; mkdir -p $TMP_NEW
git archive --format=tar $NEW | (cd $TMP_NEW; tar xf -)
opendiff $TMP_OLD $TMP_NEW
fi
Mettilo da qualche parte sul tuo percorso. Preferisco ~/bin/git-opendiff
, che significa che git opendiff ...
funziona come previsto.
Aggiornamento: modifiche non modificate quando chiamate senza argomenti, aggiunta l'opzione -h
(aiuto).
grazie !!!!!!!!!!!!!! quindi "difftool" è fondamentalmente come un normale comando "diff" ma dando la scelta per uno strumento diff esterno? e "opendiff" chiama in modo specifico FileMerge? e posso ancora passare un percorso a un file specifico per diff solo uno? mi dispiace, a casa ora e non riesco a testare sul mio computer di lavoro;) – Doug
in realtà, che non sta facendo nulla per me vedo. la mia linea di comando restituisce semplicemente un prompt. Ho provato a far sparire il filemerge, niente. – doug
Ciao, Doug. Potrebbe avere problemi a trovare il binario "opendiff" sul tuo percorso. Cosa succede quando crei un paio di file di testo, quindi digita "opendiff file1.txt file2.txt" nel terminale? – undees