2012-05-07 9 views

risposta

29

Uso --word-diff-regex:

--word-diff-regex=<regex> 
     Use <regex> to decide what a word is, instead of considering runs 
     of non-whitespace to be a word. Also implies --word-diff unless it 
     was already enabled. 

     Every non-overlapping match of the <regex> is considered a word. 
     Anything between these matches is considered whitespace and 
     ignored(!) for the purposes of finding differences. You may want to 
     append |[^[:space:]] to your regular expression to make sure that 
     it matches all non-whitespace characters. A match that contains a 
     newline is silently truncated(!) at the newline. 

     The regex can also be set via a diff driver or configuration 
     option, see gitattributes(1) or git-config(1). Giving it explicitly 
     overrides any diff driver or configuration setting. Diff drivers 
     override configuration settings. 

ho mai usato ma credo che git diff --word-diff-regex="[^[:space:],]+" può funzionare.

+0

E funziona :-) – oberlies

+0

Qualsiasi idea di come impostarlo in config git, per utilizzare questo regex per impostazione predefinita, quando ho specificare --word-diff, piuttosto che me dover specificare l'espressione regolare di volta in volta . – sibaz

+1

Ho risposto alla mia domanda: 'git config --global diff.wordRegex [^ [: space:],] +' – sibaz

1

Puoi anche provare -w/--ignore-all-space, anche se questo potrebbe ignorare più spazio bianco di quello che vuoi.

+0

-b ignora un po 'meno spazio bianco –

9

In aggiunta alla risposta di KurzedMetal: senza le virgolette funziona ancora meglio poiché non interrompe il completamento automatico del mio bash quando si colpisce TAB.

git diff --word-diff-regex=[^[:space:],]+

Problemi correlati