diff --git a/bin/benchmark b/bin/benchmark index 90fc31e..1219989 100755 --- a/bin/benchmark +++ b/bin/benchmark @@ -135,7 +135,7 @@ EOF ## Clean up after tests ####################### -# shellcheck disable=SC2317 +# shellcheck disable=SC2317,SC2329 _clean-up() { find . -name "test_file.*" -delete exit diff --git a/bin/test-dd-write b/bin/test-dd-write index 0953a95..5a8b0db 100755 --- a/bin/test-dd-write +++ b/bin/test-dd-write @@ -23,7 +23,7 @@ block_count_large=1024 ## Clean up after tests ####################### -# shellcheck disable=SC2317 +# shellcheck disable=SC2317,SC2329 _clean-up() { rm -f "${test_file_name}" exit diff --git a/lib/git.sh b/lib/git.sh index 343a6bc..3c6132b 100644 --- a/lib/git.sh +++ b/lib/git.sh @@ -9,16 +9,19 @@ ## then delete local and remote tracking branch ## ## @param $1 Branch to be merged +## @default current branch ## @param $2 Branch to merge into ## @default main ## @param $3 Remote ## @default origin ############################################### ggit-merge() { - local branch="${1?:Source branch missing}" + local branch="${1:-}" local into="${2:-main}" local remote="${3:-origin}" + [[ -z "${branch}" ]] && branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) + print-header Pull remote changes for "${branch}" from "${remote}" git checkout "${branch}" || return 1 git pull --stat "${remote}" "${branch}" || return 1 @@ -74,19 +77,22 @@ ggit-pull() { ## Update local branch from remote ## ## @param $1 Branch +## @default current branch ## @param $2 Remote ## @default origin ################################## ggit-update() { - local branch="${1?:Branch missing}" + local branch="${1:-}" local remote="${2:-origin}" + [[ -z "${branch}" ]] && branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) + print-header Fetch "${remote}" git fetch --prune "${remote}" || return 1 - print-header Delete old "${branch}" + print-header Delete old branch: "${branch}" git checkout -b "${branch}-temp" "${branch}" || return 1 git branch -D "${branch}" || return 1 - print-header Checkout new "${branch}" from "${remote}" + print-header Checkout new branch: "${branch}" from "${remote}" git checkout -b "${branch}" --recurse-submodules --track "${remote}/${branch}" || return 1 git branch -D "${branch}-temp" } @@ -105,17 +111,20 @@ ggit-diff() { ## Rebase branch ## ## @param $1 Branch to rebase +## @default current branch ## @param $2 Rebase onto this branch ## @default main ## @param $3 Remote ## @default origin ######################################## ggit-base() { - local branch_src=("${1?:Branch to rebase missing}") + local branch_src=("${1:-}") local branch_onto="${2:-main}" local remote="${3:-origin}" local branch + [[ -z "${branch_src[*]}" ]] && branch_src=("$(git rev-parse --abbrev-ref HEAD 2>/dev/null)") + # If more than 3 arguments supplied # last 2 arguments are branch_onto and remote the rest are branch_src if [[ $# -gt 3 ]]; then