1 { pkgs, lib, config, ... }:
3 home.packages = lib.mkIf config.programs.git.enable [
21 enable = lib.mkDefault true;
22 ignores = [ "*~" "*.swp" ];
23 package = lib.mkDefault pkgs.gitMinimal;
30 authors = "shortlog -s -n";
32 bl = "git log -p -M --follow --stat --";
34 ca = "commit --amend";
35 caa = "commit --amend -C@";
36 caaa = "commit --amend -C@ -a";
37 cf = "commit --fixup";
41 dcw = "diff --cached --word-diff=color";
42 dh = "diff --histogram";
43 dp = "diff --patience";
44 dt = "difftool --patience";
45 dtc = "difftool --cached";
46 dw = "diff --word-diff=color";
48 ign = "ls-files -o -i --exclude-standard";
50 ll = "log --graph --decorate --pretty=oneline --abbrev-commit";
51 lp = "log -p --pretty=fuller --stat";
52 lpg = "log -p --pretty=fuller --stat -g";
55 patch = "push rad HEAD:refs/patches";
56 # See https://stackoverflow.com/a/65839129/6741004
57 pf = "push -v --force-with-lease --force-if-includes";
64 spull = "!git-svn fetch && git-svn rebase";
65 spush = "!git-svn dcommit";
68 stu = "status -unormal";
70 fetch-local = "!git fetch local && git tag -d $(git describe --exact-match 2>/dev/null >/dev/null) && git fetch --tags local";
71 pull-local = "!git fetch-local && git checkout -B master local/master";
72 pull-local-old = "!git fetch-local && git checkout HEAD'^' && git branch -f master local/master && git checkout master";
73 root = ''!git rev-list --parents HEAD | egrep "^[a-f0-9]{40}$"'';
74 has-tag-version = ''!git show-ref --tags -d | grep -qx \"^$(git rev-parse HEAD) refs/tags/v[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]\\(\\^{}\\)\\?\"'';
75 tag-version = ''"!git has-tag-version && return; v=$(TZ=UTC date +v%Y-%m-%d) && name=$(git rev-parse --show-toplevel | sed -e 's:^.*/work::') && set -x && git tag -s -m \"$name $v\" $v"'';
76 has-tag-majordate = ''!git show-ref --tags -d | grep -qx \"^$(git rev-parse HEAD) refs/tags/v[0-9]\\+.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\(\\^{}\\)\\?\"'';
77 tag-majordate = ''"!git has-tag-majordate && return; name=$(basename $(dirname $(git rev-parse --show-toplevel))); major=$(basename $(git rev-parse --show-toplevel)); version=''${version:-$(TZ=UTC date +\"v$major.%Y%m%d\")} && set -x && git tag -s -m \"$name $version\" $version"'';
78 tag-cabal = ''"!set -x; for cabal in $(git ls-files | grep '.*\\.cabal$'); do name=$(sed -ne 's/^name: *\\(.*\\)/\\1/p' \"$cabal\"); version=$(sed -ne 's/^version: *\\(.*\\)/\\1/p' \"$cabal\"); git tag --merged | grep -Fqx \"$name-$version\" || git tag -f -s -m \"$name v$version\" $name-$version; done"'';
79 cl = "notes --ref=changelog append";
80 cl-bug = "notes --ref=changelogs/bugs append";
81 cl-feature = "notes --ref=changelogs/features append";
82 wip = "for-each-ref --sort='authordate:iso8601' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads";
85 browser.elinks.cmd = "elinks";
86 color.branch = "auto";
88 #color.diff.whitespace = "red reverse";
89 color.status = "auto";
90 core.commentChar = "auto";
91 core.quotepath = "false";
92 core.whitespace = "fix,-indent-with-non-tab,trailing-space,cr-at-eol";
93 diff.algorithm = "histogram";
94 diff.sqldiff.command = "sqldiff";
95 format.pretty = "oneline";
96 gui.fontdiff = ''-family "DejaVu Sans Mono" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
97 gui.fontui = ''-family "DejaVu Sans" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
98 gui.spellingdictionary = "en_US";
100 guitool."Rebase interactive" = {
101 cmd = "EDITOR=gvim git rebase -i $REVISION";
104 init.defaultBranch = "main";
105 merge.tool = "vimdiff";
106 merge.conflictStyle = "zdiff3";
107 protocol.version = 2;
109 push.default = "simple";
110 push.useForceIfIncludes = true;
111 rebase.autosquash = "true";
112 sendemail.chainReplyTo = "false";
113 sendemail.composeencoding = "UTF-8";
114 sendemail.confirm = "always";
115 sendemail.envelopeSender = "auto";
116 sendemail.multiedit = "yes";
117 sendemail.suppressFrom = "false";
118 sendemail.suppresscc = "self";
119 sendemail.thread = "true";
120 sendemail.validate = "true";
121 web.browser = "elinks";
125 diff.external = lib.concatStringsSep " " [
126 "${pkgs.difftastic}/bin/difft"
129 "--display side-by-side"
134 diff.tool = "difftastic";
135 difftool.prompt = false;
136 difftool.difftastic.cmd = ''${pkgs.difftastic}/bin/difft "$LOCAL" "$REMOTE"'';
137 pager.difftool = true;
142 core.pager = "delta --grep-separator-symbol keep";
143 interactive.diffFilter = "delta --color-only --features=interactive";
144 delta.features = "decorations";
145 delta.interactive = {
146 keep-plus-minus-markers = false;
148 delta.decorations = {
149 commit-decoration-style = "blue ol";
150 commit-style = "raw";
152 hunk-header-decoration-style = "blue box";
153 hunk-header-file-style = "red";
154 hunk-header-line-number-style = "#067a00";
155 hunk-header-style = "file line-number syntax";
160 programs.bash = lib.mkIf config.programs.git.enable {
163 ge = "git-edit-commit";
165 gge = "git-grep-edit";
169 git-edit-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
170 git-grep-edit () { $EDITOR $(git grep --name-only --recursive "$@"); }