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";
69 fetch-local = "!git fetch local && git tag -d $(git describe --exact-match 2>/dev/null >/dev/null) && git fetch --tags local";
70 pull-local = "!git fetch-local && git checkout -B master local/master";
71 pull-local-old = "!git fetch-local && git checkout HEAD'^' && git branch -f master local/master && git checkout master";
72 root = ''!git rev-list --parents HEAD | egrep "^[a-f0-9]{40}$"'';
73 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]\\(\\^{}\\)\\?\"'';
74 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"'';
75 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]\\(\\^{}\\)\\?\"'';
76 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"'';
77 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"'';
78 cl = "notes --ref=changelog append";
79 cl-bug = "notes --ref=changelogs/bugs append";
80 cl-feature = "notes --ref=changelogs/features append";
81 wip = "for-each-ref --sort='authordate:iso8601' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads";
84 browser.elinks.cmd = "elinks";
85 color.branch = "auto";
87 #color.diff.whitespace = "red reverse";
88 color.status = "auto";
89 core.commentChar = "auto";
90 core.quotepath = "false";
91 core.whitespace = "fix,-indent-with-non-tab,trailing-space,cr-at-eol";
92 diff.algorithm = "histogram";
93 diff.sqldiff.command = "sqldiff";
94 format.pretty = "oneline";
95 gui.fontdiff = ''-family "DejaVu Sans Mono" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
96 gui.fontui = ''-family "DejaVu Sans" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
97 gui.spellingdictionary = "en_US";
99 guitool."Rebase interactive" = {
100 cmd = "EDITOR=gvim git rebase -i $REVISION";
103 init.defaultBranch = "main";
104 merge.tool = "vimdiff";
105 merge.conflictStyle = "zdiff3";
106 protocol.version = 2;
108 push.default = "simple";
109 push.useForceIfIncludes = true;
110 rebase.autosquash = "true";
111 sendemail.chainReplyTo = "false";
112 sendemail.composeencoding = "UTF-8";
113 sendemail.confirm = "always";
114 sendemail.envelopeSender = "auto";
115 sendemail.multiedit = "yes";
116 sendemail.suppressFrom = "false";
117 sendemail.suppresscc = "self";
118 sendemail.thread = "true";
119 sendemail.validate = "true";
120 web.browser = "elinks";
124 diff.external = lib.concatStringsSep " " [
125 "${pkgs.difftastic}/bin/difft"
128 "--display side-by-side"
133 diff.tool = "difftastic";
134 difftool.prompt = false;
135 difftool.difftastic.cmd = ''${pkgs.difftastic}/bin/difft "$LOCAL" "$REMOTE"'';
136 pager.difftool = true;
141 core.pager = "delta --grep-separator-symbol keep";
142 interactive.diffFilter = "delta --color-only --features=interactive";
143 delta.features = "decorations";
144 delta.interactive = {
145 keep-plus-minus-markers = false;
147 delta.decorations = {
148 commit-decoration-style = "blue ol";
149 commit-style = "raw";
151 hunk-header-decoration-style = "blue box";
152 hunk-header-file-style = "red";
153 hunk-header-line-number-style = "#067a00";
154 hunk-header-style = "file line-number syntax";
159 programs.bash = lib.mkIf config.programs.git.enable {
162 ge = "git-edit-commit";
164 gge = "git-grep-edit";
168 git-edit-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
169 git-grep-edit () { $EDITOR $(git grep --name-only --recursive "$@"); }