Repository: vscode
Issue: Git - Pull and Sync  fails when name of tracking branch differs from name of tracked branch on remote
Labels: bug,git


Issue Type: <b>Bug</b>

I have several branches that have another name, or rather path, in the upstream repository, e.g. local branch `foo` pushes to and fetches from branch `path/to/foo` in the upstream repository. But the tracking branch is `upstream/foo`, so the tracking branch path doesn't reflect the upstream branch path.

With this setup, the `git.pull` and `git.sync` commands fail with a message "Git: fatal: couldn't find remote ref foo".

Studying the code, I found that the bug is either at extensions/git/src/git.ts, lines 1462 - 1470, https://github.com/Microsoft/vscode/blob/c63c97c12848e85769e717209b73110e83c18ef6/extensions/git/src/git.ts#L1462-L1470
or at extensions/git/src/repository.ts, lines 924, 944 and 1006,
https://github.com/Microsoft/vscode/blob/c63c97c12848e85769e717209b73110e83c18ef6/extensions/git/src/repository.ts#L924
https://github.com/Microsoft/vscode/blob/c63c97c12848e85769e717209b73110e83c18ef6/extensions/git/src/repository.ts#L944
https://github.com/Microsoft/vscode/blob/c63c97c12848e85769e717209b73110e83c18ef6/extensions/git/src/repository.ts#L1006

Should the `name` field in the `upstream` object really be the name of the remote tracking branch? Shouldn't it be the name of the tracked branch on the remote? Or should the `upstream` object contain another field storing the name of the tracked branch on the remote which then should be used at extensions/git/src/repository.ts, lines 924, 944 and 1006?

VS Code version: Code 1.31.1 (1b8e8302e405050205e69b59abb3559592bb9e60, 2019-02-12T02:20:54.427Z)
OS version: Windows_NT x64 10.0.17134

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz (4 x 2592)|
|GPU Status|2d_canvas: enabled<br>checker_imaging: disabled_off<br>flash_3d: enabled<br>flash_stage3d: enabled<br>flash_stage3d_baseline: enabled<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>native_gpu_memory_buffers: disabled_software<br>rasterization: enabled<br>surface_synchronization: enabled_on<br>video_decode: enabled<br>webgl: enabled<br>webgl2: enabled|
|Memory (System)|7.89GB (0.31GB free)|
|Process Argv|c:\Users\perpe\OneDrive - Adaptive Simulations Sweden AB\Source\VSCode Workspaces\NewPostProcessing.code-workspace|
|Screen Reader|no|
|VM|0%|

</details><details><summary>Extensions (55)</summary>

Extension|Author (truncated)|Version
---|---|---
calculate|aca|2.1.0
Bookmarks|ale|10.2.2
project-manager|ale|10.3.2
code-gnu-global|aus|0.2.2
awarest-align|awa|1.1.0
path-intellisense|chr|1.4.2
ssh|chr|0.0.4
bracket-pair-colorizer|Coe|1.0.61
vscode-markdownlint|Dav|0.25.0
empty-indent|Dmi|0.2.0
vscode-gitignore-syntax|dun|0.1.2
gitlens|eam|9.5.1
tslint|eg2|1.0.43
hungry-backspace|ekl|1.0.0
prettier-vscode|esb|1.8.1
vscode-pyvmmonitor|fab|0.0.3
file-icons|fil|1.0.16
matlab|Gim|0.9.0
todo-tree|Gru|0.0.124
rest-client|hum|0.21.2
python-coding-conventions|igr|0.0.4
latex-workshop|Jam|6.1.0
vscode-jira|Kni|0.6.0
rest-client|Kro|0.18.3
git-tree-compare|let|1.5.0
Star|lip|0.0.3
remotefs|lix|0.0.13
vscode-smart-column-indenter|lmc|0.0.13
vscode-3dviewer|md2|1.0.0
rainbow-csv|mec|1.0.0
git-graph|mhu|1.4.1
vscode-deploy-reloaded|mkl|0.87.2
vscode-remote-workspace|mkl|0.41.0
prettify-json|moh|0.0.3
python|ms-|2019.2.5558
cpptools|ms-|0.21.0
Go|ms-|0.9.2
printcode|nob|3.0.0
indent-rainbow|ode|7.3.0
vscode-code-outline|pat|0.2.1
vscode-versionlens|pfl|0.22.0
material-icon-theme|PKi|3.6.3
quicktype|qui|12.0.46
datetime|rid|1.0.5
vscode-paste-and-indent|Rub|0.0.8
copy-text|sal|0.4.3
gitconfig|sid|2.0.0
open-file-between-two-folder|sky|0.0.1
vscode-hexdump|sle|1.7.2
python|tht|0.2.3
hosts|tom|1.1.1
python-extended-snippets|tus|0.0.1
vscodeintellicode|Vis|1.1.4
vscode-todo-highlight|way|1.0.4
pull-requester|yos|0.1.5


</details>
<!-- generated by issue reporter -->