#!/bin/bash

function git-config-joshs()
{
  git config --global user.name 'Josh Holtrop'
  git config --global color.ui true
  git config --global color.diff.meta yellow
  git config --global core.excludesfile ${HOME}/.gitignore
  git config --global core.pager 'less -FRXi'
  git config --global alias.dc 'diff --cached'
  git config --global alias.lg 'log --graph --abbrev-commit --decorate --date=format:"%a %Y-%m-%d %-I:%M%P" --format=format:"%C(yellow)%h%C(reset) %C(magenta)%an%C(reset) %C(cyan)%ad%C(reset) %C(green)(%ar)%C(reset)%C(red)%d%C(reset)%n    %C(white)%s%C(reset)" --all'
  git config --global alias.lg1 'log --graph --abbrev-commit --decorate --date=format:"%a %Y-%m-%d %-I:%M%P" --format=format:"%C(yellow)%h%C(reset) %C(magenta)%an%C(reset) %C(cyan)%ad%C(reset) %C(green)(%ar)%C(reset)%C(red)%d%C(reset)%n    %C(white)%s%C(reset)"'
  git config --global alias.mergef 'merge FETCH_HEAD'
  git config --global alias.gdiff 'difftool -y -t gvimdiff'
  git config --global alias.gdiffc 'difftool -y -t gvimdiff --cached'
  git config --global alias.wdiff 'diff --word-diff=color'
  git config --global alias.mktar '!function f { name="$1"; pos="$2"; if [ "$pos" == "" ]; then pos=HEAD; fi; git archive --prefix="$name"/ "$pos" | bzip2 > ../"$name".tar.bz2; }; f'
  git config --global alias.mktarxz '!function f { name="$1"; pos="$2"; if [ "$pos" == "" ]; then pos=HEAD; fi; git archive --prefix="$name"/ "$pos" | xz > ../"$name".tar.xz; }; f'
  git config --global alias.amd 'am --committer-date-is-author-date'
  git config --global push.default upstream
  git config --global alias.bcdiff 'difftool -y -t bc'
  git config --global alias.bcdiffc 'difftool -y -t bc --cached'
  git config --global difftool.bc.cmd 'git_bcdiff "$LOCAL" "$REMOTE" "$MERGED"'
  git config --global alias.bcmerge 'mergetool -y -t bc'
  git config --global mergetool.bc.cmd \
    'git_bcmerge "$LOCAL" "$REMOTE" "$BASE" "$MERGED"'
  git config --global alias.authors '!git log --pretty="%an" | sort | uniq -c | sort -n'
  git config --global init.defaultBranch master
  # Only use configured user.name/user.email; do not guess them
  git config --global user.useConfigOnly true
  # Do not automatically mark my branch as tracking the remote branch that I
  # happened to use as the starting point.
  git config --global branch.autoSetupMerge false
  # delete all branches that have been merged to HEAD
  git config --global alias.prunebranches '!git branch --merged | grep -v '^\*' | xargs git branch -d'
}
function git-config-local-personal()
{
  local domain='gmail.com'
  git config user.email 'jholtrop@'${domain}
}
alias git-find-lost-commit='git fsck --lost-found'
git_empty_commit='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
function gitat()
{
  local timestamp="$1"
  shift
  GIT_AUTHOR_DATE="$timestamp" GIT_COMMITTER_DATE="$timestamp" git "$@"
}
