Skip to content

Instantly share code, notes, and snippets.

@fetep
Created March 15, 2013 06:37
Show Gist options
  • Save fetep/5167906 to your computer and use it in GitHub Desktop.
Save fetep/5167906 to your computer and use it in GitHub Desktop.
c0 fetep-vm(~) % cat bin/git-push-n
#!/bin/bash
if [ $# -ne 2 ]; then
echo "usage: git push-n <remote> <ref>" >&2
exit 1
fi
output=$(git push -n "$@" 2>&1)
git_rc=$?
echo "$output" >&2
range=$(
echo $output |
sed -n -r -e 's,^.* ([0-9a-f]+\.\.[0-9a-f]+).*,\1,p'
)
if [ -n "$range" ]; then
exec git log $range
fi
exit $git_rc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment