From 66939c71da756c1d9e07a88a4a8ea2a018650060 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 17 Sep 2023 11:17:56 -0400 Subject: add support for git-branchless --- bin/git/git-amend | 13 +++++++++++++ bin/git/git-record | 13 +++++++++++++ config/git/config | 6 +++--- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 bin/git/git-amend create mode 100755 bin/git/git-record diff --git a/bin/git/git-amend b/bin/git/git-amend new file mode 100755 index 0000000..3b937ec --- /dev/null +++ b/bin/git/git-amend @@ -0,0 +1,13 @@ +#!/bin/sh +set -eu + +if [ -e "$(git root)/.git/branchless" ]; then + exec git branchless amend "$@" +else + if [ "${1:-}" = "-i" ]; then + git add -p + else + git add -u + fi + git commit --amend +fi diff --git a/bin/git/git-record b/bin/git/git-record new file mode 100755 index 0000000..eaa36c9 --- /dev/null +++ b/bin/git/git-record @@ -0,0 +1,13 @@ +#!/bin/sh +set -eu + +if [ -e "$(git root)/.git/branchless" ]; then + exec git branchless record "$@" +else + if [ "${1:-}" = "-i" ]; then + git add -p + else + git add -u + fi + git commit +fi diff --git a/config/git/config b/config/git/config index 1406069..b8092d8 100644 --- a/config/git/config +++ b/config/git/config @@ -4,7 +4,7 @@ [alias] aliases = !git config --get-regexp 'alias.*' | perl -nle'/^alias\\.([^ ]*) (.*)/ && printf \"%-15s = %s\\n\", $1, $2' alias = "!f() { local name=$1; shift; git config --global alias.$name \"$*\"; }; f" - amend = !git add -p && git commit --amend + amend = !~/.bin/git/git-amend bda = "!f() { git branch --merged $(git default-branch) --format='%(refname:short)' | grep -v \"^$(git default-branch)$\" | xargs -r git branch -d; }; f" blame-stats = !~/.bin/git/git-blame-stats br = for-each-ref --sort=committerdate refs/heads/ --format='%(align:30,left)%(HEAD) %(refname:short)%(end) %(color:magenta)(%(committerdate:relative))' @@ -21,7 +21,7 @@ lg = log --graph --pretty=format:'%Cred%h%Creset%C(yellow)%d%Creset %C(bold blue)%aN%Creset %C(magenta)(%ar)%Creset%n%s%n' --abbrev-commit --date=relative --stat=72 pr = !~/.bin/git/git-pr prune-all = !git remote | xargs -n 1 git remote prune - record = !git add -p && git commit --verbose + record = !~/.bin/git/git-record refix = "!f() { env EDITOR=true git rebase -i \"$@\"; }; f" re = rebase -i @{u} ri = rebase -i @@ -30,7 +30,7 @@ stashed = stash list --pretty=format:'%<(10)%gd: %Cred%h%Creset %Cgreen(%ar)%Creset%n %s' st = status -sb start = "!f() { git commit --allow-empty -m 'initial commit' && git add . && git commit -m 'project skeleton'; }; f" - track = "!f() { local name=$(git name-rev --name-only @); git branch --set-upstream-to=origin/$name $name; }; f" + track = "!f() { local name=$(git name-rev --name-only --exclude='branchless/*' @); git branch --set-upstream-to=origin/$name $name; }; f" [github] user = doy [color] -- cgit v1.2.3-54-g00ecf