diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-16 11:22:41 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-16 11:22:41 +0200 |
| commit | e97d5dea1d2b36ee9882de8699b382cf4fef64ae (patch) | |
| tree | e54a0d12d60049185f90792aa1077ca4f3622e7c /desktop/modules/git/test-gitcfg.sh | |
| parent | 02f7797aaf6ab9e5c4a2a89ab0efb33b43349e90 (diff) | |
| download | quickshell-e97d5dea1d2b36ee9882de8699b382cf4fef64ae.tar.gz quickshell-e97d5dea1d2b36ee9882de8699b382cf4fef64ae.zip | |
fix(git): refuse duplicate values, show list errors, Escape on Add
Review findings. With a key holding the same value twice, --fixed-value
--replace-all rewrote both and merged two rows into one, and --unset
failed on both; gitcfg now counts the matches and refuses anything but
exactly one, pointing at the editor. A file git cannot parse made list
print nothing, which the page drew as an empty config; list now prints
git's error as an error= line and the page shows it. Escape in the Add
fields clears the typed text before it leaves the page, as a row's edit
is undone first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/git/test-gitcfg.sh')
| -rwxr-xr-x | desktop/modules/git/test-gitcfg.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/desktop/modules/git/test-gitcfg.sh b/desktop/modules/git/test-gitcfg.sh index 328a575..6e1b32c 100755 --- a/desktop/modules/git/test-gitcfg.sh +++ b/desktop/modules/git/test-gitcfg.sh @@ -71,6 +71,25 @@ check "add bad key: git's error" 1 "$([[ "$out" == *section* ]] && echo 1)" check "comment kept" 1 "$(grep -c '^# keep me$' "$GIT_CONFIG_GLOBAL")" +# A value held twice: --fixed-value would replace or trip on both, so gitcfg +# refuses rather than silently merging two rows into one. +printf '[d]\n\tv = a\n\tv = a\n\tv = b\n' >> "$GIT_CONFIG_GLOBAL" +out="$("$ctl" set d.v a c)"; rc=$? +check "set duplicate: rc" 1 "$rc" +check "set duplicate: untouched" "a,a,b" "$(vals d.v)" +out="$("$ctl" unset d.v a)"; rc=$? +check "unset duplicate: rc" 1 "$rc" +check "unset duplicate: says why" 1 "$([[ "$out" == *twice* ]] && echo 1)" + +# A file git cannot parse lists nothing on stdout without this, which the +# page would draw as an empty config. +cp "$GIT_CONFIG_GLOBAL" "$tmp/good" +printf '[x\n' >> "$GIT_CONFIG_GLOBAL" +out="$("$ctl" list)"; rc=$? +check "list broken file: rc" 1 "$rc" +check "list broken file: error= line" 1 "$([[ "$out" == error=* ]] && echo 1)" +cp "$tmp/good" "$GIT_CONFIG_GLOBAL" + "$ctl" bogus >/dev/null 2>&1; rc=$? check "usage: rc" 2 "$rc" |
