repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

git: repair the merge driver and add textconv, config, and union rules

c46cf8e91571ffc3852a4a4c675e259146a52406

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

The mergiraf driver was configured on every host but installed on none of
the Termux ones, and a merge driver that exits non-zero means "conflict":
merges of mapped files were left untouched, without markers, losing even
git's own three-way merge. The driver now falls back to `git merge-file`
when mergiraf is missing, so every host degrades to stock git instead of to
manual work. Termux gets mergiraf itself from the Codeberg musl build.

core.whitespace = error was a no-op: `error` is an action for `git apply`,
not a token for core.whitespace, so patches with whitespace damage applied
with a warning. Moved to [apply] whitespace = error, which refuses them.

Also:

- textconv for .class, .jar, .war, .apk, .docx, .odt, so opaque formats
  diff as javap output, archive listings, or markdown;
- hunk headers for TOML sections and YAML top-level keys, which git ships
  no drivers for;
- union merge for CHANGELOG.md and .gitignore, which are append-only.

Changed files (2)

git/gitattributes

Modified
97 97 *.tex diff=tex
98 98 *.zig diff=zig
99 99 *.zon diff=zig
101 +# textconv: make opaque formats reviewable.
102 +*.class diff=javap
103 +*.jar diff=zip
104 +*.war diff=zip
105 +*.apk diff=zip
106 +*.docx diff=pandoc
107 +*.odt diff=pandoc
109 +# Config languages git ships no driver for.
110 +*.toml diff=toml
111 +*.yaml diff=yaml
112 +*.yml diff=yaml
114 +# Append-only files: keep both sides instead of conflicting.
115 +CHANGELOG.md merge=union
116 +.gitignore merge=union

git/gitconfig

Modified
32 32 untrackedcache = true
33 33 pager = delta
34 34 compression = 9
35 - whitespace = error
37 36 [log]
38 37 abbrevCommit = true
51 50 upstream = green
52 51 plain = blue
53 +[apply]
54 + # `error` is an action, not a core.whitespace token: refuse to apply patches
55 + # that introduce whitespace damage instead of merely warning.
56 + whitespace = error
54 58 [advice]
55 59 addEmptyPathSpec = false
56 60 pushNonFastForward = false
101 105 # Binary is named 'zeditor' on some distros, 'zed' elsewhere.
102 106 cmd = "\"$(command -v zeditor || command -v zed)\" --wait --diff \"$LOCAL\" \"$REMOTE\""
108 +[diff "javap"]
109 + textconv = javap -p -c
110 + cachetextconv = true
112 +[diff "zip"]
113 + textconv = unzip -l
114 + cachetextconv = true
116 +[diff "pandoc"]
117 + textconv = pandoc --to=markdown --wrap=none
118 + cachetextconv = true
120 +[diff "toml"]
121 + xfuncname = "^\\[.*\\]$"
123 +[diff "yaml"]
124 + xfuncname = "^[^ \t#-].*:.*$"
104 126 [diff "zig"]
105 127 # Hunk headers name the enclosing declaration in Zig and ZON sources.
106 128 # Capture groups would truncate the header, so the alternation is group-free.
134 156 [merge "mergiraf"]
135 157 name = mergiraf
136 - driver = mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P -l %L
158 + # A driver that exits non-zero means "conflict", so a missing mergiraf would
159 + # leave the file untouched with no markers. Fall back to git's own merge.
160 + driver = "sh -c 'if command -v mergiraf >/dev/null 2>&1; then exec mergiraf merge --git \"$1\" \"$2\" \"$3\" -s \"$4\" -x \"$5\" -y \"$6\" -p \"$7\" -l \"$8\"; else exec git merge-file --marker-size=\"$8\" -L \"$5\" -L \"$4\" -L \"$6\" \"$2\" \"$1\" \"$3\"; fi' -- %O %A %B %S %X %Y %P %L"
138 162 [branch]
139 163 sort = committerdate