From 53710c2622daa3496dbf7cc0b4674745117e57f2 Mon Sep 17 00:00:00 2001 From: kalmenn Date: Sat, 23 Dec 2023 16:20:03 +0100 Subject: [PATCH 01/10] git lg: disable annoying line wrap --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 001a3ad..17423e1 100644 --- a/config +++ b/config @@ -49,7 +49,7 @@ # custom git log (always opens in pager) lg = "!f() { \ git lgi $@ | \ - less -cr; \ + less --clear-screen --RAW-CONTROL-CHARS --chop-long-lines; \ }; f" # Inspired by, then evolved from: From 34655c2acf450686004433d2f2cb35a9e96f6868 Mon Sep 17 00:00:00 2001 From: kalmenn Date: Sat, 23 Dec 2023 16:21:42 +0100 Subject: [PATCH 02/10] git lgi: changed colors of gpg output --- config | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config b/config index 17423e1..3694f47 100644 --- a/config +++ b/config @@ -34,15 +34,15 @@ # sed part courtesy of: https://stackoverflow.com/questions/17371955/verifying-signed-git-commits/32038784#comment124980964_32038784 lgi = "!f() { \ git log --graph --branches --all --date=human --color $@ \ - --format='%C(bold dim green)%h%C(auto) - %C(yellow)%<(12)%cr %C(bold)→%C(reset) %s%C(dim white) - %an %C(bold green)%G?%GS%C(reset cyan)%d%C(reset)' | \ + --format='%C(bold dim green)%h%C(auto) - %C(yellow)%<(12)%cr %C(bold)→%C(reset) %s%C(dim white) - %an %G?%C(reset dim green)%GS%C(reset cyan)%d%C(reset)' | \ sed \ - -e 's#G#Good Signature: #' \ - -e 's#B#\\x1b[31mBAD#' \ - -e 's#U#\\x1b[33mUnknown Trust: #' \ - -e 's#X#Good | Expired#' \ - -e 's#Y#\\x1b[33mExpired Key#' \ - -e 's#R#\\x1b[31mRevoked#' \ - -e 's#E#\\x1b[33mMissing Key#' \ + -e 's#G#\\x1b[1;32mGood Signature: #' \ + -e 's#B#\\x1b[1;31mBAD#' \ + -e 's#U#\\x1b[1;33mUnknown Trust: #' \ + -e 's#X#\\x1b[1;32mGood (later expired)#' \ + -e 's#Y#\\x1b[1;33mExpired Key#' \ + -e 's#R#\\x1b[1;31mRevoked#' \ + -e 's#E#\\x1b[1;33mMissing Key#' \ -e 's#N##'; \ }; f" From cac0da5998e1373af2f75b98e74d92d7048f8b78 Mon Sep 17 00:00:00 2001 From: kalmenn Date: Sat, 23 Dec 2023 18:03:12 +0100 Subject: [PATCH 03/10] identity: first implementation of the include subcommand --- scripts/identity.sh | 49 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/scripts/identity.sh b/scripts/identity.sh index a5f9acc..323322b 100755 --- a/scripts/identity.sh +++ b/scripts/identity.sh @@ -4,6 +4,12 @@ no_home_identities=".local/share/git/identities" identities="$HOME/$no_home_identities"; mkdir -p "$identities"; +if [ ! -z "$(git config core.editor)" ]; then + EDITOR="$(git config core.editor)"; +elif [ ! -z "$GIT_EDITOR" ]; then + EDITOR="$GIT_EDITOR"; +fi + function yes_or_no { # courtesy of: https://stackoverflow.com/a/29436423 while true; do read -p "$* [y/n]: " yn; @@ -128,7 +134,7 @@ case $1 in echo; echo "Copies the config from an identity to the local git config."; echo "Using set instead of link essentially means that future changes made to the identity will not be synced with the local git config."; - echo "If you wish for that be the case, you can manually include the identity in your local git config like so:"; + echo "If you wish for that be the case, consider using the include subcommand instead."; echo; echo "[include]"; echo " path = ~/$no_home_identities/" @@ -144,6 +150,44 @@ case $1 in [ ! -z "$email" ] && git config user.email "$email"; [ ! -z "$sigkey" ] && git config user.signingKey "$sigkey"; ;; + include) + if [ -z "$2" ]; then + echo "USAGE:"; + echo; + echo " git identity include "; + echo; + echo "Takes the path of the file in which the identity is defined and includes it in your local git config."; + echo "This means that any changes made to the identity will be kept in sync in this local confif, risking a loss of consistency for the identity that's shown in your commits." + exit 1; + fi + + get_identity "$2"; + + echo "Using this identity:"; + display_identity "$identity"; + echo; + + git_config="$GIT_DIR/config"; + + echo "Writing to $git_config"; + echo; + + echo -e "[include]\n path = ~/$no_home_identities/$identity" >> "$git_config"; + + res=0; + + set -m; + + #while [ "$res" -eq 0 ]; do # TODOOOOOOOOOOOO + echo "Your new identity is:"; + display_parts "" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)"; + yes_or_no "Is this good (otherwise, review the config)"; + res=$?; + if [ "$res" -eq 1 ]; then + $EDITOR "$git_config"; + fi + #done + ;; show) if [ -z "$2" ]; then display_parts "current" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)"; @@ -163,7 +207,8 @@ case $1 in echo " import: Imports an identity from a gpg key"; echo " remove: Removes a saved identity"; echo " set: Sets the identity of the current git repo"; - echo " show: Show a saved identity or the identity of the current repo"; + echo " include: Includes the identity file in your local git config" + echo " show: Show a saved identity or the identity that's currently effective"; echo " list: List all saved identities"; exit 1; ;; From 971a126276f6de1d4ef7ec2fb71a7f5ccecb9ec8 Mon Sep 17 00:00:00 2001 From: kale Date: Tue, 26 Dec 2023 18:09:11 +0100 Subject: [PATCH 04/10] identity: allowed displaying an identity with an empty first field --- scripts/identity.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/identity.sh b/scripts/identity.sh index 323322b..652f651 100755 --- a/scripts/identity.sh +++ b/scripts/identity.sh @@ -34,8 +34,11 @@ function display_parts() { local email="$3"; local sigkey="$4"; - printf "[$identity] $name <$email>"; - if [ ! -z $sigkey ]; then + if [ ! -z "$identity" ]; then + printf "[$identity] "; + fi + printf "$name <$email>"; + if [ ! -z "$sigkey" ]; then printf " (signing key: $sigkey)"; fi printf "\n"; @@ -190,7 +193,7 @@ case $1 in ;; show) if [ -z "$2" ]; then - display_parts "current" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)"; + display_parts "" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)"; else get_identity "$2"; display_identity "$identity"; From 8e88602784ecfcbb8405a33b3fd5498b76dcc25b Mon Sep 17 00:00:00 2001 From: kale Date: Wed, 10 Jan 2024 02:03:34 +0100 Subject: [PATCH 05/10] enable non ASCII characters in path names --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index 3694f47..8b20ddb 100644 --- a/config +++ b/config @@ -10,6 +10,7 @@ [core] editor = nvim + quotepath = off [init] defaultBranch = main From 26c869b714608dcf156cdca08c4174d3280179bb Mon Sep 17 00:00:00 2001 From: kale Date: Wed, 10 Jan 2024 11:55:59 +0100 Subject: [PATCH 06/10] New colors for git lgi and lg. Also, now refs come before gpg output --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 8b20ddb..8470692 100644 --- a/config +++ b/config @@ -35,7 +35,7 @@ # sed part courtesy of: https://stackoverflow.com/questions/17371955/verifying-signed-git-commits/32038784#comment124980964_32038784 lgi = "!f() { \ git log --graph --branches --all --date=human --color $@ \ - --format='%C(bold dim green)%h%C(auto) - %C(yellow)%<(12)%cr %C(bold)→%C(reset) %s%C(dim white) - %an %G?%C(reset dim green)%GS%C(reset cyan)%d%C(reset)' | \ + --format='%C(bold dim green)%h%C(auto) - %C(yellow)%<(12)%cr %C(bold)→%C(reset) %s%C(bold black) - %an%C(reset bold yellow)%d %C(reset)%G?%C(reset dim white)%GS%C(reset)' | \ sed \ -e 's#G#\\x1b[1;32mGood Signature: #' \ -e 's#B#\\x1b[1;31mBAD#' \ From 5768c236c5e60502d809d357c765eb0bb939729d Mon Sep 17 00:00:00 2001 From: kalmenn Date: Tue, 16 Jan 2024 02:00:54 +0100 Subject: [PATCH 07/10] git lgi: remove padding after date --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 8470692..30e7b50 100644 --- a/config +++ b/config @@ -35,7 +35,7 @@ # sed part courtesy of: https://stackoverflow.com/questions/17371955/verifying-signed-git-commits/32038784#comment124980964_32038784 lgi = "!f() { \ git log --graph --branches --all --date=human --color $@ \ - --format='%C(bold dim green)%h%C(auto) - %C(yellow)%<(12)%cr %C(bold)→%C(reset) %s%C(bold black) - %an%C(reset bold yellow)%d %C(reset)%G?%C(reset dim white)%GS%C(reset)' | \ + --format='%C(bold dim green)%h%C(auto) - %C(yellow)%cr %C(bold)→%C(reset) %s%C(bold black) - %an%C(reset bold yellow)%d %C(reset)%G?%C(reset dim white)%GS%C(reset)' | \ sed \ -e 's#G#\\x1b[1;32mGood Signature: #' \ -e 's#B#\\x1b[1;31mBAD#' \ From 9264ed5aed416ace42e563ab643576f60c0f272e Mon Sep 17 00:00:00 2001 From: kale Date: Tue, 27 Feb 2024 01:47:44 +0100 Subject: [PATCH 08/10] lg: Only show signer's name for signed commits --- config | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/config b/config index 30e7b50..23b8b94 100644 --- a/config +++ b/config @@ -32,19 +32,22 @@ s = "status" # custom git log (inline) - # sed part courtesy of: https://stackoverflow.com/questions/17371955/verifying-signed-git-commits/32038784#comment124980964_32038784 lgi = "!f() { \ git log --graph --branches --all --date=human --color $@ \ - --format='%C(bold dim green)%h%C(auto) - %C(yellow)%cr %C(bold)→%C(reset) %s%C(bold black) - %an%C(reset bold yellow)%d %C(reset)%G?%C(reset dim white)%GS%C(reset)' | \ + --format='%C(bold dim green)%h%C(auto) - %C(yellow)%cr %C(bold)→%C(reset) %s%C(reset bold yellow)%d %an %G? %GS %C(reset)' | \ sed \ - -e 's#G#\\x1b[1;32mGood Signature: #' \ + -e 's#\\(.*\\) N .*#\\x1b[0;2;3m- \\1#' \ + \ + -e 's#.* \\([^N]\\)#\\1#' \ + -e 's#\\(.*\\)#\\x1b[0;2;3m\\1#' \ + \ + -e 's#G#\\x1b[0;1;32mGood Signature:#' \ -e 's#B#\\x1b[1;31mBAD#' \ -e 's#U#\\x1b[1;33mUnknown Trust: #' \ - -e 's#X#\\x1b[1;32mGood (later expired)#' \ + -e 's#X#\\x1b[1;32mGood (expired since)#' \ -e 's#Y#\\x1b[1;33mExpired Key#' \ -e 's#R#\\x1b[1;31mRevoked#' \ - -e 's#E#\\x1b[1;33mMissing Key#' \ - -e 's#N##'; \ + -e 's#E#\\x1b[1;33mMissing Key#'; \ }; f" # custom git log (always opens in pager) From 10445c095279a21a4b2d8e04d0109664e9b74d87 Mon Sep 17 00:00:00 2001 From: kale Date: Tue, 27 Feb 2024 21:42:04 +0100 Subject: [PATCH 09/10] fix(lgi): Show author name when the commit is signed with a missing key --- config | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config b/config index 23b8b94..ed5b583 100644 --- a/config +++ b/config @@ -37,17 +37,17 @@ --format='%C(bold dim green)%h%C(auto) - %C(yellow)%cr %C(bold)→%C(reset) %s%C(reset bold yellow)%d %an %G? %GS %C(reset)' | \ sed \ -e 's#\\(.*\\) N .*#\\x1b[0;2;3m- \\1#' \ + -e 's#\\(.*\\) E .*#\\x1b[1;33mMissing Key: \\x1b[0;2;3m\\1#' \ \ -e 's#.* \\([^N]\\)#\\1#' \ - -e 's#\\(.*\\)#\\x1b[0;2;3m\\1#' \ \ - -e 's#G#\\x1b[0;1;32mGood Signature:#' \ - -e 's#B#\\x1b[1;31mBAD#' \ - -e 's#U#\\x1b[1;33mUnknown Trust: #' \ - -e 's#X#\\x1b[1;32mGood (expired since)#' \ - -e 's#Y#\\x1b[1;33mExpired Key#' \ - -e 's#R#\\x1b[1;31mRevoked#' \ - -e 's#E#\\x1b[1;33mMissing Key#'; \ + -e 's#G#\\x1b[0;1;32mGood:#' \ + -e 's#R#\\x1b[1;32mGood (revoked since):#' \ + -e 's#X#\\x1b[1;32mGood (expired since):#' \ + -e 's#U#\\x1b[1;33mUnknown Trust:#' \ + -e 's#Y#\\x1b[1;33mExpired Key:#' \ + -e 's#B#\\x1b[1;31mBAD:#' \ + -e 's#\\(.*\\)#\\x1b[0;2;3m\\1#'; \ }; f" # custom git log (always opens in pager) From a57111c2fdad19725fd0025025fe3e31df754d9c Mon Sep 17 00:00:00 2001 From: kale Date: Tue, 27 Feb 2024 21:44:32 +0100 Subject: [PATCH 10/10] fix(lgi): Bring back showing the author / signer name in gray --- config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config b/config index ed5b583..d9c10d3 100644 --- a/config +++ b/config @@ -36,8 +36,8 @@ git log --graph --branches --all --date=human --color $@ \ --format='%C(bold dim green)%h%C(auto) - %C(yellow)%cr %C(bold)→%C(reset) %s%C(reset bold yellow)%d %an %G? %GS %C(reset)' | \ sed \ - -e 's#\\(.*\\) N .*#\\x1b[0;2;3m- \\1#' \ - -e 's#\\(.*\\) E .*#\\x1b[1;33mMissing Key: \\x1b[0;2;3m\\1#' \ + -e 's#\\(.*\\) N .*#\\x1b[0;2;3;37m- \\1#' \ + -e 's#\\(.*\\) E .*#\\x1b[1;33mMissing Key: \\x1b[0;2;3;37m\\1#' \ \ -e 's#.* \\([^N]\\)#\\1#' \ \ @@ -47,7 +47,7 @@ -e 's#U#\\x1b[1;33mUnknown Trust:#' \ -e 's#Y#\\x1b[1;33mExpired Key:#' \ -e 's#B#\\x1b[1;31mBAD:#' \ - -e 's#\\(.*\\)#\\x1b[0;2;3m\\1#'; \ + -e 's#\\(.*\\)#\\x1b[0;2;3;37m\\1#'; \ }; f" # custom git log (always opens in pager)