Browse Source

Renames some members for consistency

main
Eric Amodio 5 years ago
parent
commit
6d9a666d12
10 changed files with 75 additions and 72 deletions
  1. +2
    -2
      src/annotations/annotations.ts
  2. +1
    -1
      src/commands/diffLineWithWorking.ts
  3. +2
    -2
      src/commands/diffWithWorking.ts
  4. +22
    -20
      src/git/git.ts
  5. +36
    -35
      src/git/gitService.ts
  6. +4
    -4
      src/git/gitUri.ts
  7. +1
    -1
      src/git/models/commit.ts
  8. +2
    -2
      src/quickpicks/repoStatusQuickPick.ts
  9. +2
    -2
      src/views/nodes/fileHistoryNode.ts
  10. +3
    -3
      src/views/nodes/statusFilesNode.ts

+ 2
- 2
src/annotations/annotations.ts View File

@ -121,7 +121,7 @@ export class Annotations {
let message: string; let message: string;
if (commit.isUncommitted) { if (commit.isUncommitted) {
if (uri.sha !== undefined && GitService.isStagedUncommitted(uri.sha)) {
if (uri.sha !== undefined && GitService.isUncommittedStaged(uri.sha)) {
message = `[\`Changes\`](${DiffWithCommand.getMarkdownCommandArgs( message = `[\`Changes\`](${DiffWithCommand.getMarkdownCommandArgs(
commit, commit,
editorLine editorLine
@ -173,7 +173,7 @@ export class Annotations {
): Promise<Partial<DecorationOptions>> { ): Promise<Partial<DecorationOptions>> {
let ref; let ref;
if (commit.isUncommitted) { if (commit.isUncommitted) {
if (uri.sha !== undefined && GitService.isStagedUncommitted(uri.sha)) {
if (uri.sha !== undefined && GitService.isUncommittedStaged(uri.sha)) {
ref = uri.sha; ref = uri.sha;
} }
} }

+ 1
- 1
src/commands/diffLineWithWorking.ts View File

@ -52,7 +52,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
args.commit = args.commit.with({ args.commit = args.commit.with({
sha: sha:
status !== undefined && status.indexStatus !== undefined status !== undefined && status.indexStatus !== undefined
? GitService.stagedUncommittedSha
? GitService.uncommittedStagedSha
: args.commit.previousSha!, : args.commit.previousSha!,
fileName: args.commit.previousFileName!, fileName: args.commit.previousFileName!,
originalFileName: null, originalFileName: null,

+ 2
- 2
src/commands/diffWithWorking.ts View File

@ -61,12 +61,12 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
} }
// If we are a fake "staged" sha, check the status // If we are a fake "staged" sha, check the status
if (GitService.isStagedUncommitted(gitUri.sha!)) {
if (GitService.isUncommittedStaged(gitUri.sha!)) {
gitUri.sha = undefined; gitUri.sha = undefined;
const status = await Container.git.getStatusForFile(gitUri.repoPath!, gitUri.fsPath); const status = await Container.git.getStatusForFile(gitUri.repoPath!, gitUri.fsPath);
if (status !== undefined && status.indexStatus !== undefined) { if (status !== undefined && status.indexStatus !== undefined) {
let sha = GitService.stagedUncommittedSha;
let sha = GitService.uncommittedStagedSha;
if (args.inDiffEditor) { if (args.inDiffEditor) {
const commit = await Container.git.getCommitForFile(gitUri.repoPath!, gitUri.fsPath); const commit = await Container.git.getCommitForFile(gitUri.repoPath!, gitUri.fsPath);
if (commit === undefined) return Messages.showCommitHasNoPreviousCommitWarningMessage(); if (commit === undefined) return Messages.showCommitHasNoPreviousCommitWarningMessage();

+ 22
- 20
src/git/git.ts View File

@ -206,10 +206,10 @@ export class Git {
static shaRegex = /(^[0-9a-f]{40}$)|(^[0]{40}(:|-)$)/; static shaRegex = /(^[0-9a-f]{40}$)|(^[0]{40}(:|-)$)/;
static shaParentRegex = /^[0-9a-f]{40}\^[0-3]?$/; static shaParentRegex = /^[0-9a-f]{40}\^[0-3]?$/;
static shaShortenRegex = /^(.*?)([\^@~:].*)?$/; static shaShortenRegex = /^(.*?)([\^@~:].*)?$/;
static stagedUncommittedRegex = /^[0]{40}([\^@~]\S*)?:$/;
static stagedUncommittedSha = '0000000000000000000000000000000000000000:';
static uncommittedRegex = /^[0]{40}(?:[\^@~:]\S*)?:?$/; static uncommittedRegex = /^[0]{40}(?:[\^@~:]\S*)?:?$/;
static uncommittedSha = '0000000000000000000000000000000000000000'; static uncommittedSha = '0000000000000000000000000000000000000000';
static uncommittedStagedRegex = /^[0]{40}([\^@~]\S*)?:$/;
static uncommittedStagedSha = '0000000000000000000000000000000000000000:';
static getEncoding(encoding: string | undefined) { static getEncoding(encoding: string | undefined) {
return encoding !== undefined && iconv.encodingExists(encoding) ? encoding : 'utf8'; return encoding !== undefined && iconv.encodingExists(encoding) ? encoding : 'utf8';
@ -247,27 +247,29 @@ export class Git {
return Git.shaParentRegex.test(ref); return Git.shaParentRegex.test(ref);
} }
static isStagedUncommitted(ref: string | undefined): boolean {
return ref ? Git.stagedUncommittedRegex.test(ref) : false;
}
static isUncommitted(ref: string | undefined) { static isUncommitted(ref: string | undefined) {
return ref ? Git.uncommittedRegex.test(ref) : false; return ref ? Git.uncommittedRegex.test(ref) : false;
} }
static isUncommittedStaged(ref: string | undefined): boolean {
return ref ? Git.uncommittedStagedRegex.test(ref) : false;
}
static shortenSha( static shortenSha(
ref: string,
strings: { stagedUncommitted?: string; uncommitted?: string; working?: string } = {}
ref: string | undefined,
{
stagedUncommitted = 'Index',
uncommitted = 'Working Tree',
working = emptyStr
}: { stagedUncommitted?: string; uncommitted?: string; working?: string } = {}
) { ) {
strings = { stagedUncommitted: 'Index', uncommitted: 'Working Tree', working: emptyStr, ...strings };
if (ref == null || ref.length === 0) return strings.working;
if (ref == null || ref.length === 0) return working;
if (Git.isUncommitted(ref)) { if (Git.isUncommitted(ref)) {
if (Git.isStagedUncommitted(ref)) return strings.stagedUncommitted;
return strings.uncommitted;
return Git.isUncommittedStaged(ref) ? stagedUncommitted : uncommitted;
} }
if (!Git.isShaLike(ref)) return ref;
// Don't allow shas to be shortened to less than 5 characters // Don't allow shas to be shortened to less than 5 characters
const len = Math.max(5, Container.config.advanced.abbreviatedShaLength); const len = Math.max(5, Container.config.advanced.abbreviatedShaLength);
@ -343,7 +345,7 @@ export class Git {
let stdin; let stdin;
if (ref) { if (ref) {
if (Git.isStagedUncommitted(ref)) {
if (Git.isUncommittedStaged(ref)) {
// Pipe the blame contents to stdin // Pipe the blame contents to stdin
params.push('--contents', '-'); params.push('--contents', '-');
@ -496,10 +498,10 @@ export class Git {
if (ref1.endsWith('^3^')) { if (ref1.endsWith('^3^')) {
ref1 = rootSha; ref1 = rootSha;
} }
params.push(Git.isStagedUncommitted(ref1) ? '--staged' : ref1);
params.push(Git.isUncommittedStaged(ref1) ? '--staged' : ref1);
} }
if (ref2) { if (ref2) {
params.push(Git.isStagedUncommitted(ref2) ? '--staged' : ref2);
params.push(Git.isUncommittedStaged(ref2) ? '--staged' : ref2);
} }
const encoding: BufferEncoding = options.encoding === 'utf8' ? 'utf8' : 'binary'; const encoding: BufferEncoding = options.encoding === 'utf8' ? 'utf8' : 'binary';
@ -637,7 +639,7 @@ export class Git {
params.push('--use-mailmap', ...authors.map(a => `--author=${a}`)); params.push('--use-mailmap', ...authors.map(a => `--author=${a}`));
} }
if (ref && !Git.isStagedUncommitted(ref)) {
if (ref && !Git.isUncommittedStaged(ref)) {
// If we are reversing, we must add a range (with HEAD) because we are using --ancestry-path for better reverse walking // If we are reversing, we must add a range (with HEAD) because we are using --ancestry-path for better reverse walking
if (reverse) { if (reverse) {
params.push('--reverse', '--ancestry-path', `${ref}..HEAD`); params.push('--reverse', '--ancestry-path', `${ref}..HEAD`);
@ -697,7 +699,7 @@ export class Git {
params.push(`-L ${startLine},${endLine == null ? startLine : endLine}:${file}`); params.push(`-L ${startLine},${endLine == null ? startLine : endLine}:${file}`);
} }
if (ref && !Git.isStagedUncommitted(ref)) {
if (ref && !Git.isUncommittedStaged(ref)) {
// If we are reversing, we must add a range (with HEAD) because we are using --ancestry-path for better reverse walking // If we are reversing, we must add a range (with HEAD) because we are using --ancestry-path for better reverse walking
if (reverse) { if (reverse) {
params.push('--reverse', '--ancestry-path', `${ref}..HEAD`); params.push('--reverse', '--ancestry-path', `${ref}..HEAD`);
@ -868,7 +870,7 @@ export class Git {
): Promise<TOut | undefined> { ): Promise<TOut | undefined> {
const [file, root] = Git.splitPath(fileName, repoPath); const [file, root] = Git.splitPath(fileName, repoPath);
if (Git.isStagedUncommitted(ref)) {
if (Git.isUncommittedStaged(ref)) {
ref = ':'; ref = ':';
} }
if (Git.isUncommitted(ref)) throw new Error(`ref=${ref} is uncommitted`); if (Git.isUncommitted(ref)) throw new Error(`ref=${ref} is uncommitted`);

+ 36
- 35
src/git/gitService.ts View File

@ -93,12 +93,9 @@ export enum GitRepoSearchBy {
Sha = 'sha' Sha = 'sha'
} }
export class GitService implements Disposable {
static emptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
static deletedOrMissingSha = Git.deletedOrMissingSha;
static stagedUncommittedSha = Git.stagedUncommittedSha;
static uncommittedSha = Git.uncommittedSha;
const emptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
export class GitService implements Disposable {
private _onDidChangeRepositories = new EventEmitter<void>(); private _onDidChangeRepositories = new EventEmitter<void>();
get onDidChangeRepositories(): Event<void> { get onDidChangeRepositories(): Event<void> {
return this._onDidChangeRepositories.event; return this._onDidChangeRepositories.event;
@ -672,7 +669,7 @@ export class GitService implements Disposable {
): Promise<GitBlame | undefined> { ): Promise<GitBlame | undefined> {
if (!(await this.isTracked(uri))) { if (!(await this.isTracked(uri))) {
Logger.log(cc, `Skipping blame; '${uri.fsPath}' is not tracked`); Logger.log(cc, `Skipping blame; '${uri.fsPath}' is not tracked`);
return GitService.emptyPromise as Promise<GitBlame>;
return emptyPromise as Promise<GitBlame>;
} }
const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false); const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false);
@ -692,14 +689,14 @@ export class GitService implements Disposable {
Logger.debug(cc, `Cache replace (with empty promise): '${key}'`); Logger.debug(cc, `Cache replace (with empty promise): '${key}'`);
const value: CachedBlame = { const value: CachedBlame = {
item: GitService.emptyPromise as Promise<GitBlame>,
item: emptyPromise as Promise<GitBlame>,
errorMessage: msg errorMessage: msg
}; };
document.state.set<CachedBlame>(key, value); document.state.set<CachedBlame>(key, value);
document.setBlameFailure(); document.setBlameFailure();
return GitService.emptyPromise as Promise<GitBlame>;
return emptyPromise as Promise<GitBlame>;
} }
return undefined; return undefined;
@ -756,7 +753,7 @@ export class GitService implements Disposable {
): Promise<GitBlame | undefined> { ): Promise<GitBlame | undefined> {
if (!(await this.isTracked(uri))) { if (!(await this.isTracked(uri))) {
Logger.log(cc, `Skipping blame; '${uri.fsPath}' is not tracked`); Logger.log(cc, `Skipping blame; '${uri.fsPath}' is not tracked`);
return GitService.emptyPromise as Promise<GitBlame>;
return emptyPromise as Promise<GitBlame>;
} }
const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false); const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false);
@ -777,13 +774,13 @@ export class GitService implements Disposable {
Logger.debug(cc, `Cache replace (with empty promise): '${key}'`); Logger.debug(cc, `Cache replace (with empty promise): '${key}'`);
const value: CachedBlame = { const value: CachedBlame = {
item: GitService.emptyPromise as Promise<GitBlame>,
item: emptyPromise as Promise<GitBlame>,
errorMessage: msg errorMessage: msg
}; };
document.state.set<CachedBlame>(key, value); document.state.set<CachedBlame>(key, value);
document.setBlameFailure(); document.setBlameFailure();
return GitService.emptyPromise as Promise<GitBlame>;
return emptyPromise as Promise<GitBlame>;
} }
return undefined; return undefined;
@ -1169,7 +1166,7 @@ export class GitService implements Disposable {
try { try {
let data; let data;
if (ref1 !== undefined && ref2 === undefined && !GitService.isStagedUncommitted(ref1)) {
if (ref1 !== undefined && ref2 === undefined && !GitService.isUncommittedStaged(ref1)) {
data = await Git.show__diff(root, file, ref1, originalFileName, { data = await Git.show__diff(root, file, ref1, originalFileName, {
similarityThreshold: Container.config.advanced.similarityThreshold similarityThreshold: Container.config.advanced.similarityThreshold
}); });
@ -1192,12 +1189,12 @@ export class GitService implements Disposable {
Logger.debug(cc, `Cache replace (with empty promise): '${key}'`); Logger.debug(cc, `Cache replace (with empty promise): '${key}'`);
const value: CachedDiff = { const value: CachedDiff = {
item: GitService.emptyPromise as Promise<GitDiff>,
item: emptyPromise as Promise<GitDiff>,
errorMessage: msg errorMessage: msg
}; };
document.state.set<CachedDiff>(key, value); document.state.set<CachedDiff>(key, value);
return GitService.emptyPromise as Promise<GitDiff>;
return emptyPromise as Promise<GitDiff>;
} }
return undefined; return undefined;
@ -1216,7 +1213,7 @@ export class GitService implements Disposable {
let diff = await this.getDiffForFile(uri, ref1, ref2, originalFileName); let diff = await this.getDiffForFile(uri, ref1, ref2, originalFileName);
// If we didn't find a diff & ref1 is undefined (meaning uncommitted), check for a staged diff // If we didn't find a diff & ref1 is undefined (meaning uncommitted), check for a staged diff
if (diff === undefined && ref1 === undefined) { if (diff === undefined && ref1 === undefined) {
diff = await this.getDiffForFile(uri, Git.stagedUncommittedSha, ref2, originalFileName);
diff = await this.getDiffForFile(uri, Git.uncommittedStagedSha, ref2, originalFileName);
} }
if (diff === undefined) return undefined; if (diff === undefined) return undefined;
@ -1537,7 +1534,7 @@ export class GitService implements Disposable {
): Promise<GitLog | undefined> { ): Promise<GitLog | undefined> {
if (!(await this.isTracked(fileName, repoPath, { ref: ref }))) { if (!(await this.isTracked(fileName, repoPath, { ref: ref }))) {
Logger.log(cc, `Skipping log; '${fileName}' is not tracked`); Logger.log(cc, `Skipping log; '${fileName}' is not tracked`);
return GitService.emptyPromise as Promise<GitLog>;
return emptyPromise as Promise<GitLog>;
} }
const [file, root] = Git.splitPath(fileName, repoPath, false); const [file, root] = Git.splitPath(fileName, repoPath, false);
@ -1582,12 +1579,12 @@ export class GitService implements Disposable {
Logger.debug(cc, `Cache replace (with empty promise): '${key}'`); Logger.debug(cc, `Cache replace (with empty promise): '${key}'`);
const value: CachedLog = { const value: CachedLog = {
item: GitService.emptyPromise as Promise<GitLog>,
item: emptyPromise as Promise<GitLog>,
errorMessage: msg errorMessage: msg
}; };
document.state.set<CachedLog>(key, value); document.state.set<CachedLog>(key, value);
return GitService.emptyPromise as Promise<GitLog>;
return emptyPromise as Promise<GitLog>;
} }
return undefined; return undefined;
@ -1641,7 +1638,7 @@ export class GitService implements Disposable {
const fileName = GitUri.getRelativePath(uri, repoPath); const fileName = GitUri.getRelativePath(uri, repoPath);
if (Git.isStagedUncommitted(ref)) {
if (Git.isUncommittedStaged(ref)) {
return { return {
current: GitUri.fromFile(fileName, repoPath, ref), current: GitUri.fromFile(fileName, repoPath, ref),
next: GitUri.fromFile(fileName, repoPath, undefined) next: GitUri.fromFile(fileName, repoPath, undefined)
@ -1656,7 +1653,7 @@ export class GitService implements Disposable {
if (status.indexStatus !== undefined) { if (status.indexStatus !== undefined) {
return { return {
current: GitUri.fromFile(fileName, repoPath, ref), current: GitUri.fromFile(fileName, repoPath, ref),
next: GitUri.fromFile(fileName, repoPath, GitService.stagedUncommittedSha)
next: GitUri.fromFile(fileName, repoPath, GitService.uncommittedStagedSha)
}; };
} }
} }
@ -1682,7 +1679,7 @@ export class GitService implements Disposable {
// editorLine?: number // editorLine?: number
): Promise<GitUri | undefined> { ): Promise<GitUri | undefined> {
// If we have no ref (or staged ref) there is no next commit // If we have no ref (or staged ref) there is no next commit
if (ref === undefined || ref.length === 0 || Git.isStagedUncommitted(ref)) return undefined;
if (ref === undefined || ref.length === 0 || Git.isUncommittedStaged(ref)) return undefined;
let filters: GitLogDiffFilter[] | undefined; let filters: GitLogDiffFilter[] | undefined;
if (ref === GitService.deletedOrMissingSha) { if (ref === GitService.deletedOrMissingSha) {
@ -1746,18 +1743,18 @@ export class GitService implements Disposable {
if (skip === 0) { if (skip === 0) {
return { return {
current: GitUri.fromFile(fileName, repoPath, ref), current: GitUri.fromFile(fileName, repoPath, ref),
previous: GitUri.fromFile(fileName, repoPath, GitService.stagedUncommittedSha)
previous: GitUri.fromFile(fileName, repoPath, GitService.uncommittedStagedSha)
}; };
} }
return { return {
current: GitUri.fromFile(fileName, repoPath, GitService.stagedUncommittedSha),
current: GitUri.fromFile(fileName, repoPath, GitService.uncommittedStagedSha),
previous: await this.getPreviousUri(repoPath, uri, ref, skip - 1, editorLine) previous: await this.getPreviousUri(repoPath, uri, ref, skip - 1, editorLine)
}; };
} }
} }
} }
else if (GitService.isStagedUncommitted(ref)) {
else if (GitService.isUncommittedStaged(ref)) {
const current = const current =
skip === 0 skip === 0
? GitUri.fromFile(fileName, repoPath, ref) ? GitUri.fromFile(fileName, repoPath, ref)
@ -1791,6 +1788,9 @@ export class GitService implements Disposable {
editorLine?: number editorLine?: number
): Promise<GitUri | undefined> { ): Promise<GitUri | undefined> {
if (ref === GitService.deletedOrMissingSha) return undefined; if (ref === GitService.deletedOrMissingSha) return undefined;
if (ref === GitService.uncommittedSha) {
ref = undefined;
}
if (ref !== undefined) { if (ref !== undefined) {
skip++; skip++;
@ -2130,14 +2130,14 @@ export class GitService implements Disposable {
): Promise<Uri | undefined> { ): Promise<Uri | undefined> {
if (ref === GitService.deletedOrMissingSha) return undefined; if (ref === GitService.deletedOrMissingSha) return undefined;
if (!ref || (Git.isUncommitted(ref) && !Git.isStagedUncommitted(ref))) {
if (!ref || (Git.isUncommitted(ref) && !Git.isUncommittedStaged(ref))) {
const data = await Git.ls_files(repoPath!, fileName); const data = await Git.ls_files(repoPath!, fileName);
if (data !== undefined) return GitUri.file(fileName); if (data !== undefined) return GitUri.file(fileName);
return undefined; return undefined;
} }
if (Git.isStagedUncommitted(ref)) {
if (Git.isUncommittedStaged(ref)) {
return GitUri.git(fileName, repoPath); return GitUri.git(fileName, repoPath);
} }
@ -2435,24 +2435,25 @@ export class GitService implements Disposable {
return Git.getEncoding(workspace.getConfiguration('files', uri).get<string>('encoding')); return Git.getEncoding(workspace.getConfiguration('files', uri).get<string>('encoding'));
} }
static deletedOrMissingSha = Git.deletedOrMissingSha;
static getGitPath = Git.getGitPath; static getGitPath = Git.getGitPath;
static getGitVersion = Git.getGitVersion; static getGitVersion = Git.getGitVersion;
static isShaLike = Git.isShaLike; static isShaLike = Git.isShaLike;
static isShaParent = Git.isShaParent; static isShaParent = Git.isShaParent;
static isStagedUncommitted = Git.isStagedUncommitted;
static isUncommitted = Git.isUncommitted; static isUncommitted = Git.isUncommitted;
static isUncommittedStaged = Git.isUncommittedStaged;
static uncommittedSha = Git.uncommittedSha;
static uncommittedStagedSha = Git.uncommittedStagedSha;
static shortenSha( static shortenSha(
ref: string | undefined, ref: string | undefined,
strings: { deletedOrMissing?: string; stagedUncommitted?: string; uncommitted?: string; working?: string } = {}
{
deletedOrMissing = '(deleted)',
...strings
}: { deletedOrMissing?: string; stagedUncommitted?: string; uncommitted?: string; working?: string } = {}
) { ) {
if (ref === undefined) return undefined;
strings = { deletedOrMissing: '(deleted)', working: emptyStr, ...strings };
if (ref == null || ref.length === 0) return strings.working;
if (ref === GitService.deletedOrMissingSha) return strings.deletedOrMissing;
if (ref === GitService.deletedOrMissingSha) return deletedOrMissing;
return Git.isShaLike(ref) || Git.isStagedUncommitted(ref) ? Git.shortenSha(ref, strings) : ref;
return Git.shortenSha(ref, strings);
} }
} }

+ 4
- 4
src/git/gitUri.ts View File

@ -68,7 +68,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
}); });
this.repoPath = data.repoPath; this.repoPath = data.repoPath;
if (GitService.isStagedUncommitted(data.ref) || !GitService.isUncommitted(data.ref)) {
if (GitService.isUncommittedStaged(data.ref) || !GitService.isUncommitted(data.ref)) {
this.sha = data.ref; this.sha = data.ref;
} }
@ -123,7 +123,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
}); });
this.repoPath = commitOrRepoPath.repoPath; this.repoPath = commitOrRepoPath.repoPath;
this.versionedPath = commitOrRepoPath.versionedPath; this.versionedPath = commitOrRepoPath.versionedPath;
if (GitService.isStagedUncommitted(commitOrRepoPath.sha) || !GitService.isUncommitted(commitOrRepoPath.sha)) {
if (GitService.isUncommittedStaged(commitOrRepoPath.sha) || !GitService.isUncommitted(commitOrRepoPath.sha)) {
this.sha = commitOrRepoPath.sha; this.sha = commitOrRepoPath.sha;
} }
} }
@ -257,7 +257,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
switch (data.ref) { switch (data.ref) {
case emptyStr: case emptyStr:
case '~': case '~':
ref = GitService.stagedUncommittedSha;
ref = GitService.uncommittedStagedSha;
break; break;
case null: case null:
@ -397,7 +397,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
} }
if (ref === undefined || GitService.isUncommitted(ref)) { if (ref === undefined || GitService.isUncommitted(ref)) {
if (GitService.isStagedUncommitted(ref)) {
if (GitService.isUncommittedStaged(ref)) {
return GitUri.git(fileName, repoPath); return GitUri.git(fileName, repoPath);
} }

+ 1
- 1
src/git/models/commit.ts View File

@ -98,7 +98,7 @@ export abstract class GitCommit {
private _isStagedUncommitted: boolean | undefined; private _isStagedUncommitted: boolean | undefined;
get isStagedUncommitted(): boolean { get isStagedUncommitted(): boolean {
if (this._isStagedUncommitted === undefined) { if (this._isStagedUncommitted === undefined) {
this._isStagedUncommitted = Git.isStagedUncommitted(this.sha);
this._isStagedUncommitted = Git.isUncommittedStaged(this.sha);
} }
return this._isStagedUncommitted; return this._isStagedUncommitted;
} }

+ 2
- 2
src/quickpicks/repoStatusQuickPick.ts View File

@ -54,7 +54,7 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
this.commit = new GitLogCommit( this.commit = new GitLogCommit(
GitCommitType.LogFile, GitCommitType.LogFile,
status.repoPath, status.repoPath,
GitService.stagedUncommittedSha,
GitService.uncommittedStagedSha,
'You', 'You',
undefined, undefined,
new Date(), new Date(),
@ -82,7 +82,7 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
[status], [status],
status.status, status.status,
status.originalFileName, status.originalFileName,
realIndexStatus !== undefined ? GitService.stagedUncommittedSha : 'HEAD',
realIndexStatus !== undefined ? GitService.uncommittedStagedSha : 'HEAD',
status.fileName status.fileName
); );
} }

+ 2
- 2
src/views/nodes/fileHistoryNode.ts View File

@ -41,14 +41,14 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
if (status.workingTreeStatus !== undefined) { if (status.workingTreeStatus !== undefined) {
sha = GitService.uncommittedSha; sha = GitService.uncommittedSha;
if (status.indexStatus !== undefined) { if (status.indexStatus !== undefined) {
previousSha = GitService.stagedUncommittedSha;
previousSha = GitService.uncommittedStagedSha;
} }
else if (status.workingTreeStatus !== '?') { else if (status.workingTreeStatus !== '?') {
previousSha = 'HEAD'; previousSha = 'HEAD';
} }
} }
else { else {
sha = GitService.stagedUncommittedSha;
sha = GitService.uncommittedStagedSha;
previousSha = 'HEAD'; previousSha = 'HEAD';
} }

+ 3
- 3
src/views/nodes/statusFilesNode.ts View File

@ -67,12 +67,12 @@ export class StatusFilesNode extends ViewNode {
older.setMilliseconds(older.getMilliseconds() - 1); older.setMilliseconds(older.getMilliseconds() - 1);
return [ return [
this.toStatusFile(s, GitService.uncommittedSha, GitService.stagedUncommittedSha),
this.toStatusFile(s, GitService.stagedUncommittedSha, 'HEAD', older)
this.toStatusFile(s, GitService.uncommittedSha, GitService.uncommittedStagedSha),
this.toStatusFile(s, GitService.uncommittedStagedSha, 'HEAD', older)
]; ];
} }
else if (s.indexStatus !== undefined) { else if (s.indexStatus !== undefined) {
return [this.toStatusFile(s, GitService.stagedUncommittedSha, 'HEAD')];
return [this.toStatusFile(s, GitService.uncommittedStagedSha, 'HEAD')];
} }
return [this.toStatusFile(s, GitService.uncommittedSha, 'HEAD')]; return [this.toStatusFile(s, GitService.uncommittedSha, 'HEAD')];

Loading…
Cancel
Save