From 73131b086f21fa6a58ed9f8e73882ea0ca92d9c1 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Sun, 30 Oct 2022 13:43:18 +0000 Subject: [PATCH] aliases: git: gfrb/gfrbi defaults to defbranch Much like how `git pull` will default to the remote tracking branch if called with no arguments, gfrb and gfrbi will fetch and rebase from the "default" branch according to git defbranch. Signed-off-by: Joe Groocock --- aliases | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aliases b/aliases index 99f016c..ea7ba98 100644 --- a/aliases +++ b/aliases @@ -138,9 +138,9 @@ alias grba="grb --abort" alias grbc="grb --continue" alias grbsk="grb --skip" alias grbsh="grb --show-current" -alias grbom="git rebase \"origin/\$(git defbranch)\"" -gfrb() { remote="${1%/*}"; git fetch "$remote" && git rebase "$@"; } -gfrbi() { remote="${1%/*}"; git fetch "$remote" && git rebase -i "$@"; } +alias grbom="git rebase \"origin/\$(git defbranch origin)\"" +gfrb() { ref="${1:-origin/$(git defbranch origin)}"; remote="${ref%%/*}"; git fetch "$remote" && git rebase "$ref" "${@:2}"; } +gfrbi() { ref="${1:-origin/$(git defbranch origin)}"; remote="${ref%%/*}"; git fetch "$remote" && git rebase -i "$ref" "${@:2}"; } alias gam="git am" alias gama="git am --abort"