#!/bin/sh # Usage: git-up # git-reup # # Like git-pull but show a short and sexy log of changes # immediately after merging (git-up) or rebasing (git-reup). # # Inspired by Kyle Neath's `git up' alias: # http://gist.github.com/249223 set -e PULL_ARGS="$@" if [ "$(basename $0)" = "git-reup" ]; then # when invoked as git-reup, run as `git pull --rebase ...' PULL_ARGS="--rebase $PULL_ARGS" FETCH_ARGS="" else # when invoked as git-up, run as `git pull ...` PULL_ARGS="--ff-only $PULL_ARGS" if [ " $@" = " " ]; then # when invoked without a repo/head, fetch (and prune) all remotes FETCH_ARGS="--all --prune" fi fi HEAD_OLD=$(git log -1 --pretty='format:%H' HEAD) git pull $PULL_ARGS $FETCH_ARGS $@ HEAD_NEW=$(git log -1 --pretty='format:%H' HEAD) if [ "$HEAD_OLD" != "$HEAD_NEW" ]; then # if HEAD was actually updated... if [ "$(basename $0)" = "git-reup" ]; then # if we're pulling with --rebase, show diffstat of all changes. # not sure why git-pull only does this when merging. echo "Diff:" git --no-pager diff --color --stat ${HEAD_OLD}.. | sed 's/^/ /' fi # show an abbreviated commit log of stuff that was just merged. echo "Log:" git log --color --pretty=oneline --abbrev-commit ${HEAD_OLD}.. | sed 's/^/ /' fi