From 1ee41e1c5bb6bd9a2c224bf91a5dc6aba46703f4 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Sun, 20 Jul 2025 03:25:46 +0200 Subject: [PATCH] vim:keys: Reference commits w/ --pretty=reference Use git's preferred way of referencing commits (`--pretty=reference`) instead of the kernel's (`--pretty='%h ("%s")'`). I can see that specifying the date makes sense and that the quotes are at best unnecessary in the parentheses and at worst confusing when the subject contains quotes itself. Link: https://git-scm.com/docs/SubmittingPatches#describe-changes --- .config/vim/vimrc.d/40-keys.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index 04b3be4..0610ded 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -140,12 +140,14 @@ nnoremap gp '`[' . strpart(getregtype(), 0, 1) . '`]' " Git bindings -" Insert a commit's subject behind the SHA1 that the cursor is currently on. -" Mnemonic: "git reference commit" +" Reference the commit that the cursor is currently on with the 'reference' +" format (Mnemonic: "git reference commit"). +" NOTE: I can't use --pretty=reference since it would insert the abbreviated +" hash additionally to the existing hash. " NOTE: This uses `system` and not `:r!` to insert the text directly at the -" cursor. `subject[:-2]` cuts off the trailing newline. +" cursor. `subject[:-1]` cuts off the trailing newline. " TODO: print error message but insert nothing on git error -nmap grc :let subject=system('git show -s --format="(\"%s\")" ')viwa =subject[:-2] +nmap grc :let subject=system('git show -s --date=short --pretty="format:(%s, %ad)" ')viwa =subject[:-1] " Insert a Signed-off-by trailer nmap gso :r!git config --get user.name:r!git config --get user.emailI<A>kJISigned-off-by: