Created
January 11, 2017 09:24
-
-
Save bluss/5c58505ba8c6e232de10dd90c6bb4bc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Display a git status, without touching or | |
# displaying any untracked files; | |
# just display the diffstat for index and worktree | |
USAGE="[<directory>]" | |
LONG_USAGE="Display diffstat for staging area and working directory, relative to current directory (or the given directory, -t for top)" | |
SUBDIRECTORY_OK=y | |
. $(git --exec-path)/git-sh-setup | |
require_work_tree | |
DIR=$1 | |
test "x$DIR" = "x-t" && IS_TOP=1 | |
test -n "$DIR" && DIR=$(readlink -f -- "$DIR") | |
test -z "$DIR" && DIR=$(readlink -f -- "$PWD") | |
cd_to_toplevel | |
T=$(pwd) | |
REL= | |
test "x$DIR" != "x$T" -a -z $IS_TOP && REL="${DIR##$T/}/" | |
DIFFCMD="--stat=,80" | |
DIFFOPTS="-B -C -C -M --color --summary" | |
GITOPTS="--no-pager" | |
LESSOPTS="-FX -R -S" | |
test -n "$REL" && echo "Relative to $REL" >&2 | |
set -e | |
# put it all through less -F (quit if less than one screen) together | |
( | |
printf '\033[01;32mSTAGED\033[m\n' | |
git $GITOPTS diff --cached "$DIFFCMD" --relative=$REL $DIFFOPTS | |
printf '\033[01;31mIN WORKING TREE\033[m\n' | |
git $GITOPTS diff "$DIFFCMD" --relative=$REL $DIFFOPTS | |
) | less $LESSOPTS | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment