Description
In src/commands/objects.ts:21-22:
const byType = { commit: 0, tree: 0, blob: 0 }
for (const obj of objects) byType[obj.type]++
The byType object only has keys for commit, tree, and blob. However, git fsck --unreachable can also report other types such as tag. If obj.type is 'tag', then byType['tag'] is undefined, and undefined++ evaluates to NaN.
Impact
The type summary table (lines 24-30) would display NaN for any unrecognized type. Additionally, the type assertion in git.ts:116 blindly casts whatever string git fsck outputs without validating it against the union 'commit' | 'tree' | 'blob', allowing invalid types to propagate through.
Suggested Fix
Initialize counts dynamically or add a default case, and validate object types in git.ts against the expected union.
Description
In
src/commands/objects.ts:21-22:The
byTypeobject only has keys forcommit,tree, andblob. However,git fsck --unreachablecan also report other types such astag. Ifobj.typeis'tag', thenbyType['tag']isundefined, andundefined++evaluates toNaN.Impact
The type summary table (lines 24-30) would display
NaNfor any unrecognized type. Additionally, the type assertion ingit.ts:116blindly casts whatever stringgit fsckoutputs without validating it against the union'commit' | 'tree' | 'blob', allowing invalid types to propagate through.Suggested Fix
Initialize counts dynamically or add a default case, and validate object types in
git.tsagainst the expected union.