microsoft / vscode

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

git.rebasewhensync setting attempts a rebase when there is nothing to pull #168045

Open Shaddix opened 1 year ago

Shaddix commented 1 year ago

Type: Bug

  1. Use git.rebasewhensync: true.
  2. Create branch 'test' from Master, commit something to branch 'test'
  3. Commit something to Master
  4. Switch to branch 'test'
  5. Merge changes from Master to 'test' branch. Merge-commit is created
  6. Press 'Sync' button. EXPECTED: changes are pushed, Merge commit is preserved ACTUAL: rebase is performed, Merge commit is not present

For me this seems like a duplicate of #149124

VS Code version: Code 1.73.1 (6261075646f055b99068d3688932416f2346dd3b, 2022-11-09T04:27:29.066Z) OS version: Windows_NT x64 10.0.22000 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz (16 x 3792)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|undefined| |Memory (System)|31.82GB (6.53GB free)| |Process Argv|--crash-reporter-id 29c5a4ee-6c8e-43e6-b5dc-b3efa808b624| |Screen Reader|no| |VM|0%|
Extensions (15) Extension|Author (truncated)|Version ---|---|--- vscode-pull-request-azdo|ank|0.0.25 vscode-css-modules|cli|0.4.2 csharpier-vscode|csh|1.3.5 vscode-eslint|dba|2.2.6 gitlens|eam|13.1.1 prettier-vscode|esb|9.10.3 dotnet|for|0.0.4 dotnet-test-explorer|for|0.7.8 vscode-scss|mrm|0.10.0 vscode-docker|ms-|1.23.1 csharp|ms-|1.25.2 playwright|ms-|1.0.1 remote-containers|ms-|0.262.3 remote-wsl|ms-|0.72.0 vscode-jest|Ort|4.6.0
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 pythondataviewer:30285071 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30410667 cppdebug:30492333 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 azure-dev_surveyone:30548225 pyindex848cf:30577861 nodejswelcome1:30587005 2e4cg342:30602488 gswce1:30612156 3d0df643:30613357 dbltrim-noruby:30604474 89544117:30613380 ```
Log of git commands when pressing 'Sync' ``` 2022-12-05 12:06:53.725 [info] > git log --oneline --cherry feature/36965-add-is-current-property...feature/36965-add-is-current-property@{upstream} -- [36ms] 2022-12-05 12:06:55.026 [info] > git ls-files --stage -- ***.ci\azure-pipelines.yml [25ms] 2022-12-05 12:06:55.055 [info] > git cat-file -s d2b5b12bec057ef5202fc2f8a8962c7b59a54d8a [27ms] 2022-12-05 12:06:55.099 [info] > git show --textconv :.ci/azure-pipelines.yml [35ms] 2022-12-05 12:06:55.308 [info] > git pull -r origin feature/36965-add-is-current-property [1579ms] 2022-12-05 12:06:55.308 [info] From https://dev.azure.com/**** * branch feature/36965-add-is-current-property -> FETCH_HEAD Rebasing (1/1) Successfully rebased and updated refs/heads/feature/36965-add-is-current-property. 2022-12-05 12:06:56.552 [info] > git ls-files --stage -- ***\.ci\azure-pipelines.yml [24ms] 2022-12-05 12:06:56.583 [info] > git cat-file -s d2b5b12bec057ef5202fc2f8a8962c7b59a54d8a [28ms] 2022-12-05 12:06:56.627 [info] > git show --textconv :.ci/azure-pipelines.yml [37ms] 2022-12-05 12:06:57.202 [info] > git push origin feature/36965-add-is-current-property:feature/36965-add-is-current-property [1891ms] 2022-12-05 12:06:57.202 [info] To https://dev.azure.com/*** 26dd442..c95e2aa feature/36965-add-is-current-property -> feature/36965-add-is-current-property ```
ekrapfl commented 1 year ago

I'll chime in that this is a pretty big issue. It can cause some weird issues in a scenario like so:

lszomoru commented 1 year ago

@Shaddix, @ekrapfl, apologies for not getting back to you on this until now. By default, when performing a rebase, git will ignore the local merge commits and drop them from the todo list as documented here. I believe that the ask here is to have the ability (probably trough a setting) to control how merge commits are being handled during a rebase operation.

Shaddix commented 1 year ago

yep. I just tested my situation, and saw that currently the following was run by VSCode git pull --tags -r origin vs-rebase-test If I manually run git pull --tags --rebase=merges origin vs-rebase-test then everything is ok.

So basically having a setting that controls the parameter of --rebase option would fix that for me

ipcjs commented 1 year ago

Set git.rebaseWhenSync to false and configure git config pull.rebase merges. This can temporarily prevent the issue.

Shaddix commented 1 year ago

@ipcjs but what happens in this case if I'm on develop branch, I have some local commits, and remote have some new commits as well? In this case when I press 'sync' button I'd expect a rebase, but my guess I will get a merge commit, no?

ipcjs commented 1 year ago

@Shaddix you will get a rebase https://git-scm.com/docs/git-pull#Documentation/git-pull.txt---rebasefalsetruemergesinteractive

Shaddix commented 1 year ago

thanks! gonna try