Handle Mac file system as case insensitive when comparing paths in the git extension. #138090

This commit is contained in:
Ladislau Szomoru
2022-01-18 21:45:16 +01:00
parent 86e3a3a062
commit 41a1de64ed
2 changed files with 10 additions and 10 deletions
+1 -2
View File
@@ -11,7 +11,7 @@ import * as which from 'which';
import { EventEmitter } from 'events';
import * as iconv from '@vscode/iconv-lite-umd';
import * as filetype from 'file-type';
import { assign, groupBy, IDisposable, toDisposable, dispose, mkdirp, readBytes, detectUnicodeEncoding, Encoding, onceEvent, splitInChunks, Limiter, Versions } from './util';
import { assign, groupBy, IDisposable, toDisposable, dispose, mkdirp, readBytes, detectUnicodeEncoding, Encoding, onceEvent, splitInChunks, Limiter, Versions, isWindows } from './util';
import { CancellationToken, Progress, Uri } from 'vscode';
import { detectEncoding } from './encoding';
import { Ref, RefType, Branch, Remote, ForcePushMode, GitErrorCodes, LogOptions, Change, Status, CommitOptions, BranchQuery } from './api/git';
@@ -20,7 +20,6 @@ import { StringDecoder } from 'string_decoder';
// https://github.com/microsoft/vscode/issues/65693
const MAX_CLI_LENGTH = 30000;
const isWindows = process.platform === 'win32';
export interface IGit {
path: string;
+9 -8
View File
@@ -9,6 +9,9 @@ import { Readable } from 'stream';
import { promises as fs, createReadStream } from 'fs';
import * as byline from 'byline';
export const isMacintosh = process.platform === 'darwin';
export const isWindows = process.platform === 'win32';
export function log(...args: any[]): void {
console.log.apply(console, ['git:', ...args]);
}
@@ -284,10 +287,6 @@ export function detectUnicodeEncoding(buffer: Buffer): Encoding | null {
return null;
}
function isWindowsPath(path: string): boolean {
return /^[a-zA-Z]:\\/.test(path);
}
export function isDescendant(parent: string, descendant: string): boolean {
if (parent === descendant) {
return true;
@@ -297,8 +296,9 @@ export function isDescendant(parent: string, descendant: string): boolean {
parent += sep;
}
// Windows is case insensitive
if (isWindowsPath(parent)) {
// Windows & Mac are currently being handled
// as case insensitive file systems in VS Code.
if (isWindows || isMacintosh) {
parent = parent.toLowerCase();
descendant = descendant.toLowerCase();
}
@@ -307,8 +307,9 @@ export function isDescendant(parent: string, descendant: string): boolean {
}
export function pathEquals(a: string, b: string): boolean {
// Windows is case insensitive
if (isWindowsPath(a)) {
// Windows & Mac are currently being handled
// as case insensitive file systems in VS Code.
if (isWindows || isMacintosh) {
a = a.toLowerCase();
b = b.toLowerCase();
}