git-diff.shon commit Documentation: git-commit in 1.2.X series defaults to --include. (64491e1)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Linus Torvalds
   4# Copyright (c) 2005 Junio C Hamano
   5
   6USAGE='[ --diff-options ] <ent>{0,2} [<path>...]'
   7SUBDIRECTORY_OK='Yes'
   8. git-sh-setup
   9
  10rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
  11flags=$(git-rev-parse --no-revs --flags --sq "$@")
  12files=$(git-rev-parse --no-revs --no-flags --sq "$@")
  13
  14# I often say 'git diff --cached -p' and get scolded by git-diff-files, but
  15# obviously I mean 'git diff --cached -p HEAD' in that case.
  16case "$rev" in
  17'')
  18        case " $flags " in
  19        *" '--cached' "*)
  20                rev='HEAD '
  21                ;;
  22        esac
  23esac
  24
  25# If we have -[123] --ours --theirs --base, don't do --cc by default.
  26case " $flags " in
  27*" '-"[123]"' "* | *" '--ours' "* | *" '--base' "* | *" '--theirs' "*)
  28        cc_or_p=-p ;;
  29*)
  30        cc_or_p=--cc ;;
  31esac
  32
  33# If we do not have --name-status, --name-only, -r, or -c default to --cc.
  34case " $flags " in
  35*" '--name-status' "* | *" '--name-only' "* | *" '-r' "* | *" '-c' "* )
  36        ;;
  37*)
  38        flags="$flags'$cc_or_p' " ;;
  39esac
  40
  41# If we do not have -B nor -C, default to -M.
  42case " $flags " in
  43*" '-"[BCM]* | *" '--find-copies-harder' "*)
  44        ;; # something like -M50.
  45*)
  46        flags="$flags'-M' " ;;
  47esac
  48
  49case "$rev" in
  50?*' '?*' '?*)
  51        usage
  52        ;;
  53?*' '^?*)
  54        begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
  55        end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
  56        cmd="git-diff-tree $flags $begin $end -- $files"
  57        ;;
  58?*' '?*)
  59        cmd="git-diff-tree $flags $rev -- $files"
  60        ;;
  61?*' ')
  62        cmd="git-diff-index $flags $rev -- $files"
  63        ;;
  64'')
  65        cmd="git-diff-files $flags -- $files"
  66        ;;
  67*)
  68        usage
  69        ;;
  70esac
  71
  72eval "$cmd"