microsoft / vscode

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

Git: HEAD version shows wrong contents #89068

Closed jitendrapawar closed 11 months ago

jitendrapawar commented 4 years ago

Issue Type: Bug

  1. consider one file and do some changes on a particular file and commit it.
  2. Push that file to the repo.
  3. Again do some changes in that file but on some other line.
  4. Go to Source Control.
  5. You will see both earlier commit changes as well the current changes done. All will be shown as you have made both the changes now.

VS Code version: Code 1.41.1 (26076a4de974ead31f97692a0d32f90d735645c0, 2019-12-18T14:58:56.166Z) OS version: Windows_NT x64 10.0.17763

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (8 x 1896)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|7.88GB (0.20GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (7) Extension|Author (truncated)|Version ---|---|--- vscode-eslint|dba|2.0.14 gitlens|eam|10.2.0 vscode-cfn-lint|kdd|0.10.2 dotenv|mik|1.0.1 python|ms-|2020.1.58038 vscode-yaml|red|0.6.1 code-spell-checker|str|1.7.21
joaomoreno commented 4 years ago

Can you show me a screen recording of the issue? I'm not sure I fully understand it.

Adam13531 commented 4 years ago

I'm not the original filer, but I've been facing this problem on Windows 10 for the last week or two and I've had it happen several times while streaming. Here's a clip of the most recent time: https://clips.twitch.tv/GiantNastyChinchillaStrawBeary

EDIT: it was suggested to me that I paste the Git output log here. Here's the log leading up to the event (and then I actually committed at the end):

> git remote --verbose
> git config --get commit.template
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse ad-simplify-blockly
> git rev-parse --symbolic-full-name ad-simplify-blockly@{u}
> git rev-list --left-right ad-simplify-blockly...refs/remotes/origin/ad-simplify-blockly
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
> git config --get commit.template
> git show :TODO
> git show HEAD:packages/client/public/javascripts/setupblockly.js
> git status -z -u
> git symbolic-ref --short HEAD
> git show :packages/client/public/data/3-beginner-snippets.xml
> git show :packages/client/public/javascripts/constants.js
> git show :packages/client/public/javascripts/tutorial/campaign/magnetic_shutdown.js
> git show :packages/client/public/javascripts/tutorial/campaign/welcome_to_omegacorp.js
> git show HEAD:packages/client/public/javascripts/setupblockly.js
> git rev-parse ad-simplify-blockly
> git rev-parse --symbolic-full-name ad-simplify-blockly@{u}
> git rev-list --left-right ad-simplify-blockly...refs/remotes/origin/ad-simplify-blockly
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
> git config --get commit.template
> git show :TODO
> git add -A -- .
> git commit --quiet --allow-empty-message --file -

ANOTHER UPDATE (1/28/20): this happened to me today, so this time, while I was looking at stale results in the diff pane, I cleared my Git log, opened TortoiseGit's git log view, then waited for Visual Studio Code to show which commands it ran to fix everything, and it was these:

> git status -z -u
> git symbolic-ref --short HEAD
> git show HEAD:packages/client/public/javascripts/setupblockly.js
> git rev-parse ad-simplify-blockly
> git rev-parse --symbolic-full-name ad-simplify-blockly@{u}
> git rev-list --left-right ad-simplify-blockly...refs/remotes/origin/ad-simplify-blockly
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
> git config --get commit.template

UPDATE (2/21/20): this is still happening to me.

Riigess commented 4 years ago

Looking at the issue a little further, it appears that VSCode isn't pushing the commit to GitHub, and/or VSCode is not pulling the last local commit to "git diff" off of.

Reference hunt got me to looking at a method of code where all this does is commit - no git push attempt is made. Somewhere along the way, the intent to push to the repository is skipped and thus VSCode should be checking against the local commit reference, but that's not being done currently.

joaomoreno commented 4 years ago

@Adam13531 Awesome twitch video. Unfortunately this just looks like missing file events... which is always flaky. When you use Tortoise git, that fires more file events inside .git and we pick it up and refresh. I wonder if we could distill some steps from your setup, since you seem to hit this quite often?

lszomoru commented 11 months ago

Closing due to inactivity.