#!/bin/sh
-# Usage: git-outgoing [<upstream>] [<head> [<limit>]]
+# Usage: git-outgoing [-d] [<upstream>] [<head> [<limit>]]
# Show commits on current branch that do not exist on branch <upstream>.
# bail out with message to stderr and exit status 1
REM=$(git config --get-color 'color.diff.old')
RESET=$(git config --get-color '' 'reset')
+# check for -d / --diff argument
+diff=false
+if [ "$1" = '-d' -o "$1" = '--diff' ]
+then diff=true
+ shift
+fi
+
# get the current branch in refs/heads/<branch> form
ref=$(git symbolic-ref -q HEAD)
test -n "$ref" ||
set -- "$remote/$(echo "$merge" |sed 's@^refs/heads/@@')"
fi
-git cherry -v "$@" |
-cut -c1-9 -c43- |
-sed -e "s/^\(.\) \(.......\)/\1 $SHA\2$RESET/" |
-sed -e "s/^-/$REM-$RESET/" -e "s/^+/$ADD+$RESET/"
+if $diff
+then git diff "$1"...HEAD
+else git cherry -v "$@" |
+ cut -c1-9,43- |
+ sed -e "s/^\(.\) \(.......\)/\1 $SHA\2$RESET/" |
+ sed -e "s/^-/$REM-$RESET/" -e "s/^+/$ADD+$RESET/"
+fi