Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/git/src/git.ts')
-rw-r--r--extensions/git/src/git.ts34
1 files changed, 23 insertions, 11 deletions
diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts
index cd6bdaf1884..8fdab7f659b 100644
--- a/extensions/git/src/git.ts
+++ b/extensions/git/src/git.ts
@@ -396,7 +396,7 @@ export class Git {
return Versions.compare(Versions.fromString(this.version), Versions.fromString(version));
}
- open(repository: string, dotGit: string): Repository {
+ open(repository: string, dotGit: { path: string; commonPath?: string }): Repository {
return new Repository(this, repository, dotGit);
}
@@ -469,7 +469,7 @@ export class Git {
}
async getRepositoryRoot(repositoryPath: string): Promise<string> {
- const result = await this.exec(repositoryPath, ['rev-parse', '--show-toplevel'], { log: false });
+ const result = await this.exec(repositoryPath, ['rev-parse', '--show-toplevel']);
// Keep trailing spaces which are part of the directory name
const repoPath = path.normalize(result.stdout.trimLeft().replace(/[\r\n]+$/, ''));
@@ -509,15 +509,25 @@ export class Git {
return repoPath;
}
- async getRepositoryDotGit(repositoryPath: string): Promise<string> {
- const result = await this.exec(repositoryPath, ['rev-parse', '--git-dir']);
- let dotGitPath = result.stdout.trim();
+ async getRepositoryDotGit(repositoryPath: string): Promise<{ path: string; commonPath?: string }> {
+ const result = await this.exec(repositoryPath, ['rev-parse', '--git-dir', '--git-common-dir']);
+ let [dotGitPath, commonDotGitPath] = result.stdout.split('\n').map(r => r.trim());
if (!path.isAbsolute(dotGitPath)) {
dotGitPath = path.join(repositoryPath, dotGitPath);
}
+ dotGitPath = path.normalize(dotGitPath);
- return path.normalize(dotGitPath);
+ if (commonDotGitPath) {
+ if (!path.isAbsolute(commonDotGitPath)) {
+ commonDotGitPath = path.join(repositoryPath, commonDotGitPath);
+ }
+ commonDotGitPath = path.normalize(commonDotGitPath);
+
+ return { path: dotGitPath, commonPath: commonDotGitPath !== dotGitPath ? commonDotGitPath : undefined };
+ }
+
+ return { path: dotGitPath };
}
async exec(cwd: string, args: string[], options: SpawnOptions = {}): Promise<IExecutionResult<string>> {
@@ -863,7 +873,7 @@ export class Repository {
constructor(
private _git: Git,
private repositoryRoot: string,
- readonly dotGit: string
+ readonly dotGit: { path: string; commonPath?: string }
) { }
get git(): Git {
@@ -2043,8 +2053,10 @@ export class Repository {
if (this._git.compareGitVersionTo('1.9.0') === -1) {
args.push('--format=%(refname)%00%(upstream:short)%00%(objectname)');
supportsAheadBehind = false;
- } else {
+ } else if (this._git.compareGitVersionTo('2.16.0') === -1) {
args.push('--format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)');
+ } else {
+ args.push('--format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref)');
}
if (/^refs\/(head|remotes)\//i.test(name)) {
@@ -2055,7 +2067,7 @@ export class Repository {
const result = await this.exec(args);
const branches: Branch[] = result.stdout.trim().split('\n').map<Branch | undefined>(line => {
- let [branchName, upstream, ref, status] = line.trim().split('\0');
+ let [branchName, upstream, ref, status, remoteName, upstreamRef] = line.trim().split('\0');
if (branchName.startsWith('refs/heads/')) {
branchName = branchName.substring(11);
@@ -2072,8 +2084,8 @@ export class Repository {
type: RefType.Head,
name: branchName,
upstream: upstream ? {
- name: upstream.substring(index + 1),
- remote: upstream.substring(0, index)
+ name: upstreamRef ? upstreamRef.substring(11) : upstream.substring(index + 1),
+ remote: remoteName ? remoteName : upstream.substring(0, index)
} : undefined,
commit: ref || undefined,
ahead: Number(ahead) || 0,