.vimrc: Enhanced strip-trailing-whitespace
[dotfiles.git] / bin / git-outgoing
index b0d2d3d1d1a696d492fa4077f4d44d85228159c4..0cb29e4d7dcd258c39264d03a9909cccdadeb5b9 100755 (executable)
@@ -1,5 +1,5 @@
 #!/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
@@ -14,6 +14,13 @@ ADD=$(git config --get-color 'color.diff.new')
 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" ||
@@ -35,7 +42,10 @@ then
     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