diff

2012-05-07 19 views
21

में एक शब्द विभाजक के रूप में अल्पविराम का उपयोग करें, मैं गिट diff --word-diff के लिए शब्द विभाजक के रूप में , कैसे जोड़ सकता हूं?diff

उदाहरण के लिए मैं diff पहचान करने के लिए कि

function(A,B,C) -> function(A, B, C) 

केवल बजाय पूरे लाइन की जगह के रिक्त स्थान जोड़ा गया है चाहते हैं।

उत्तर

29

उपयोग --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. 

मैं इसे इस्तेमाल कभी नहीं किया, लेकिन मैं अनुमान है कि git diff --word-diff-regex="[^[:space:],]+" काम कर सकते हैं।

+0

यह कार्य करता है :-) – oberlies

+0

किसी भी विचार Git config में मुझे regex हर बार निर्दिष्ट करने के लिए की तुलना में इसे कैसे सेट, जब मैं --word-diff निर्दिष्ट करते हैं, डिफ़ॉल्ट रूप से इस regex का उपयोग करने के लिए नहीं बल्कि । – sibaz

+1

ने अपना खुद का प्रश्न उत्तर दिया: 'git config --global diff.wordRegex [^ [: space:],] + ' – sibaz

1

आप -w/--ignore-all-space भी आजमा सकते हैं, हालांकि यह आपकी पसंद से अधिक सफेद जगह को अनदेखा कर सकता है।

+0

-b थोड़ा कम सफेद जगह को अनदेखा करता है –

9

KurzedMetal के उत्तर के अलावा: उद्धरण के बिना यह भी बेहतर काम करता है क्योंकि यह टैब को मारते समय मेरे बैश स्वतः पूर्ण नहीं करता है।

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