mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Git - fix discard changes when the repository does not have an initial commit (#169397)
This commit is contained in:
Vendored
+1
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user