-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-notpushed
executable file
·42 lines (37 loc) · 1.2 KB
/
git-notpushed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#
# git-notpushed
# Shows commits you haven't pushed to the remote yet. Optionally accepts same
# arguments as git-log. Assumes "origin" is the remote if no
# branch.<current>.remote configuration exists (or "trunk" for repositories
# that seem to have git-svn remotes).
# Adapted from <http://scie.nti.st/2007/12/7/git-notpushed>.
#
# Usage:
# git notpushed [arguments to git log]
#
# Pure git or git-svn? (there must be a better way to do this...)
git_svn_remotes=`git config --get-regexp svn-remote`
if [ "$git_svn_remotes" != "" ]; then
is_git_svn=1
else
is_git_svn=0
fi
# Get the current branch
current_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
# Figure out the origin for the current branch
origin=$(git config --get "branch.$current_branch.remote")
if [ "$origin" == "" ]; then
if [ "$is_git_svn" == 1 ]; then
origin=${origin:-trunk}
else
origin=${origin:-origin}
fi
fi
if [ "$is_git_svn" == 1 ]; then
origin="^remotes/$origin"
else
origin="^remotes/$origin/$current_branch"
fi
# Show the commits since the origin's HEAD in a nice one-line format, with no paging
GIT_PAGER=cat git log --pretty=tformat:"%Cred%h%Creset %s (%ar)" $@ $current_branch $origin --