worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

get_config() swallows all git errors instead of distinguishing missing vs corrupt

Open worktrunk-bot opened this issue 8 months ago • 2 comments

Summary

In src/git/repository/config.rs, get_config() treats ALL git config errors as "key doesn't exist" by mapping Err(_) => Ok(None).

git config --get uses distinct exit codes:

  • Exit 1: key not found
  • Exit 128+: actual error (corrupt config, permission denied, etc.)

Currently, a corrupt git config or permission error silently returns None, which could mask real problems.

Location

  • src/git/repository/config.rs:15
  • Also clear_hint at line 91 swallows errors similarly (though that's more defensible as best-effort).

Suggested fix

Check the exit code: return Ok(None) for exit code 1, propagate the error for other exit codes.

worktrunk-bot avatar Mar 17 '26 06:03 worktrunk-bot

ok, make this change

max-sixty avatar Mar 18 '26 20:03 max-sixty

Done — #1610.

config_value() now checks exit codes: 1 = key not found (Ok(None)), anything else propagated. Same fix for clear_hint() and clear_default_branch_cache() which use --unset (exit 5 = not found).

worktrunk-bot avatar Mar 18 '26 20:03 worktrunk-bot