Browse Source

Renames fakeSha to deletedSha

main
Eric Amodio 7 years ago
parent
commit
e05239499a
6 changed files with 14 additions and 14 deletions
  1. +1
    -1
      src/commands/diffLineWithPrevious.ts
  2. +8
    -8
      src/commands/diffWith.ts
  3. +2
    -2
      src/commands/diffWithPrevious.ts
  4. +1
    -1
      src/gitContentProvider.ts
  5. +1
    -1
      src/gitService.ts
  6. +1
    -1
      src/views/gitExplorer.ts

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

@ -53,7 +53,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
const diffArgs: DiffWithCommandArgs = { const diffArgs: DiffWithCommandArgs = {
repoPath: args.commit.repoPath, repoPath: args.commit.repoPath,
lhs: { lhs: {
sha: args.commit.previousSha !== undefined ? args.commit.previousSha : GitService.fakeSha,
sha: args.commit.previousSha !== undefined ? args.commit.previousSha : GitService.deletedSha,
uri: args.commit.previousUri uri: args.commit.previousUri
}, },
rhs: { rhs: {

+ 8
- 8
src/commands/diffWith.ts View File

@ -48,7 +48,7 @@ export class DiffWithCommand extends ActiveEditorCommand {
args = { args = {
repoPath: commit1.repoPath, repoPath: commit1.repoPath,
lhs: { lhs: {
sha: commit1.previousSha !== undefined ? commit1.previousSha : GitService.fakeSha,
sha: commit1.previousSha !== undefined ? commit1.previousSha : GitService.deletedSha,
uri: commit1.previousUri! uri: commit1.previousUri!
}, },
rhs: { rhs: {
@ -110,19 +110,19 @@ export class DiffWithCommand extends ActiveEditorCommand {
if (rhs === undefined) { if (rhs === undefined) {
rhsPrefix = 'deleted in '; rhsPrefix = 'deleted in ';
} }
else if (lhs === undefined || args.lhs.sha === GitService.fakeSha) {
else if (lhs === undefined || args.lhs.sha === GitService.deletedSha) {
rhsPrefix = 'added in '; rhsPrefix = 'added in ';
} }
if (args.lhs.title === undefined && lhs !== undefined && args.lhs.sha !== GitService.fakeSha) {
if (args.lhs.title === undefined && lhs !== undefined && args.lhs.sha !== GitService.deletedSha) {
args.lhs.title = (args.lhs.sha === '' || GitService.isUncommitted(args.lhs.sha)) args.lhs.title = (args.lhs.sha === '' || GitService.isUncommitted(args.lhs.sha))
? `${path.basename(args.lhs.uri.fsPath)}` ? `${path.basename(args.lhs.uri.fsPath)}`
: `${path.basename(args.lhs.uri.fsPath)} (${GitService.shortenSha(args.lhs.sha)})`; : `${path.basename(args.lhs.uri.fsPath)} (${GitService.shortenSha(args.lhs.sha)})`;
} }
if (args.rhs.title === undefined && args.rhs.sha !== GitService.fakeSha) {
if (args.rhs.title === undefined && args.rhs.sha !== GitService.deletedSha) {
args.rhs.title = (args.rhs.sha === '' || GitService.isUncommitted(args.rhs.sha)) args.rhs.title = (args.rhs.sha === '' || GitService.isUncommitted(args.rhs.sha))
? `${path.basename(args.rhs.uri.fsPath)}`
: `${path.basename(args.rhs.uri.fsPath)} (${rhsPrefix}${GitService.shortenSha(args.rhs.sha)})`;
? `${path.basename(args.rhs.uri.fsPath)}`
: `${path.basename(args.rhs.uri.fsPath)} (${rhsPrefix}${GitService.shortenSha(args.rhs.sha)})`;
} }
const title = (args.lhs.title !== undefined && args.rhs.title !== undefined) const title = (args.lhs.title !== undefined && args.rhs.title !== undefined)
@ -131,10 +131,10 @@ export class DiffWithCommand extends ActiveEditorCommand {
return await commands.executeCommand(BuiltInCommands.Diff, return await commands.executeCommand(BuiltInCommands.Diff,
lhs === undefined lhs === undefined
? GitService.toGitContentUri(GitService.fakeSha, args.lhs.uri.fsPath, args.repoPath)
? GitService.toGitContentUri(GitService.deletedSha, args.lhs.uri.fsPath, args.repoPath)
: Uri.file(lhs), : Uri.file(lhs),
rhs === undefined rhs === undefined
? GitService.toGitContentUri(GitService.fakeSha, args.rhs.uri.fsPath, args.repoPath)
? GitService.toGitContentUri(GitService.deletedSha, args.rhs.uri.fsPath, args.repoPath)
: Uri.file(rhs), : Uri.file(rhs),
title, title,
args.showOptions); args.showOptions);

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

@ -38,7 +38,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
try { try {
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha; const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
if (sha === GitService.fakeSha) return Messages.showCommitHasNoPreviousCommitWarningMessage();
if (sha === GitService.deletedSha) return Messages.showCommitHasNoPreviousCommitWarningMessage();
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, sha, { maxCount: 2, range: args.range!, skipMerges: true }); const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, sha, { maxCount: 2, range: args.range!, skipMerges: true });
if (log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare'); if (log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
@ -59,7 +59,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
const diffArgs: DiffWithCommandArgs = { const diffArgs: DiffWithCommandArgs = {
repoPath: args.commit.repoPath, repoPath: args.commit.repoPath,
lhs: { lhs: {
sha: args.commit.previousSha !== undefined ? args.commit.previousSha : GitService.fakeSha,
sha: args.commit.previousSha !== undefined ? args.commit.previousSha : GitService.deletedSha,
uri: args.commit.previousUri uri: args.commit.previousUri
}, },
rhs: { rhs: {

+ 1
- 1
src/gitContentProvider.ts View File

@ -16,7 +16,7 @@ export class GitContentProvider implements TextDocumentContentProvider {
async provideTextDocumentContent(uri: Uri, token: CancellationToken): Promise<string | undefined> { async provideTextDocumentContent(uri: Uri, token: CancellationToken): Promise<string | undefined> {
const data = GitService.fromGitContentUri(uri); const data = GitService.fromGitContentUri(uri);
if (data.sha === GitService.fakeSha) return '';
if (data.sha === GitService.deletedSha) return '';
const fileName = data.originalFileName || data.fileName; const fileName = data.originalFileName || data.fileName;

+ 1
- 1
src/gitService.ts View File

@ -81,7 +81,7 @@ export interface GitChangeEvent {
export class GitService extends Disposable { export class GitService extends Disposable {
static emptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined); static emptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
static fakeSha = 'ffffffffffffffffffffffffffffffffffffffff';
static deletedSha = 'ffffffffffffffffffffffffffffffffffffffff';
static uncommittedSha = '0000000000000000000000000000000000000000'; static uncommittedSha = '0000000000000000000000000000000000000000';
config: IConfig; config: IConfig;

+ 1
- 1
src/views/gitExplorer.ts View File

@ -342,7 +342,7 @@ export class GitExplorer implements TreeDataProvider {
.map(s => GitUri.fromFileStatus(s, repoPath)); .map(s => GitUri.fromFileStatus(s, repoPath));
for (const uri of uris) { for (const uri of uris) {
await this.openDiffWith(repoPath, await this.openDiffWith(repoPath,
{ uri: uri, sha: node.commit.previousSha !== undefined ? node.commit.previousSha : GitService.fakeSha },
{ uri: uri, sha: node.commit.previousSha !== undefined ? node.commit.previousSha : GitService.deletedSha },
{ uri: uri, sha: node.commit.sha }, options); { uri: uri, sha: node.commit.sha }, options);
} }
} }

Loading…
Cancel
Save