]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - bin/git-up
bin/git-branch-dates: Smarter automatic line truncation
[dotfiles.git] / bin / git-up
1 #!/bin/sh
2
3 # Usage: git-up
4 # git-reup
5 #
6 # Like git-pull but show a short and sexy log of changes
7 # immediately after merging (git-up) or rebasing (git-reup).
8 #
9 # Inspired by Kyle Neath's `git up' alias:
10 # http://gist.github.com/249223
11 # Stolen from Ryan Tomayko
12 # http://github.com/rtomayko/dotfiles/blob/rtomayko/bin/git-up
13
14 set -e
15
16 if [ "$(basename $0)" = "git-reup" ]; then
17 # when invoked as git-reup, run as `git pull --rebase ...'
18 PULL_ARGS="--rebase"
19 FETCH_ARGS=""
20 else
21 # when invoked as git-up, run as `git pull ...`
22 PULL_ARGS="--ff-only"
23 if [ " $@" = " " ]; then
24 # when invoked without a repo/head, fetch (and prune) all remotes
25 FETCH_ARGS="--all --prune"
26 fi
27 fi
28
29 HEAD_OLD=$(git rev-parse HEAD)
30 git pull $PULL_ARGS $FETCH_ARGS $@
31 HEAD_NEW=$(git rev-parse HEAD)
32
33 if [ "$HEAD_OLD" != "$HEAD_NEW" ]; then
34 # if HEAD was actually updated...
35 if [ "$(basename $0)" = "git-reup" ]; then
36 # if we're pulling with --rebase, show diffstat of all changes.
37 # not sure why git-pull only does this when merging.
38 echo "Diff:"
39 git --no-pager diff --color --stat ${HEAD_OLD}.. | sed 's/^/ /'
40 fi
41
42 # show an abbreviated commit log of stuff that was just merged.
43 echo "Log:"
44 git log --color --pretty=oneline --abbrev-commit ${HEAD_OLD}.. | sed 's/^/ /'
45 fi