Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] File is listed in the "Changes" section even if it has no change #133417

Closed
wenfangdu opened this issue Sep 20, 2021 · 7 comments
Closed

[Bug] File is listed in the "Changes" section even if it has no change #133417

wenfangdu opened this issue Sep 20, 2021 · 7 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@wenfangdu
Copy link
Contributor

wenfangdu commented Sep 20, 2021

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: v1.61.0-insider
  • OS Version: Windows 10

File encoding is UTF-8 with BOM.

Steps to Reproduce:

  • STG 2021-09-20 09_55_48

  • Notice the diff editor in the "Changes" (Not "Staged Changes") section shows no change, but the file is still listed there nonetheless.

@hamzawaleed0102
Copy link

@wenfangdu I'm unable to figure out whats wrong here 😕 I mean you added a new line and then staged the changes, then under diff viewer its reflecting that exact new line change. That's perfectly fine 🤔 . Pardon me if I missed something?

@wenfangdu
Copy link
Contributor Author

@Lemmingh @hamzawaleed0102 Please see the updated issue, and remove the "confused" emoji if it's clear for you now.

@wenfangdu wenfangdu changed the title [Bug] Diff shows there's change but there's none [Bug] File is listed in the "Changes" section even if it has no change Sep 20, 2021
@hamzawaleed0102
Copy link

@wenfangdu Oh got it, now makes sense. I'm not a pro in it so I need to see whether it's a bug or expected behaviour. After all changing the file encoding is still a change but sometimes not a visible one.

@wenfangdu
Copy link
Contributor Author

@hamzawaleed0102 It's reproducible for new files with utf8bom encoding as well, i.e. no change for the encoding.

@Lemmingh
Copy link
Contributor

OK. I can tell what happened. But I'm not sure who is to blame: VS Code, Git, or ConHost.

When invoking "Git: Stage Selected Ranges" (git.stageSelectedRanges), VS Code runs:

git hash-object --stdin -w --path test.ahk

Inspect the created object, and we can surprisingly find that it does not have BOM.

You can get a visual hint by:

git status --verbose

@Lemmingh
Copy link
Contributor

/duplicate #111915

async stage(path: string, data: string): Promise<void> {
const child = this.stream(['hash-object', '--stdin', '-w', '--path', sanitizePath(path)], { stdio: [null, null, null] });
child.stdin!.end(data, 'utf8');
const { exitCode, stdout } = await exec(child);
const hash = stdout.toString('utf8');

The encoding information is lost.

I can also reproduce the problem with GB 2312.

锟斤拷

@eamodio eamodio assigned lszomoru and unassigned eamodio Oct 7, 2021
@eamodio eamodio added the *duplicate Issue identified as a duplicate of another issue(s) label Oct 7, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

6 participants
@eamodio @lszomoru @wenfangdu @Lemmingh @hamzawaleed0102 and others