Skip to content

Commit e5d5317

Browse files
committed
.
1 parent 1571d4f commit e5d5317

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

dist/index.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -4799,9 +4799,11 @@ class GitCommandManager {
47994799
branchList(remote) {
48004800
return __awaiter(this, void 0, void 0, function* () {
48014801
const result = [];
4802-
// Note, this implementation uses "rev-parse --symbolic" because the output from
4802+
// Note, this implementation uses "rev-parse --symbolic-full-name" because the output from
48034803
// "branch --list" is more difficult when in a detached HEAD state.
4804-
const args = ['rev-parse', '--symbolic'];
4804+
// Note, this implementation uses "rev-parse --symbolic-full-name" because there is a bug
4805+
// in Git 2.18 that causes "rev-parse --symbolic" to output symbolic full names.
4806+
const args = ['rev-parse', '--symbolic-full-name'];
48054807
if (remote) {
48064808
args.push('--remotes=origin');
48074809
}
@@ -4812,6 +4814,12 @@ class GitCommandManager {
48124814
for (let branch of output.stdout.trim().split('\n')) {
48134815
branch = branch.trim();
48144816
if (branch) {
4817+
if (branch.startsWith('refs/heads/')) {
4818+
branch = branch.substr('refs/heads/'.length);
4819+
}
4820+
else if (branch.startsWith('refs/remotes/')) {
4821+
branch = branch.substr('refs/remotes/'.length);
4822+
}
48154823
result.push(branch);
48164824
}
48174825
}

src/git-command-manager.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ class GitCommandManager {
7777
async branchList(remote: boolean): Promise<string[]> {
7878
const result: string[] = []
7979

80-
// Note, this implementation uses "rev-parse --symbolic" because the output from
80+
// Note, this implementation uses "rev-parse --symbolic-full-name" because the output from
8181
// "branch --list" is more difficult when in a detached HEAD state.
82+
// Note, this implementation uses "rev-parse --symbolic-full-name" because there is a bug
83+
// in Git 2.18 that causes "rev-parse --symbolic" to output symbolic full names.
8284

83-
const args = ['rev-parse', '--symbolic']
85+
const args = ['rev-parse', '--symbolic-full-name']
8486
if (remote) {
8587
args.push('--remotes=origin')
8688
} else {
@@ -92,6 +94,12 @@ class GitCommandManager {
9294
for (let branch of output.stdout.trim().split('\n')) {
9395
branch = branch.trim()
9496
if (branch) {
97+
if (branch.startsWith('refs/heads/')) {
98+
branch = branch.substr('refs/heads/'.length)
99+
} else if (branch.startsWith('refs/remotes/')) {
100+
branch = branch.substr('refs/remotes/'.length)
101+
}
102+
95103
result.push(branch)
96104
}
97105
}

0 commit comments

Comments
 (0)