From b166f22bc85f2105e0f016c74cb36c7a6d701fcb Mon Sep 17 00:00:00 2001 From: Soispha Date: Fri, 29 Dec 2023 08:25:11 +0100 Subject: feat(hm/conf/git): Incorporate elements of other peoples configs --- hm/soispha/conf/git/default.nix | 98 ++++++++++++++++++++++++++++++++++++++--- hm/soispha/pkgs/default.nix | 1 + 2 files changed, 93 insertions(+), 6 deletions(-) diff --git a/hm/soispha/conf/git/default.nix b/hm/soispha/conf/git/default.nix index 728e40d9..efacf36d 100644 --- a/hm/soispha/conf/git/default.nix +++ b/hm/soispha/conf/git/default.nix @@ -1,4 +1,9 @@ -{nixosConfig, ...}: let +{ + nixosConfig, + lib, + config, + ... +}: let gitIgnoreFile = ./git_ignore.git; gitTemplateFile = ./git_template.git; in { @@ -9,7 +14,8 @@ in { cm = "commit --verbose"; cmr = "commit --file .git/COMMIT_EDITMSG --edit --verbose"; - st = "status"; + st = "status --short --branch"; + stf = "status"; ds = "diff --staged"; di = "diff"; @@ -38,6 +44,44 @@ in { '' %C(white)%s%C(reset)%n''\ %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)\ %C(bold white)- trailers: %(trailers) %C(reset)'"; + + # hard reset with commit before (use reflog to recover) + # git wipe [] + wipe = lib.strings.concatStringsSep " " [ + "!git" + "add" + "--all" + "&&" + "git" + "commit" + "--quiet" + "--message='WIPE-SAVEPOINT'" + "--no-gpg-sign" + "&&" + "git reset $${1:-HEAD~} --hard" + "&&" + "git clean -fd" + ]; + branches = lib.strings.concatStringsSep " " [ + "!git" + "for-each-ref" + "--sort=-committerdate" + "--color=always" + "--format='${ + lib.strings.concatStringsSep "|" [ + "%(color:blue)%(authordate:relative)" + "%(color:red)%(authorname)" + "%(color:green)%(color:bold)%(refname:short)" + ] + }'" + "refs/remotes" + "|" + "column -ts'|' -o ' '" + ]; + tags = "tag --list"; + remotes = "remote --verbose"; + day = "!git log --stat --since '1 day ago' --author $(git config user.email)"; + unpush = "push --force-with-lease origin HEAD~1:${config.programs.git.extraConfig.init.defaultBranch}"; }; extraConfig = { core = { @@ -61,11 +105,56 @@ in { }; diff = { colorMoved = "default"; + # Usually leads to better results + algorithm = "patience"; + bin = { + textconv = "hexdump -v -C"; + }; + }; + # Makes it a bit more readable + blame = { + coloring = "repeatedLines"; + markIgnoredLines = true; + markUnblamables = true; }; merge = { conflictstyle = "diff3"; }; + url = { + "git@codeberg.org" = { + insteadOf = "@cb:"; + }; + "https://codeberg.org/" = { + insteadOf = "cb://"; + }; + + "git@github.com:" = { + insteadOf = "@gh:"; + }; + "https://github.com/" = { + insteadOf = "gh://"; + }; + + "git@gitlab.com:" = { + insteadOf = "@gl:"; + }; + "https://gitlab.com/" = { + insteadOf = "gl://"; + }; + }; }; + includes = [ + { + condition = "gitdir:~/school/"; + contents = { + user = { + name = nixosConfig.soispha.secret.me.name; + email = nixosConfig.soispha.secret.me.email; + signingKey = nixosConfig.soispha.secret.me.gpgKey; + }; + }; + } + ]; delta = { enable = true; options = { @@ -74,10 +163,7 @@ in { file-decoration-style = "none"; file-style = "bold yellow ul"; }; - keep-plus-minus-markers = - if nixosConfig.soispha.laptop.enable - then true - else false; + keep-plus-minus-markers = true; features = "decorations"; whitespace-error-style = "22 reverse"; }; diff --git a/hm/soispha/pkgs/default.nix b/hm/soispha/pkgs/default.nix index 60884493..c713b7ac 100644 --- a/hm/soispha/pkgs/default.nix +++ b/hm/soispha/pkgs/default.nix @@ -124,6 +124,7 @@ with pkgs; let GeneralTools = [ git # the fast distributed version control system git-crypt # mostly here to avoid problems in repositories, where the flake can't be loaded + git-absorb # git commit --fixup, but automatic glow # Command-line markdown renderer ]; }; -- cgit 1.4.1