Permalink
Browse files

adding gary's helpers

  • Loading branch information...
1 parent ec3aee5 commit 01653b1440c8c73eea079470ebdb37015b12249a @coreypurcell committed May 2, 2012
Showing with 66 additions and 74 deletions.
  1. +0 −46 gitconfig
  2. +27 −28 gitconfig.erb
  3. +39 −0 githelpers
View
46 gitconfig
@@ -1,46 +0,0 @@
-[user]
- name = Corey Purcell
- email = corey.purcell@gmail.com
-[alias]
- co = checkout
- lg = log --graph --pretty=format:'%Cred%h%Creset - %Cgreen(%cr)%Creset %s%C(yellow)%d%Creset' --abbrev-commit --date=relative
- ci = commit
- st = status
- br = branch
- hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
- type = cat-file -t
- dump = cat-file -p
- di = diff
- dc = diff --cached
- amend = commit --amend
- aa = add --all
- head = !git l -1
- h = !git head
- r = !git l -20
- ra = !git r --all
- ff = merge --ff-only
- pullff = pull --ff-only
- l = log --graph --abbrev-commit --date=relative
- la = !git l --all
- div = divergence
- gn = goodness
- gnc = goodness --cached
- fa = fetch --all
- pom = push origin master
-[color]
- diff = auto
- status = auto
- branch = auto
-[core]
- excludesfile = /Users/cpurcell/.gitignore
- safecrlf = true
- autocrlf = input
-[apply]
- whitespace = nowarn
-[merge]
- tool = vimdiff
-[diff]
-[github]
- user = coreypurcell
- token = a2d315ce244f56da258d1ca54e208083
-
View
55 gitconfig.erb
@@ -2,35 +2,34 @@
name = Corey Purcell
email = corey.purcell@gmail.com
[alias]
- co = checkout
- lg = log --graph --pretty=format:'%Cred%h%Creset - %Cgreen(%cr)%Creset %s%C(yellow)%d%Creset' --abbrev-commit --date=relative
- ci = commit
- st = status
- br = branch
- hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
- type = cat-file -t
- dump = cat-file -p
- di = diff
- dc = diff --cached
- amend = commit --amend
- aa = add --all
- head = !git l -1
- h = !git head
- r = !git l -20
- ra = !git r --all
- ff = merge --ff-only
- pullff = pull --ff-only
- l = log --graph --abbrev-commit --date=relative
- la = !git l --all
- div = divergence
- gn = goodness
- gnc = goodness --cached
- fa = fetch --all
- pom = push origin master
+ st = status
+ ci = commit
+ co = checkout
+ di = diff
+ dc = diff --cached
+ amend = commit --amend
+ aa = add --all
+ ff = merge --ff-only
+ pullff = pull --ff-only
+ noff = merge --no-ff
+ div = divergence
+ gn = goodness
+ gnc = goodness --cached
+ fa = fetch --all
+ pom = push origin master
+ b = branch
+ ds = diff --stat=160,120
+ dh1 = diff HEAD~1
+
+ head = !git l -1
+ h = !git head
+ hp = "!source ~/.githelpers && show_git_head"
+ r = !git l -30
+ ra = !git r --all
+ l = "!source ~/.githelpers && pretty_git_log"
+ la = !git l --all
[color]
- diff = auto
- status = auto
- branch = auto
+ ui = auto
[core]
excludesfile = /Users/cpurcell/.gitignore
safecrlf = true
View
39 githelpers
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+# Log output:
+#
+# * 51c333e (12 days) <Gary Bernhardt> add vim-eunuch
+#
+# The time massaging regexes start with ^[^<]* because that ensures that they
+# only operate before the first "<". That "<" will be the beginning of the
+# author name, ensuring that we don't destroy anything in the commit message
+# that looks like time.
+#
+# The log format uses } characters between each field, and `column` is later
+# used to split on them. A } in the commit subject or any other field will
+# break this.
+
+HASH="%C(yellow)%h%Creset"
+RELATIVE_TIME="%Cgreen(%ar)%Creset"
+AUTHOR="%C(bold blue)<%an>%Creset"
+REFS="%C(red)%d%Creset"
+SUBJECT="%s"
+
+FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT"
+
+show_git_head() {
+ pretty_git_log -1
+ git show -p --pretty="tformat:"
+}
+
+pretty_git_log() {
+ git log --graph --pretty="tformat:${FORMAT}" $* |
+ # Replace (2 years ago) with (2 years)
+ sed -Ee 's/(^[^<]*) ago)/\1)/' |
+ # Replace (2 years, 5 months) with (2 years)
+ sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?)/\1)/' |
+ # Line columns up based on } delimiter
+ column -s '}' -t |
+ # Page only if we need to
+ less -FXRS
+}

0 comments on commit 01653b1

Please sign in to comment.