mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Git - fix discard changes when the repository does not have an initial commit (#169397)
This commit is contained in:
parent
cbf23d1500
commit
c180a08350
1
extensions/git/src/api/git.d.ts
vendored
1
extensions/git/src/api/git.d.ts
vendored
|
@ -352,5 +352,6 @@ export const enum GitErrorCodes {
|
|||
UnknownPath = 'UnknownPath',
|
||||
EmptyCommitMessage = 'EmptyCommitMessage',
|
||||
BranchFastForwardRejected = 'BranchFastForwardRejected',
|
||||
BranchNotYetBorn = 'BranchNotYetBorn',
|
||||
TagConflict = 'TagConflict'
|
||||
}
|
||||
|
|
|
@ -1455,6 +1455,8 @@ export class Repository {
|
|||
if (/Please,? commit your changes or stash them/.test(err.stderr || '')) {
|
||||
err.gitErrorCode = GitErrorCodes.DirtyWorkTree;
|
||||
err.gitTreeish = treeish;
|
||||
} else if (/You are on a branch yet to be born/.test(err.stderr || '')) {
|
||||
err.gitErrorCode = GitErrorCodes.BranchNotYetBorn;
|
||||
}
|
||||
|
||||
throw err;
|
||||
|
|
|
@ -1457,7 +1457,13 @@ export class Repository implements Disposable {
|
|||
});
|
||||
|
||||
await this.repository.clean(toClean);
|
||||
await this.repository.checkout('', toCheckout);
|
||||
try {
|
||||
await this.repository.checkout('', toCheckout);
|
||||
} catch (err) {
|
||||
if (err.gitErrorCode !== GitErrorCodes.BranchNotYetBorn) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
await this.repository.updateSubmodules(submodulesToUpdate);
|
||||
|
||||
this.closeDiffEditors([], [...toClean, ...toCheckout]);
|
||||
|
|
Loading…
Reference in a new issue