From 17f8ca062d1683208bf85b5d7496526620c6d2b0 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 28 May 2020 13:29:49 +0200 Subject: [PATCH] [git] Clean up config formatting, color diffs Made git aliasing exit if no git executable is found (which should not happen, but still) instead of putting all aliases into the conditional. Added unified colors to git diffs. Cleaned up formatting of the files. --- git/.config/git/config | 44 +++++++----- git/.config/sh/alias.d/git.sh | 130 ++++++++++++++++++---------------- 2 files changed, 96 insertions(+), 78 deletions(-) diff --git a/git/.config/git/config b/git/.config/git/config index 709e44e..3d6be53 100644 --- a/git/.config/git/config +++ b/git/.config/git/config @@ -1,30 +1,42 @@ [user] - email = marty.oehme@gmail.com - name = Marty Oehme - signingkey = 0CCB0526EFB9611A + email = marty.oehme@gmail.com + name = Marty Oehme + signingkey = 0CCB0526EFB9611A [filter "lfs"] - clean = git-lfs clean -- %f - smudge = git-lfs smudge -- %f - process = git-lfs filter-process - required = true + clean = git-lfs clean -- %f + smudge = git-lfs smudge -- %f + process = git-lfs filter-process + required = true [alias] - ignore = "!gitignore -f" - pushmerge = "push -o merge_request.merge_when_pipeline_succeeds" # see https://docs.gitlab.com/ce/user/project/push_options.html#merge-when-pipeline-succeeds-alias + ignore = "!gitignore -f" + pushmerge = "push -o merge_request.merge_when_pipeline_succeeds" # see https://docs.gitlab.com/ce/user/project/push_options.html#merge-when-pipeline-succeeds-alias [commit] # sign commits as me - gpgsign = true + gpgsign = true # Always show diff when preparing commit message - verbose = true + verbose = true [fetch] # remove references to non-existent remote branches - prune = true + prune = true [pull] - rebase = true # always rebase on pulling, obviates merge commits + rebase = true # always rebase on pulling, obviates merge commits [diff] - colorMoved = zebra # also color stuff that has simply been moved, in a classy zebra-color + colorMoved = zebra # also color stuff that has simply been moved, in a classy zebra-color +[color.diff] + meta = "9" + frag = "magenta bold" + commit = "yellow bold" + old = "red bold" + new = "green bold" + whitespace = "red reverse" +[color.diff-highlight] + oldNormal = "red bold" + oldHighlight = "red bold 52" + newNormal = "green bold" + newHighlight = "green bold 22" [rebase] - autostash = true - autoSquash = true + autostash = true + autoSquash = true # Make use of git urls for git{lab,hub}, but only do so for pushing # since pulling will create troubles with some applications [url "git@github.com:"] diff --git a/git/.config/sh/alias.d/git.sh b/git/.config/sh/alias.d/git.sh index df18680..0d260bb 100644 --- a/git/.config/sh/alias.d/git.sh +++ b/git/.config/sh/alias.d/git.sh @@ -1,65 +1,71 @@ #!/usr/bin/env sh -# git alias -if exist git; then - alias g='git' - - alias ga='git add' - alias gaa='git add --all' - alias gai='git add -i' - alias gb='git branch' - alias gbd='git branch -d' - - alias gc='git commit -v' - alias gc!='git commit -v --amend' - alias gcn!='git commit -v --no-edit --amend' - - alias gcm='git checkout master' - alias gcd='git checkout develop' - alias gcb='git checkout -b' - alias gco='git checkout' - - alias gd='git diff' - alias gds='git diff --staged' - - alias gi='git ignore' - - alias glog='git log --stat' - alias glg='git log --oneline --decorate --graph' - alias glga='git log --oneline --decorate --graph --remotes --all' - alias glgp='git log --stat -p' - - alias gf='git fetch' - alias gl='git pull' - - alias gpn='git push --dry-run' - alias gp='git push' - alias gpf!='git push --force' - alias gpm='git pushmerge' - - alias grv='git remote -v' - - alias grs='git restore --staged' - alias grs!='git restore' - - alias grbi='git rebase -i' - alias grbc='git rebase --continue' - - alias gst='git status' - - # if git is at least version 2.13, we can use git stash push - # in shells other than zsh, simply fall back to save - case "$(ps -cp "$$" -o command="")" in - *zsh*) - autoload -Uz is-at-least - if is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')"; then - alias gsta='git stash push' - else - alias gsta='git stash save' - fi - ;; - *) alias gsta='git stash save' ;; - esac - alias gstp='git stash pop' - alias gstl='git stash list' +if ! exist git; then + return 1 fi + +# git alias + +alias g='git' + +alias ga='git add' +alias gaa='git add --all' +alias gai='git add -i' +alias gb='git branch' +alias gbd='git branch -d' + +alias gc='git commit -v' +alias gc!='git commit -v --amend' +alias gcn!='git commit -v --no-edit --amend' + +alias gcm='git checkout master' +alias gcd='git checkout develop' +alias gcb='git checkout -b' +alias gco='git checkout' + +alias gd='git diff' +alias gds='git diff --staged' + +alias gi='git ignore' + +alias glog='git log --stat' +alias glg='git log --oneline --decorate --graph' +alias glga='git log --oneline --decorate --graph --remotes --all' +alias glgp='git log --stat -p' + +alias gf='git fetch' +alias gl='git pull' + +alias gpn='git push --dry-run' +alias gp='git push' +alias gpf!='git push --force' +alias gpm='git pushmerge' + +alias grv='git remote -v' + +alias grs='git restore --staged' +alias grs!='git restore' + +alias grbi='git rebase -i' +alias grbc='git rebase --continue' +alias grbm='git rebase master' + +alias gst='git status' + +# if git is at least version 2.13, we can use git stash push +# in shells other than zsh, simply fall back to save +case "$(ps -cp "$$" -o command="")" in +*zsh*) + autoload -Uz is-at-least + if is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')"; then + alias gsta='git stash push' + else + alias gsta='git stash save' + fi + ;; +*) alias gsta='git stash save' ;; +esac +alias gstp='git stash pop' +alias gstl='git stash list' +alias gstL='git stash list --stat' +