microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.16k stars 28.53k forks source link

Pull and Sync fails when name of tracking branch differs from name of tracked branch on remote #70136

Open md2perpe opened 5 years ago

md2perpe commented 5 years ago

Issue Type: Bug

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

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz (4 x 2592)| |GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
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%|
Extensions (55) 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
vscodebot[bot] commented 5 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

joaomoreno commented 5 years ago

What does git rev-parse --symbolic-full-name foo@{u} return? Also what does git remote -vvv return? Also what does git config push.default return?

md2perpe commented 5 years ago

What does git rev-parse --symbolic-full-name foo@{u} return?

refs/remotes/upstream/foo

Also what does git remote -vvv return?

upstream      https://upstream.server/path/to/repository (fetch)
upstream      https://upstream.server/path/to/repository (push)

Also what does git config push.default return?

(nothing)

I've here modified the answers because I don't want to make the URLs public. Maybe I should make a test with a public gist.

md2perpe commented 5 years ago

Here's a repository for testing: https://github.com/md2perpe/vscode-issue-70136/tree/master Instructions for reproduction are given in README.md.

In the local repository created the answers to your questions are as follows:

What does git rev-parse --symbolic-full-name foo@{u} return?

refs/remotes/upstream/foo

Also what does git remote -vvv return?

upstream        git@github.com:md2perpe/vscode-issue-70136.git (fetch)
upstream        git@github.com:md2perpe/vscode-issue-70136.git (push)

Also what does git config push.default return?

(nothing)

joaomoreno commented 5 years ago

What what's your git version?

md2perpe commented 5 years ago

I use latest git for Windows.

$ git --version
git version 2.21.0.windows.1
md2perpe commented 5 years ago

@joaomoreno Have you been able to reproduce?

joaomoreno commented 5 years ago

Not really... If you change push.default to upstream, does it work?

md2perpe commented 5 years ago

Using the command

git config push.default upstream

the following was added to .git/config:

[push]
    default = upstream

The error still occurs.

md2perpe commented 5 years ago

Did you follow my instructions to reproduce?

joaomoreno commented 5 years ago

Yup, I understand it now.

The way I see us fixing this is just to remove the arguments passed to git pull. Not sure I would do this for everyone though... so maybe a setting?