diff --git a/src/gitManager/isomorphicGit.ts b/src/gitManager/isomorphicGit.ts index 31e761d..cf294d4 100644 --- a/src/gitManager/isomorphicGit.ts +++ b/src/gitManager/isomorphicGit.ts @@ -824,11 +824,18 @@ export class IsomorphicGit extends GitManager { const [remote, branch] = splitRemoteBranch(remoteBranch); const branchInfo = await this.branchInfo(); + await this.wrapFS( + git.push({ + ...this.getRepo(), + remote: remote, + remoteRef: branch, + }) + ); + await this.setConfig( `branch.${branchInfo.current}.merge`, `refs/heads/${branch}` ); - await this.setConfig(`branch.${branch}.remote`, remote); } updateGitPath(_: string): Promise { diff --git a/src/gitManager/simpleGit.ts b/src/gitManager/simpleGit.ts index 41a6e82..e0f42c6 100644 --- a/src/gitManager/simpleGit.ts +++ b/src/gitManager/simpleGit.ts @@ -829,14 +829,12 @@ export class SimpleGit extends GitManager { try { // git 1.8+ await this.git.branch(["--set-upstream-to", remoteBranch]); - } catch (e) { - console.error(e); + } catch { try { // git 1.7 - 1.8 await this.git.branch(["--set-upstream", remoteBranch]); - } catch (e) { - console.error(e); - // fallback + } catch { + // fallback for when setting upstream branch to a branch that does not exist on the remote yet. Setting it with push instead. await this.git.push( // @ts-expect-error A type error occurs here because the third element could be undefined. // However, it is unlikely to be undefined due to the `remoteBranch`'s format, and error handling is in place. diff --git a/src/ui/modals/generalModal.ts b/src/ui/modals/generalModal.ts index e2040e6..5f8964b 100644 --- a/src/ui/modals/generalModal.ts +++ b/src/ui/modals/generalModal.ts @@ -37,14 +37,13 @@ export class GeneralModal extends SuggestModal { } openAndGetResult(): Promise { - if (this.config.initialValue != undefined) { - this.inputEl.value = this.config.initialValue; - this.inputEl.dispatchEvent(new Event("input")); - } - return new Promise((resolve) => { this.resolve = resolve; this.open(); + if (this.config.initialValue != undefined) { + this.inputEl.value = this.config.initialValue; + this.inputEl.dispatchEvent(new Event("input")); + } }); }