fix: correct git status parsing in merge preview

Fixed parsing bug where .trim() on entire output removed leading space
from git status --porcelain format, causing filenames to be truncated.

- Removed .trim() from git status output (line 536)
- Check for empty status using gitStatus.trim() in condition
- Correctly parse XY<space>filename format without truncation
- Removed diagnostic logging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
AndyMik90
2025-12-18 16:37:41 +01:00
parent 1a2b7a1bbb
commit c721dc23b6
@@ -533,15 +533,17 @@ export function registerWorktreeHandlers(
const gitStatus = execSync('git status --porcelain', {
cwd: project.path,
encoding: 'utf-8'
}).trim();
});
if (gitStatus) {
if (gitStatus && gitStatus.trim()) {
// Parse the status output to get file names
uncommittedFiles = gitStatus.split('\n')
// Format: XY filename (where X and Y are status chars, then space, then filename)
uncommittedFiles = gitStatus
.split('\n')
.filter(line => line.trim())
.map(line => line.substring(3).trim()); // Remove status prefix (e.g., "M ", " M ", "?? ")
.map(line => line.substring(3)); // Skip 2 status chars + 1 space
hasUncommittedChanges = uncommittedFiles.length > 0;
console.warn('[IPC] Uncommitted changes detected:', uncommittedFiles.length, 'files');
}
} catch (e) {
console.error('[IPC] Failed to check git status:', e);