[user]
  name = laily
  email = i@laily.net
[core]
  autocrlf = input
  quotepath = false
  editor = vim
  excludesfile = ~/.dotfile/git/.gitignore
[push]
  default = current
[pull]
  rebase = false
[color]
  status = auto
  diff = auto
  branch = auto
  interactive = auto
  grep = auto
  ui = auto
[merge]
  tool = nvimdiff
[difftool "nvimdiff"]
  cmd = nvim -d \"$LOCAL\" \"$REMOTE\"
[mergetool "nvimdiff"]
  cmd = nvim -d \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
  trustExitCode = true
[includeIf "gitdir:~/workrepo/"]
  path = ~/.workgitconfig
[branch]
  autoSetupMerge = always
[alias]
  au = add -u
  co = checkout
  cm = "!f() { if [[ -z \"$1\" ]]; then git commit; else git commit -m \"$*\"; fi; }; f"
  st = status
  ap = add -p
  br = branch
  ba = branch -a
  bm = branch --merged
  bn = branch --no-merged
  pu = "!git pull origin $(git rev-parse --abbrev-ref HEAD)"
  pt = push origin --tags
  ph = push origin HEAD
  merge2 = !sh -c '_CURRENT_BRANCH=$(git symbolic-ref --short HEAD) && git checkout $1 && git merge $_CURRENT_BRANCH && git checkout $_CURRENT_BRANCH' -
  bg = "!f() { git branch | grep $1; }; f"
  delbr = "!f(){ git branch -D $(git branch | grep \"\b$1\"); };f"
  can = commit --amend --no-edit
  cleanbr = "!git branch --merged master | grep  -v '\\*\\|master\\|main' | xargs -n 1 git branch -d"
  # list files which have changed since REVIEW_BASE
  # (REVIEW_BASE defaults to 'master' in my zshrc)
  files = !git diff --name-only $(git merge-base HEAD \"$REVIEW_BASE\")
  rmsubmodule = "!f(){ git submodule deinit -f \"$1\"; git rm -f \"$1\"; git commit -m \"Removed submodule $1\"; };f"

  # Same as above, but with a diff stat instead of just names
  # (better for interactive use)
  stat = !git diff --stat $(git merge-base HEAD \"$REVIEW_BASE\")
  # Open all files changed since REVIEW_BASE in Vim tabs
  # Then, run fugitive's :Gdiff in each tab, and finally
  # tell vim-gitgutter to show +/- for changes since REVIEW_BASE
  review = !vim -p $(git files) +\"tabdo Gdiffsplit $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\"

  # Same as the above, except specify names of files as arguments,
  # instead of opening all files:
  # git reviewone foo.js bar.js
  reviewone = !vim -p +\"tabdo Gdiff $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\"
  #git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Laily'; GIT_AUTHOR_EMAIL='i@laily.net'; GIT_COMMITTER_NAME='Laily'; GIT_COMMITTER_EMAIL='i@laily.net';" HEAD
[protocol "file"]
  allow = always

# https://hyperzsb.io/posts/git-ssl-error/
