Skip to content

Instantly share code, notes, and snippets.

@fetep
Created March 15, 2013 06:37
Show Gist options
  • Select an option

  • Save fetep/5167906 to your computer and use it in GitHub Desktop.

Select an option

Save fetep/5167906 to your computer and use it in GitHub Desktop.

Revisions

  1. fetep created this gist Mar 15, 2013.
    23 changes: 23 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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