zsh:git-commit-last-msg(): Support additional args

Pass additional arguments to git-commit so that flags can be passed
e.g `-n` to bypass the commit hooks.
Also use the according completion for `git-commit-last-msg`.
This commit is contained in:
2021-07-07 11:50:52 +02:00
parent 53ae5a067e
commit 4606f9ad80
2 changed files with 3 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ compdef nvim-man=man
# Copy git completion for arguments # Copy git completion for arguments
compdef _git-log glog compdef _git-log glog
compdef _git-checkout git-checkout-worktree compdef _git-checkout git-checkout-worktree
compdef _git-commit git-commit-last-msg
# Run git's completion once to avoid a `command not found` error when using the # Run git's completion once to avoid a `command not found` error when using the
# completion functions on other programs without having completed something for # completion functions on other programs without having completed something for
# git before in the same session. # git before in the same session.

View File

@@ -364,10 +364,11 @@ cd() {
# the first comment of the file. # the first comment of the file.
# Useful for example when the commit-msg hook fails but only slight # Useful for example when the commit-msg hook fails but only slight
# modifications are needed. # modifications are needed.
# Additional arguments (for example `-n` to bypass the hooks) can be passed.
git-commit-last-msg() { git-commit-last-msg() {
local gitdir local gitdir
gitdir="$(git rev-parse --git-dir)" || return gitdir="$(git rev-parse --git-dir)" || return
git commit -eF <(sed -n '/^#/q;p' "$gitdir/COMMIT_EDITMSG") git commit -eF <(sed -n '/^#/q;p' "$gitdir/COMMIT_EDITMSG") "$@"
} }
nvim-man() { nvim-man() {