Compare commits
1 Commits
main
...
f2b8731770
| Author | SHA1 | Date | |
|---|---|---|---|
| f2b8731770 |
7
.conduit.yaml
Normal file
7
.conduit.yaml
Normal 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
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
credentials
|
||||
local
|
||||
14
README.md
14
README.md
@@ -8,16 +8,19 @@ rather than remembering the plumbing term of a specific command.
|
||||
* `abandon` abandons all local changes leave a clean repository.
|
||||
* `unstage` unstage staged changes, shorthand for `git reset -q HEAD --`.
|
||||
* `amend` amends the last commit, shorthand for `git commit --amend`.
|
||||
* `unamend` applies a negative diff of the last `git commit --amend`.
|
||||
* `fixup` prepare to fixup a commit, shorthand for `git commit --fixup`.
|
||||
* `squash` prepare to squash a commit, shorthand for `git commit --squash`.
|
||||
* `fixup` prepare a fixup commit for use with `git rebase --autosquash`,
|
||||
shorthand for `git commit --fixup=<commit>`.
|
||||
* `squash` prepare a squash commit for use with `git rebase --autosquash`,
|
||||
shorthand for `git commit --squash=<commit>`.
|
||||
* `prepare` prepare a branch for merging into another, shorthand for
|
||||
`git rebase --interactive --fork-point`.
|
||||
* `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`.
|
||||
* `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,
|
||||
shorthand for `git push -u 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,
|
||||
e.g. when on a feature branch `git changes master` lists the commits which are
|
||||
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
|
||||
for `git commit -am "temp!"`.
|
||||
* `load` like popping from the stash but attached to the current branch, if
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#compdef git-changes
|
||||
#description Compare changes on this branch with another.
|
||||
|
||||
_alternative \
|
||||
'branches::__git_branch_names' \
|
||||
'remote-branches::__git_remote_branch_names'
|
||||
_arguments '1: :__git_remote_branch_names_noprefix'
|
||||
|
||||
# vim: ft=zsh
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#compdef git-ls-ignored
|
||||
#description List files which exist and are ignored by this repository.
|
||||
|
||||
# Offer the paths the script would actually list, so the candidates match its
|
||||
# rules rather than the --exclude-standard set used by zsh's own
|
||||
# __git_ignored_other_files. _multi_parts descends one component at a time, so
|
||||
# a directory holding ignored files completes as a way to narrow the listing.
|
||||
__git-ls-ignored_files() {
|
||||
local common_dir expl
|
||||
local -a excludes files
|
||||
|
||||
if (( $+opt_args[-g] + $+opt_args[--global] )); then
|
||||
excludes=(--exclude-standard)
|
||||
else
|
||||
common_dir=$(_call_program common-dir git rev-parse --git-common-dir 2>/dev/null)
|
||||
[[ -n $common_dir ]] || return 1
|
||||
[[ $common_dir == /* ]] || common_dir=$PWD/$common_dir
|
||||
excludes=(--exclude-per-directory=.gitignore)
|
||||
[[ -f $common_dir/info/exclude ]] &&
|
||||
excludes+=(--exclude-from=$common_dir/info/exclude)
|
||||
fi
|
||||
|
||||
files=(${(0)"$(_call_program ignored-files git ls-files -z --others --ignored \
|
||||
${(q)excludes} 2>/dev/null)"})
|
||||
(( $#files )) || return 1
|
||||
|
||||
_wanted ignored-files expl 'ignored file' _multi_parts -f - / files
|
||||
}
|
||||
|
||||
_git-ls-ignored() {
|
||||
_arguments -s -S \
|
||||
'(-d --directory)'{-d,--directory}'[list an ignored directory by name instead of its contents]' \
|
||||
'(-g --global)'{-g,--global}'[also apply the global core.excludesfile]' \
|
||||
'(-z)-z[terminate entries with NUL instead of newline]' \
|
||||
'(- *)'{-h,--help}'[show usage information]' \
|
||||
'*:pathspec:__git-ls-ignored_files'
|
||||
}
|
||||
|
||||
_git-ls-ignored "$@"
|
||||
|
||||
# vim: ft=zsh
|
||||
70
config
70
config
@@ -1,97 +1,63 @@
|
||||
# vim: ft=gitconfig
|
||||
|
||||
[alias]
|
||||
root = rev-parse --show-toplevel
|
||||
|
||||
abandon = !git reset --hard HEAD && git clean -d -f
|
||||
uncommit = !git reset --soft HEAD~1 && git unstage
|
||||
unstage = reset -q HEAD --
|
||||
|
||||
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 "\\\\033[31merror:\\\\033[39m last commit was not amended"
|
||||
fixup = commit --fixup
|
||||
squash = commit --squash
|
||||
prepare = rebase -i --fork-point
|
||||
|
||||
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
|
||||
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`
|
||||
unpublish = !git push -u `git config --get publish.remote || echo origin` :`git refname`
|
||||
publish = !git push -u origin `git name`
|
||||
unpublish = !git push -u origin :`git name`
|
||||
force = push --force-with-lease
|
||||
|
||||
changes = !sh -c 'git log --oneline $1..' --
|
||||
touched = diff-tree --no-commit-id --name-only -r
|
||||
tree = log --graph --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)'
|
||||
tracking = rev-parse --abbrev-ref --symbolic-full-name @{u}
|
||||
tree = log --graph --abbrev-commit --oneline --decorate \
|
||||
--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)'
|
||||
|
||||
save = commit -m "temp!"
|
||||
save = commit -am "temp!"
|
||||
load = !sh -c '[ \"temp!\" = \"`git show --format=%s --no-patch`\" ] && \
|
||||
git reset --mixed HEAD~ || echo \"\\033[31merror:\\033[39m commit subject is not: temp!\"'
|
||||
git reset --mixed HEAD~ || echo \"error: commit subject is not: temp!\"'
|
||||
|
||||
[commit]
|
||||
verbose = true
|
||||
|
||||
[core]
|
||||
editor = vim
|
||||
excludesfile = ~/.config/git/excludes
|
||||
|
||||
[init]
|
||||
defaultBranch = main
|
||||
|
||||
[branch]
|
||||
sort = -committerdate
|
||||
|
||||
[fetch]
|
||||
prune = true
|
||||
|
||||
[help]
|
||||
autocorrect = -1
|
||||
|
||||
[merge]
|
||||
tool = vimdiff
|
||||
conflictstyle = diff3
|
||||
prompt = false
|
||||
|
||||
[pager]
|
||||
status = true
|
||||
|
||||
[push]
|
||||
default = simple
|
||||
|
||||
[pull]
|
||||
rebase = false
|
||||
|
||||
[rebase]
|
||||
autoSquash = true
|
||||
|
||||
[user]
|
||||
useConfigOnly = true
|
||||
|
||||
[diff]
|
||||
tool = vimdiff
|
||||
algorithm = patience
|
||||
[difftool]
|
||||
prompt = false
|
||||
|
||||
[merge]
|
||||
tool = vimdiff2
|
||||
algorithm = patience
|
||||
[mergetool]
|
||||
prompt = false
|
||||
|
||||
[include]
|
||||
path = ~/.config/private/gitconfig
|
||||
path = ~/.config/work/gitconfig
|
||||
path = ~/.config/git/local
|
||||
|
||||
[advice]
|
||||
skippedCherryPicks = false
|
||||
|
||||
8
excludes
8
excludes
@@ -1,9 +1,3 @@
|
||||
.DS_Store
|
||||
.cache
|
||||
.config
|
||||
.local
|
||||
.enter
|
||||
.exit
|
||||
.local
|
||||
.share
|
||||
.vim
|
||||
compile_commands.json
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Find local branches that have been squash-merged into a target branch.
|
||||
# Usage: git-find-merged [target-branch]
|
||||
# Default target branch: main
|
||||
|
||||
target="${1:-main}"
|
||||
|
||||
git for-each-ref refs/heads/ --format='%(refname:short)' | while read branch; do
|
||||
[[ "$branch" == "$target" ]] && continue
|
||||
merge_base=$(git merge-base "$target" "$branch" 2>/dev/null) || continue
|
||||
tree=$(git rev-parse "$branch^{tree}" 2>/dev/null) || continue
|
||||
squash_commit=$(git commit-tree "$tree" -p "$merge_base" -m "test" 2>/dev/null) || continue
|
||||
cherry_result=$(git cherry "$target" "$squash_commit" 2>/dev/null)
|
||||
if [[ "$cherry_result" == "-"* ]]; then
|
||||
echo "$branch"
|
||||
fi
|
||||
done
|
||||
@@ -1,77 +0,0 @@
|
||||
#!/bin/bash
|
||||
# List files which exist in the working tree and are ignored by this
|
||||
# repository's own rules: any .gitignore file, plus $GIT_DIR/info/exclude.
|
||||
#
|
||||
# Unlike `git status --ignored`, the global core.excludesfile is not consulted
|
||||
# unless --global is given, so the output only contains paths this repository
|
||||
# chose to ignore.
|
||||
#
|
||||
# Works inside a linked worktree, where .git is a file and info/exclude lives in
|
||||
# the common git directory rather than next to the worktree.
|
||||
#
|
||||
# Usage: git-ls-ignored [<options>] [--] [<pathspec>...]
|
||||
#
|
||||
# -d, --directory list an ignored directory by name instead of its contents
|
||||
# -g, --global also apply the global core.excludesfile
|
||||
# -z terminate entries with NUL instead of newline
|
||||
# -h, --help show this message
|
||||
#
|
||||
# Paths are relative to the top of the working tree. Without a <pathspec> the
|
||||
# whole working tree is listed, not just the current directory.
|
||||
|
||||
# Print the comment block above, minus the shebang, as the help text.
|
||||
usage() {
|
||||
awk 'NR == 1 { next } /^#/ { sub(/^# ?/, ""); print; next } { exit }' "$0"
|
||||
}
|
||||
|
||||
global=false
|
||||
options=()
|
||||
paths=()
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-d | --directory) options+=(--directory) ;;
|
||||
-g | --global) global=true ;;
|
||||
-z) options+=(-z) ;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
paths+=("$@")
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
echo "error: unknown option: $1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
*) paths+=("$1") ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# In a worktree .git is a file pointing at .git/worktrees/<name>, which has no
|
||||
# info/exclude of its own; Git reads the one in the common directory, so that is
|
||||
# the file to point --exclude-from at. The common directory is reported relative
|
||||
# to the current directory unless it happens to be absolute.
|
||||
common_dir=$(git rev-parse --git-common-dir) || exit $?
|
||||
case "$common_dir" in
|
||||
/*) ;;
|
||||
*) common_dir="$PWD/$common_dir" ;;
|
||||
esac
|
||||
|
||||
if $global; then
|
||||
# .gitignore, info/exclude and core.excludesfile.
|
||||
excludes=(--exclude-standard)
|
||||
else
|
||||
excludes=(--exclude-per-directory=.gitignore)
|
||||
# --exclude-from is fatal on a missing file, and info/exclude is optional.
|
||||
if [ -f "$common_dir/info/exclude" ]; then
|
||||
excludes+=("--exclude-from=$common_dir/info/exclude")
|
||||
fi
|
||||
fi
|
||||
|
||||
git ls-files --others --ignored --full-name "${excludes[@]}" "${options[@]}" \
|
||||
-- "${paths[@]:-:/}"
|
||||
23
git-sync
23
git-sync
@@ -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
|
||||
34
install.sh
34
install.sh
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
symlink() {
|
||||
local source=$1
|
||||
local dest=$2
|
||||
mkdir -p $(dirname $dest)
|
||||
if [ -L $dest ]; then
|
||||
local target=`readlink $dest`
|
||||
if [ "$target" != "$source" ]; then
|
||||
rm $dest
|
||||
ln -s $source $dest
|
||||
echo changed replace incorrect symlink $dest
|
||||
fi
|
||||
elif [ -f $dest ]; then
|
||||
error symlink failed $dest exists but is a regular file
|
||||
else
|
||||
ln -s $source $dest
|
||||
echo changed created symlink $dest
|
||||
fi
|
||||
}
|
||||
|
||||
symlink ~/.config/git/_git-changes \
|
||||
~/.local/share/zsh/site-functions/_git-changes
|
||||
|
||||
symlink ~/.config/git/git-sync \
|
||||
~/.local/bin/git-sync
|
||||
|
||||
symlink ~/.config/git/git-find-merged \
|
||||
~/.local/bin/git-find-merged
|
||||
|
||||
symlink ~/.config/git/git-ls-ignored \
|
||||
~/.local/bin/git-ls-ignored
|
||||
symlink ~/.config/git/_git-ls-ignored \
|
||||
~/.local/share/zsh/site-functions/_git-ls-ignored
|
||||
11
tasks.yaml
11
tasks.yaml
@@ -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
|
||||
Reference in New Issue
Block a user