Skip to content

Commit aa0df78

Browse files
committed
Fixes #932 - path issues with Git 2.25 on Windows
git-for-windows/git#2478
1 parent 30e1d29 commit aa0df78

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/git/git.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,8 @@ export namespace Git {
10181018

10191019
export async function rev_parse__show_toplevel(cwd: string): Promise<string | undefined> {
10201020
const data = await git<string>({ cwd: cwd, errors: GitErrorHandling.Ignore }, 'rev-parse', '--show-toplevel');
1021-
return data.length === 0 ? undefined : data.trim();
1021+
// Make sure to normalize: https://github.com/git-for-windows/git/issues/2478
1022+
return data.length === 0 ? undefined : Strings.normalizePath(data.trim());
10221023
}
10231024

10241025
export function shortlog(repoPath: string) {

src/system/string.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
import { createHash, HexBase64Latin1Encoding } from 'crypto';
3+
import { isWindows } from '../git/shell';
34

45
const emptyStr = '';
56

@@ -58,6 +59,7 @@ export namespace Strings {
5859
return secs * 1000 + Math.floor(nanosecs / 1000000);
5960
}
6061

62+
const driveLetterNormalizeRegex = /(?<=^\/?)([A-Z])(?=:\/)/;
6163
const pathNormalizeRegex = /\\/g;
6264
const pathStripTrailingSlashRegex = /\/$/g;
6365
const tokenRegex = /\$\{(\W*)?([^|]*?)(?:\|(\d+)(-|\?)?)?(\W*)?\}/g;
@@ -149,6 +151,11 @@ export namespace Strings {
149151
normalized = `/${normalized}`;
150152
}
151153

154+
if (isWindows) {
155+
// Ensure that drive casing is normalized (lower case)
156+
normalized = normalized.replace(driveLetterNormalizeRegex, (drive: string) => drive.toLowerCase());
157+
}
158+
152159
return normalized;
153160
}
154161

0 commit comments

Comments
 (0)