From 52ddefdce4300d91eba57336b27af1c7544424e5 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 31 Oct 2020 02:45:13 -0400 Subject: [PATCH] Fixes blank branch name before any commits --- src/git/git.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/git/git.ts b/src/git/git.ts index 68cecda..70965a2 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -1065,7 +1065,12 @@ export namespace Git { } catch (ex) { const msg: string = ex?.toString() ?? ''; if (GitErrors.badRevision.test(msg) || GitWarnings.noUpstream.test(msg)) { - return [ex.stdout, undefined]; + if (ex.stdout != null && ex.stdout.length !== 0) { + return [ex.stdout, undefined]; + } + + const defaultBranch = await config__get('init.defaultBranch', repoPath, { local: true }); + return [defaultBranch ?? 'main', undefined]; } if (GitWarnings.headNotABranch.test(msg)) {