From e048e6f8d6108a9911db0810d84d192219fa0999 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Thu, 3 May 2012 22:00:01 -0500 Subject: [PATCH] git-incoming and outgoing updates * git-outgoing: Support -d/--diff option. * git-outgoing, git-incoming: Use single -c argument to cut, for compatibility with GNU (coreutils) version of 'cut'. --- bin/git-incoming | 7 +++---- bin/git-outgoing | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bin/git-incoming b/bin/git-incoming index 3c5b99b..e425269 100755 --- a/bin/git-incoming +++ b/bin/git-incoming @@ -1,5 +1,5 @@ #!/bin/sh -# Usage: git-incoming [--diff] [] [ []] +# Usage: git-incoming [-d] [] [ []] # Show commits on that do not exist on current branch. # bail out with message to stderr and exit status 1 @@ -47,9 +47,8 @@ fi if $diff then git diff HEAD..."$1" -else - git cherry -v HEAD "$@" | - cut -c1-9 -c43- | +else git cherry -v HEAD "$@" | + cut -c1-9,43- | sed -e "s/^\(.\) \(.......\)/\1 $SHA\2$RESET/" | sed -e "s/^-/$REM-$RESET/" -e "s/^+/$ADD+$RESET/" fi diff --git a/bin/git-outgoing b/bin/git-outgoing index b0d2d3d..0cb29e4 100755 --- a/bin/git-outgoing +++ b/bin/git-outgoing @@ -1,5 +1,5 @@ #!/bin/sh -# Usage: git-outgoing [] [ []] +# Usage: git-outgoing [-d] [] [ []] # Show commits on current branch that do not exist on branch . # 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/ 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 -- 2.45.2