Compare commits

..

1 Commits

Author SHA1 Message Date
74a805017a Add aliases for working with autosquash rebases
* Rename the `squash` alias to `prepare` to repurpose it.
* Change `squash` alias to `git commit --squash=<commit>`.
* Add `fixup` alias to `git commit --fixup=<commit>`.
* Set the `rebase.autoSquash` config option to `true`.
2018-08-13 12:19:28 +01:00
8 changed files with 35 additions and 99 deletions

7
.conduit.yaml Normal file
View File

@@ -0,0 +1,7 @@
---
- location: ~/.config/git
- symlink:
- {src: config, dst: ~/.gitconfig}
- {src: _git-changes, dst: ~/.local/share/zsh/site-functions/_git-changes}
- repo:
- git@code.infektor.net:benie/config.git

1
.gitignore vendored
View File

@@ -1 +0,0 @@
credentials

View File

@@ -8,16 +8,19 @@ rather than remembering the plumbing term of a specific command.
* `abandon` abandons all local changes leave a clean repository. * `abandon` abandons all local changes leave a clean repository.
* `unstage` unstage staged changes, shorthand for `git reset -q HEAD --`. * `unstage` unstage staged changes, shorthand for `git reset -q HEAD --`.
* `amend` amends the last commit, shorthand for `git commit --amend`. * `amend` amends the last commit, shorthand for `git commit --amend`.
* `unamend` applies a negative diff of the last `git commit --amend`. * `fixup` prepare a fixup commit for use with
* `fixup` prepare to fixup a commit, shorthand for `git commit --fixup`. `git rebase --interactive --autosquash`, shorthand for `git commit --fixup`.
* `squash` prepare to squash a commit, shorthand for `git commit --squash`. * `squash` prepare a squash commit for use with
`git rebase --interactive --autosquash`, shorthand for `git commit --squash`.
* `prepare` prepare a branch for merging into another, shorthand for * `prepare` prepare a branch for merging into another, shorthand for
`git rebase --interactive --fork-point`. `git rebase --interactive --fork-point`.
* `list` list local branches, a shorthand for `git branch`. * `list` list local branches, a shorthand for `git branch`.
* `local` list local branches which don't have remote tracking branches.
* `create` creates a new branch, shorthand for `git checkout -b`. * `create` creates a new branch, shorthand for `git checkout -b`.
* `delete` deletes an existing branch, shorthand for `git branch -D`. * `delete` deletes an existing branch, shorthand for `git branch -D`.
* `refname` the name of the current branch. * `name` the name of the current branch.
* `last` the name of the last branch checked out before the current branch.
* `checkout-last` checkout the last branch, shorthand for
`git checkout $(git last)`.
* `publish` push and set the tracking branch of a local branch to origin, * `publish` push and set the tracking branch of a local branch to origin,
shorthand for `git push -u origin <branch>`. shorthand for `git push -u origin <branch>`.
* `unpublish` delete a remote branch, shorthand for `git push origin :<branch>`. * `unpublish` delete a remote branch, shorthand for `git push origin :<branch>`.
@@ -26,7 +29,6 @@ rather than remembering the plumbing term of a specific command.
* `changes` compare the list of commits on the local branch to another branch, * `changes` compare the list of commits on the local branch to another branch,
e.g. when on a feature branch `git changes master` lists the commits which are e.g. when on a feature branch `git changes master` lists the commits which are
not present on the master branch. not present on the master branch.
* `touched` lists the files which were touched by a selected commit.
* `save` like pushing to the stash but attached to the current branch, shorthand * `save` like pushing to the stash but attached to the current branch, shorthand
for `git commit -am "temp!"`. for `git commit -am "temp!"`.
* `load` like popping from the stash but attached to the current branch, if * `load` like popping from the stash but attached to the current branch, if

View File

@@ -1,8 +1,6 @@
#compdef git-changes #compdef git-changes
#description Compare changes on this branch with another. #description Compare changes on this branch with another.
_alternative \ _arguments '1: :__git_remote_branch_names_noprefix'
'branches::__git_branch_names' \
'remote-branches::__git_remote_branch_names'
# vim: ft=zsh # vim: ft=zsh

66
config
View File

@@ -1,93 +1,63 @@
# vim: ft=gitconfig # vim: ft=gitconfig
[alias] [alias]
root = rev-parse --show-toplevel
abandon = !git reset --hard HEAD && git clean -d -f abandon = !git reset --hard HEAD && git clean -d -f
uncommit = !git reset --soft HEAD~1 && git unstage
unstage = reset -q HEAD -- unstage = reset -q HEAD --
amend = commit --amend amend = commit --amend
unamend = !git diff $(git reflog -2 | \
awk \"{print \\$1}\" | \
sed -e ':a' -e 'N' -e '$!ba' -e 's/\\n/../g') | \
git apply - 2> /dev/null || \
echo \"\\e[31merror:\\e[39m last commit was not amended\"
fixup = commit --fixup fixup = commit --fixup
squash = commit --squash squash = commit --squash
prepare = rebase -i --fork-point prepare = rebase -i --fork-point
list = branch list = branch
local = !git branch -vv | \
cut -c 3- | \
awk '$3 !~/\\[/ { print $1 }'
recent = !git reflog show --pretty=format:'%gs ~ %gd' --date=relative | \
grep 'checkout:' | \
grep -oE '[^ ]+ ~ .*' | \
awk -F~ '!seen[$1]++' | \
head -n 10 | \
awk -F ' ~ HEAD@{' '{printf(\" %s \\033[33m%s\\033[0m\\n\", $1, substr($2, 1, length($2)-1))}'
create = checkout -b create = checkout -b
delete = branch -D delete = branch -D
refname = rev-parse --abbrev-ref HEAD name = rev-parse --abbrev-ref HEAD
last = !sh -c 'git reflog | grep \" checkout: moving from\" | head -n 1 | awk \"{ print \\$6 }\"'
checkout-last = !git checkout `git last`
publish = !git push -u `git config --get publish.remote || echo origin` `git refname` publish = !git push -u origin `git name`
unpublish = !git push -u `git config --get publish.remote || echo origin` :`git refname` unpublish = !git push -u origin :`git name`
force = push --force-with-lease force = push --force-with-lease
changes = !sh -c 'git log --oneline $1..' -- changes = !sh -c 'git log --oneline $1..' --
touched = diff-tree --no-commit-id --name-only -r tree = log --graph --abbrev-commit --oneline --decorate \
tree = log --graph --format=format:'%C(yellow)%h%C(reset) \ --format=format:'%C(yellow)%h%C(reset) %C(blue)%aD%C(reset) %C(green)(%ar)%C(reset)%C(bold)%d%C(reset)%n %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
%C(blue)%aD%C(reset) %C(green)(%ar)%C(reset)%C(bold)%d%C(reset)%n \
%C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
tracking = rev-parse --abbrev-ref --symbolic-full-name @{u}
save = commit -m "temp!" save = commit -am "temp!"
load = !sh -c '[ \"temp!\" = \"`git show --format=%s --no-patch`\" ] && \ load = !sh -c '[ \"temp!\" = \"`git show --format=%s --no-patch`\" ] && \
git reset --mixed HEAD~ || echo \"\\e[31merror:\\e[39m commit subject is not: temp!\"' git reset --mixed HEAD~ || echo \"error: commit subject is not: temp!\"'
[commit]
verbose = true
[core] [core]
editor = vim
excludesfile = ~/.config/git/excludes excludesfile = ~/.config/git/excludes
[init]
defaultBranch = main
[branch]
sort = -committerdate
[fetch] [fetch]
prune = true prune = true
[help] [help]
autocorrect = -1 autocorrect = -1
[merge]
tool = vimdiff
conflictstyle = diff3
prompt = false
[pager] [pager]
status = true status = true
[push] [push]
default = simple default = simple
[pull]
rebase = false
[rebase] [rebase]
autoSquash = true autoSquash = true
[user] [user]
useConfigOnly = true useConfigOnly = true
[diff]
tool = vimdiff
algorithm = patience
[difftool]
prompt = false
[merge]
tool = vimdiff2
algorithm = patience
[mergetool]
prompt = false
[include] [include]
path = ~/.config/private/gitconfig path = ~/.config/private/gitconfig
path = ~/.config/work/gitconfig path = ~/.config/work/gitconfig

View File

@@ -1,9 +1,3 @@
.DS_Store .local
.cache
.config
.enter .enter
.exit .exit
.local
.share
.vim
compile_commands.json

View File

@@ -1,23 +0,0 @@
#!/usr/bin/env zsh
autoload -U colors && colors
git_sync=${GIT_SYNC:-~/.config/git-sync}
if [ ! -f "$git_sync" ]; then
echo "$fg[yellow]warning:${reset_color} sync list does not exist: $git_sync"
exit 0
fi
local repos=($(cat $git_sync))
if [ ${#repos[@]} = 0 ]; then
echo "$fg[yellow]warning:${reset_color} sync list is empty: $git_sync"
exit 0
fi
for repo in $repos; do
print -P "$fg[cyan]synchronizing: $repo${reset_color}"
repo="${repo/#\~/$HOME}"
git -C "$repo" fetch
done

View File

@@ -1,11 +0,0 @@
---
- name: git create symbolic links
file:
state: link
src: '{{item.src}}'
dest: '{{item.dest}}'
with_items:
- src: ~/.config/git/_git-changes
dest: ~/.local/share/zsh/site-functions/_git-changes
- src: ~/.config/git/git-sync
dest: ~/.local/bin/git-sync