Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions extensions/git/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3211,6 +3211,25 @@ export class Repository {
} catch { }
}

// Fallback for shallow clones: for-each-ref returns empty upstream
// fields, so we read the branch tracking config directly
if (!branch.upstream && branch.type === RefType.Head && branch.name) {
try {
const remoteResult = await this.exec(['config', '--get', `branch.${branch.name}.remote`]);
const mergeResult = await this.exec(['config', '--get', `branch.${branch.name}.merge`]);

const remote = remoteResult.stdout.trim();
const merge = mergeResult.stdout.trim();

if (remote && merge) {
const upstreamName = merge.startsWith('refs/heads/') ? merge.substring(11) : merge;
(branch as Mutable<Branch>).upstream = { remote, name: upstreamName };
}
} catch {
// No tracking config found, upstream remains undefined
}
}

return branch;
}

Expand Down