From e97d5dea1d2b36ee9882de8699b382cf4fef64ae Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 16 Oct 2026 11:22:41 +0200 Subject: 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 --- desktop/modules/git/test-gitcfg.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'desktop/modules/git/test-gitcfg.sh') 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" -- cgit v1.2.3