-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Description
I'm opening this issue to bring attention to a specific usability hurdle regarding branch renaming on Windows, which I previously mentioned in a comment here: #21287 (comment).
I understand that you are not actively looking for external contributions for this feature at the moment. However, I have already investigated the codebase and identified a clean, low-risk solution that I would love to implement if permitted.
Proposed Solution
I found that the logic can be handled within app/src/lib/git/branch.ts inside the renameBranch function.
Since Windows is case-insensitive, we can detect if the OS is win32 and if the rename is only a case change. In that specific scenario, we can implement a two-step rename process (e.g. oldName -> tempName -> newName) to force the filesystem to register the change.
Here is the rough implementation idea:
Click to view the code snippet
export async function renameBranch(repository: Repository, branch: Branch, newName: string): Promise<void> {
const oldName = branch.nameWithoutRemote
const isCaseInsensitiveRename = oldName.toLowerCase() === newName.toLowerCase() && oldName !== newName
const isWindows = process.platform === 'win32'
// If Windows and case-only rename, use the two-step rename process
if (isWindows && isCaseInsensitiveRename) {
const tempName = `${oldName}-temp-${Date.now()}`
// Step 1: Rename to temp name
await git(['branch', '-m', oldName, tempName], repository.path, 'renameBranch-step1')
// Step 2: Rename to target name
await git(['branch', '-m', tempName, newName], repository.path, 'renameBranch-step2')
return
}
// Default behavior for other cases
await git(['branch', '-m', oldName, newName], repository.path, 'renameBranch')
}This approach isolates the fix to the Git operation layer without requiring complex UI changes.
Since I have a clear implementation plan ready that aligns with the project's architecture, would you be open to adding the help-wanted label to this issue? I am eager to submit a PR following your contribution guidelines to help improve the Windows user experience.