@matheusbsbs / matheus-bagliano / commits / 5620518095
Fork 0

git-diff: do not turn off -p/-M with any diff options.

When the user gives a diff option (e.g. --cached) to "git diff", we turned off the built-in default option -p, which is usually not what user wants to see. This commit makes lack of --name-status, --name-only nor -r to add -p, and lack of -B*, -C* nor -M* to add -M to the flags given to the underlying diff. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 29, 2005 at 21:59 UTC 562051809589574576971c53c23aad93f8c395d9
1 file changed +15 -2
git-diff.sh
+15 -2
@@ -7,8 +7,6 @@ rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
7 flags=$(git-rev-parse --no-revs --flags --sq "$@")
8 files=$(git-rev-parse --no-revs --no-flags --sq "$@")
9
10 -: ${flags:="'-M' '-p'"}
11 -
10 # I often say 'git diff --cached -p' and get scolded by git-diff-files, but
11 # obviously I mean 'git diff --cached -p HEAD' in that case.
12 case "$rev" in
@@ -20,6 +18,21 @@ case "$rev" in
18 esac
19 esac
20
21 +# If we do not have --name-status, --name-only nor -r, default to -p.
22 +# If we do not have -B nor -C, default to -M.
23 +case " $flags " in
24 +*" '--name-status' "* | *" '--name-only' "* | *" '-r' "* )
25 + ;;
26 +*)
27 + flags="$flags'-p' " ;;
28 +esac
29 +case " $flags " in
30 +*" '-"[BCM]* | *" '--find-copies-harder' "*)
31 + ;; # something like -M50.
32 +*)
33 + flags="$flags'-M' " ;;
34 +esac
35 +
36 case "$rev" in
37 ?*' '?*' '?*)
38 echo >&2 "I don't understand"