From: Jannik Zander Date: Fri, 20 May 2016 20:42:54 +0000 (+0200) Subject: Move git config to .config/git X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=9010c70206129a3124364017e80e19ecdbe3a1f0;p=dotfiles.git Move git config to .config/git --- diff --git a/.config/git/config b/.config/git/config new file mode 100644 index 0000000..5206648 --- /dev/null +++ b/.config/git/config @@ -0,0 +1,102 @@ +# ~/.config/git/config + +[github] + user = jannikz +[alias] + a = add + una = reset HEAD -- + uha = checkout HEAD -- + aa = add -u + unaa = reset HEAD + uhaa = reset --hard HEAD + br = branch + brdm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d" + co = checkout + go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f" + ci = commit -v + unci = reset --soft HEAD~ + amend = commit --amend + diff = diff --word-diff + dt = difftool + mt = mergetool + # dont pull without rebase, and dont push without pull (fetch & merge) + pu = pull --rebase + pp = "!git pull --rebase && git push" + # avoid merge commits + mf = merge --ff-only + cp = cherry-pick + wc = whatchanged -p + ch = cherry -v + st = status -sb + fs = "!git fetch && git status" + rb = rebase + ready = rebase -i @{u} + rbi = "!r() { git rebase -i HEAD~$1; }; r" + ec = config --global -e + l = log --oneline --decorate --reverse + lg = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph + tail = !"git lg -10 HEAD" + last = log -1 HEAD + ls = ls-files + lt = tag -l + type = cat-file -t + dump = cat-file -p + who = shortlog -s -- + remotes = remote -v + root = rev-parse --show-toplevel + cl = clone --recursive + + # Show the diff between the latest commit and the current state + d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat" + # `git di $number` shows the diff between the state `$number` revisions ago and the current state + di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d" + + # Find branches containing commit + fb = "!f() { git branch -a --contains $1; }; f" + # Find tags containing commit + ft = "!f() { git describe --always --contains $1; }; f" + # Find commits by source code + fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f" + # Find commits by commit message + fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f" + +# Credit an author on the latest commit + credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f" + # List contributors with number of commits + contributors = shortlog --summary --numbered + + k = !gitk + visual = !gitk + + ctags = "!sh -c '[ -f .git/hooks/ctags ] || git init; .git/hooks/ctags' git-ctags" + gtags = "!sh -c '[ -f .git/hooks/gtags ] || git init; .git/hooks/gtags' git-gtags" + cscope = "!sh -c '[ -f .git/hooks/cscope ] || git init; .git/hooks/cscope' git-cscope" + +[help] + autocorrect = 10 +[branch] + autosetupmerge = always + autosetuprebase = always +[rebase] + autosquash = true + autostash = true +[pull] + rebase = true +[push] + default = simple +[diff] + tool = vimdiff +[difftool] + prompt = false +[merge] + tool = vimdiff + conflictstyle = diff3 +[mergetool] + prompt = false +[init] + templatedir = ~/.config/git/templates +[core] + editor = vim + autocrlf = false +[include] + path = ~/.config/git/config_local diff --git a/.config/git/templates/config b/.config/git/templates/config new file mode 100644 index 0000000..f8767a9 --- /dev/null +++ b/.config/git/templates/config @@ -0,0 +1,9 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[branch "master"] + remote = origin + merge = refs/heads/master + rebase = true diff --git a/.config/git/templates/hooks/cscope b/.config/git/templates/hooks/cscope new file mode 100755 index 0000000..42f9522 --- /dev/null +++ b/.config/git/templates/hooks/cscope @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +PATH="/usr/local/bin:$PATH" +dir="`git rev-parse --git-dir`" +trap 'rm -f "$dir/$$.cscope.out"' EXIT INT TERM +git ls-files |\ + grep -E '\.(c(pp)?|h)$' |\ + awk '{print "\""$0"\""}' |\ + cscope -R -b -i - -f "$dir/$$.cscope.out" +mv "$dir/$$.cscope.out" "$dir/cscope.out" diff --git a/.config/git/templates/hooks/ctags b/.config/git/templates/hooks/ctags new file mode 100755 index 0000000..d51e9af --- /dev/null +++ b/.config/git/templates/hooks/ctags @@ -0,0 +1,8 @@ +#!/bin/sh +set -e +PATH="/usr/local/bin:$PATH" +dir="`git rev-parse --git-dir`" +trap 'rm -f "$dir/$$.tags"' EXIT INT TERM +git ls-files | \ + ctags --tag-relative -L - -f"$dir/$$.tags" --languages=-javascript,sql +mv "$dir/$$.tags" "$dir/tags" diff --git a/.config/git/templates/hooks/gtags b/.config/git/templates/hooks/gtags new file mode 100755 index 0000000..d30547d --- /dev/null +++ b/.config/git/templates/hooks/gtags @@ -0,0 +1,9 @@ +#! /bin/sh +set -e +PATH="/usr/local/bin:$PATH" +dir="`git rev-parse --git-dir`" +trap 'rm -rf "$dir/$$.gtags/"' EXIT INT TERM +mkdir "$dir/$$.gtags" +git ls-files | \ + gtags --file=- --skip-unreadable "$dir/$$.gtags" +mv "$dir/$$.gtags"/* "$dir/.." diff --git a/.config/git/templates/hooks/post-applypatch b/.config/git/templates/hooks/post-applypatch new file mode 100755 index 0000000..dbe2120 --- /dev/null +++ b/.config/git/templates/hooks/post-applypatch @@ -0,0 +1,7 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & +.git/hooks/gtags >/dev/null 2>&1 & +.git/hooks/cscope >/dev/null 2>&1 & + + + diff --git a/.config/git/templates/hooks/post-checkout b/.config/git/templates/hooks/post-checkout new file mode 100755 index 0000000..f6c2774 --- /dev/null +++ b/.config/git/templates/hooks/post-checkout @@ -0,0 +1,4 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & +.git/hooks/gtags >/dev/null 2>&1 & +.git/hooks/cscope >/dev/null 2>&1 & diff --git a/.config/git/templates/hooks/post-commit b/.config/git/templates/hooks/post-commit new file mode 100755 index 0000000..f6c2774 --- /dev/null +++ b/.config/git/templates/hooks/post-commit @@ -0,0 +1,4 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & +.git/hooks/gtags >/dev/null 2>&1 & +.git/hooks/cscope >/dev/null 2>&1 & diff --git a/.config/git/templates/hooks/post-merge b/.config/git/templates/hooks/post-merge new file mode 100755 index 0000000..f6c2774 --- /dev/null +++ b/.config/git/templates/hooks/post-merge @@ -0,0 +1,4 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & +.git/hooks/gtags >/dev/null 2>&1 & +.git/hooks/cscope >/dev/null 2>&1 & diff --git a/.config/git/templates/hooks/post-rewrite b/.config/git/templates/hooks/post-rewrite new file mode 100755 index 0000000..fe8972d --- /dev/null +++ b/.config/git/templates/hooks/post-rewrite @@ -0,0 +1,4 @@ +#!/bin/sh +case "$1" in + rebase) exec .git/hooks/post-merge ;; +esac diff --git a/.git_template/hooks/cscope b/.git_template/hooks/cscope deleted file mode 100755 index 42f9522..0000000 --- a/.git_template/hooks/cscope +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -set -e -PATH="/usr/local/bin:$PATH" -dir="`git rev-parse --git-dir`" -trap 'rm -f "$dir/$$.cscope.out"' EXIT INT TERM -git ls-files |\ - grep -E '\.(c(pp)?|h)$' |\ - awk '{print "\""$0"\""}' |\ - cscope -R -b -i - -f "$dir/$$.cscope.out" -mv "$dir/$$.cscope.out" "$dir/cscope.out" diff --git a/.git_template/hooks/ctags b/.git_template/hooks/ctags deleted file mode 100755 index d51e9af..0000000 --- a/.git_template/hooks/ctags +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e -PATH="/usr/local/bin:$PATH" -dir="`git rev-parse --git-dir`" -trap 'rm -f "$dir/$$.tags"' EXIT INT TERM -git ls-files | \ - ctags --tag-relative -L - -f"$dir/$$.tags" --languages=-javascript,sql -mv "$dir/$$.tags" "$dir/tags" diff --git a/.git_template/hooks/gtags b/.git_template/hooks/gtags deleted file mode 100755 index d30547d..0000000 --- a/.git_template/hooks/gtags +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh -set -e -PATH="/usr/local/bin:$PATH" -dir="`git rev-parse --git-dir`" -trap 'rm -rf "$dir/$$.gtags/"' EXIT INT TERM -mkdir "$dir/$$.gtags" -git ls-files | \ - gtags --file=- --skip-unreadable "$dir/$$.gtags" -mv "$dir/$$.gtags"/* "$dir/.." diff --git a/.git_template/hooks/post-applypatch b/.git_template/hooks/post-applypatch deleted file mode 100755 index dbe2120..0000000 --- a/.git_template/hooks/post-applypatch +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -.git/hooks/ctags >/dev/null 2>&1 & -.git/hooks/gtags >/dev/null 2>&1 & -.git/hooks/cscope >/dev/null 2>&1 & - - - diff --git a/.git_template/hooks/post-checkout b/.git_template/hooks/post-checkout deleted file mode 100755 index f6c2774..0000000 --- a/.git_template/hooks/post-checkout +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -.git/hooks/ctags >/dev/null 2>&1 & -.git/hooks/gtags >/dev/null 2>&1 & -.git/hooks/cscope >/dev/null 2>&1 & diff --git a/.git_template/hooks/post-commit b/.git_template/hooks/post-commit deleted file mode 100755 index f6c2774..0000000 --- a/.git_template/hooks/post-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -.git/hooks/ctags >/dev/null 2>&1 & -.git/hooks/gtags >/dev/null 2>&1 & -.git/hooks/cscope >/dev/null 2>&1 & diff --git a/.git_template/hooks/post-merge b/.git_template/hooks/post-merge deleted file mode 100755 index f6c2774..0000000 --- a/.git_template/hooks/post-merge +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -.git/hooks/ctags >/dev/null 2>&1 & -.git/hooks/gtags >/dev/null 2>&1 & -.git/hooks/cscope >/dev/null 2>&1 & diff --git a/.git_template/hooks/post-rewrite b/.git_template/hooks/post-rewrite deleted file mode 100755 index fe8972d..0000000 --- a/.git_template/hooks/post-rewrite +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -case "$1" in - rebase) exec .git/hooks/post-merge ;; -esac diff --git a/.gitconfig b/.gitconfig deleted file mode 100644 index 4329c7e..0000000 --- a/.gitconfig +++ /dev/null @@ -1,103 +0,0 @@ -# ~/.gitconfig - -[github] - user = jannikz -[alias] - a = add - una = reset HEAD -- - uha = checkout HEAD -- - aa = add -u - unaa = reset HEAD - uhaa = reset --hard HEAD - br = branch - brdm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d" - co = checkout - go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f" - ci = commit -v - unci = reset --soft HEAD~ - amend = commit --amend - diff = diff --word-diff - dt = difftool - mt = mergetool - # dont pull without rebase, and dont push without pull (fetch & merge) - pu = pull --rebase - pp = "!git pull --rebase && git push" - # avoid merge commits - mf = merge --ff-only - cp = cherry-pick - wc = whatchanged -p - ch = cherry -v - st = status -sb - fs = "!git fetch && git status" - rb = rebase - ready = rebase -i @{u} - rbi = "!r() { git rebase -i HEAD~$1; }; r" - ec = config --global -e - l = log --oneline --decorate --reverse - lg = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph - tail = !"git lg -10 HEAD" - last = log -1 HEAD - ls = ls-files - lt = tag -l - type = cat-file -t - dump = cat-file -p - who = shortlog -s -- - remotes = remote -v - root = rev-parse --show-toplevel - cl = clone --recursive - - # Show the diff between the latest commit and the current state - d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat" - # `git di $number` shows the diff between the state `$number` revisions ago and the current state - di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d" - - # Find branches containing commit - fb = "!f() { git branch -a --contains $1; }; f" - # Find tags containing commit - ft = "!f() { git describe --always --contains $1; }; f" - # Find commits by source code - fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f" - # Find commits by commit message - fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f" - -# Credit an author on the latest commit - credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f" - # List contributors with number of commits - contributors = shortlog --summary --numbered - - k = !gitk - visual = !gitk - - ctags = "!sh -c '[ -f .git/hooks/ctags ] || git init; .git/hooks/ctags' git-ctags" - gtags = "!sh -c '[ -f .git/hooks/gtags ] || git init; .git/hooks/gtags' git-gtags" - cscope = "!sh -c '[ -f .git/hooks/cscope ] || git init; .git/hooks/cscope' git-cscope" - -[help] - autocorrect = 10 -[branch] - autosetupmerge = always - autosetuprebase = always -[rebase] - autosquash = true - autostash = true -[pull] - rebase = true -[push] - default = simple -[diff] - tool = vimdiff -[difftool] - prompt = false -[merge] - tool = vimdiff - conflictstyle = diff3 -[mergetool] - prompt = false -[init] - templatedir = ~/.git_template -[core] - excludesfile = ~/.gitignore_global - editor = vim - autocrlf = false -[include] - path = ~/.gitconfig_local