Merge branch 'ab/subtree-doc'
[git] / contrib / examples / git-whatchanged.sh
1 #!/bin/sh
2
3 USAGE='[-p] [--max-count=<n>] [<since>..<limit>] [--pretty=<format>] [-m] [git-diff-tree options] [git-rev-list options]'
4 SUBDIRECTORY_OK='Yes'
5 . git-sh-setup
6
7 diff_tree_flags=$(git-rev-parse --sq --no-revs --flags "$@") || exit
8 case "$0" in
9 *whatchanged)
10         count=
11         test -z "$diff_tree_flags" &&
12                 diff_tree_flags=$(git config --get whatchanged.difftree)
13         diff_tree_default_flags='-c -M --abbrev' ;;
14 *show)
15         count=-n1
16         test -z "$diff_tree_flags" &&
17                 diff_tree_flags=$(git config --get show.difftree)
18         diff_tree_default_flags='--cc --always' ;;
19 esac
20 test -z "$diff_tree_flags" &&
21         diff_tree_flags="$diff_tree_default_flags"
22
23 rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
24 diff_tree_args=$(git-rev-parse --sq --no-revs --no-flags "$@") &&
25
26 eval "git-rev-list $count $rev_list_args" |
27 eval "git-diff-tree --stdin --pretty -r $diff_tree_flags $diff_tree_args" |
28 LESS="$LESS -S" ${PAGER:-less}