this post was submitted on 20 Nov 2024
861 points (97.5% liked)

Programmer Humor

19817 readers
71 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] Maven@lemmy.zip 59 points 1 month ago* (last edited 1 month ago) (2 children)

Here is the exact warning that a user had to click through in order to get to where they got:

The warning

[–] Semi_Hemi_Demigod@lemmy.world 89 points 1 month ago (1 children)

That's not a very good dialog box. He didn't make any changes, so discarding them doesn't sound like a problem.

There should be a notice when you enable source control that this will permanently delete all existing files with a checkbox (checked by default) that says "Add existing files to source control."

[–] Pyro@programming.dev 10 points 1 month ago* (last edited 1 month ago) (1 children)

~~He wouldn't have seen the "Discard Changes" button at all if source control wasn't already setup (and detected by VSCode).~~

~~No sane program will delete files when you initialize source control either.~~

As I found later, VSCode did have weird behaviors with source control back then. My experience is more with the latest versions.

[–] LordPassionFruit@lemm.ee 12 points 1 month ago (1 children)

My sibling ran into this issue once. I'm not sure if it's a setting or a default, but vscode would assume they were working in a blank repo until they made a commit.

Sounds like this person had the project (without source control) in another IDE, tried out VSCode, and it assumed that it was all 'changes'. I don't use VSCode, do I can't say for certain, but I know my sibling lost ~4 hours of project set up for the same reason (though they immediately realized it was their fault).

[–] Pyro@programming.dev 8 points 1 month ago

Reading your comment and #32459, I realize that VSCode source control did have some major issues back then.

It looks like they have improved though, as the latest VSCode I use doesn't auto-initialize repositories anymore.

[–] Beacon@fedia.io 6 points 1 month ago (2 children)

Hm ok yeah, that seems quite scary sounding so that i would strongly hesitate before clicking on "discard ALL changes". Still, I wonder if a second confirmation dialog with more information is warranted for a command that's so destructive.

[–] conciselyverbose@sh.itjust.works 58 points 1 month ago (3 children)

I wouldn't assume "discard changes" means "delete files that existed before the editor did".

[–] subignition@fedia.io 10 points 1 month ago (2 children)

It's changes from the prior commit in the repository, which, if they had not committed anything prior, would have been an empty directory.

This is perhaps a good lesson in teaching version control as its own concept rather than "streamlining it" by bundling it with an editor.

[–] conciselyverbose@sh.itjust.works 18 points 1 month ago (1 children)

You shouldn't be taking ownership of files and then deleting them without communication a hell of a lot better than that.

I understand what happened. I'm saying that if you're going to delete stuff that was there before the software was, your flow to adding a project should include suggesting a base level commit of everything that's there already.

[–] subignition@fedia.io 5 points 1 month ago (1 children)

That's definitely fair, creating a repository in a non-empty directory could definitely suggest auto-committing the current state if it doesn't already. I don't use VSCode so I wouldn't know.

Although now that I think about it, that could have been the intention here but not automatic, if that's why 5k+ files were staged without the user explicitly staging them. Extra tragic if that's the case.

[–] T156@lemmy.world 1 points 1 month ago (1 children)

Although now that I think about it, that could have been the intention here but not automatic, if that's why 5k+ files were staged without the user explicitly staging them. Extra tragic if that's the case.

From the git discussions around the issue, it wasn't that the files were automatically staged, but that the "discard all changes" feature invoked a git clean, and also deleted untracked files.

Since OP's project wasn't tracked, it got detonated.

[–] WolfLink@sh.itjust.works 2 points 1 month ago

Since OP's project wasn't tracked, it got detonated.

This is the biggest part of the problem. Using git directly, it just ignores files that aren’t tracked.

[–] Scubus@sh.itjust.works 0 points 1 month ago (2 children)

Ok then, the changes to the repository shouldve been discarded. Anything he uploaded shouldve been deleted from the server. Why were files on his local machine deleted?

[–] Zagorath@aussie.zone 8 points 1 month ago

The repository in Git isn't on the server, it's on your local machine.

[–] subignition@fedia.io 3 points 1 month ago (1 children)

What makes you think a server was involved here? It was a local repository, evidenced by the reporter's bewilderment that files can be deleted without going to the Recycle Bin first. Which tells us that in addition to VCS, they were unfamiliar with Windows as well.

[–] Scubus@sh.itjust.works 3 points 1 month ago (2 children)

Admittedly i dont use source control myself as im a hobbiest, but I didnt realize that git was local. As for the recycle bin bit, yeah theyre kinda dumb. Is source control different from git?

[–] subignition@fedia.io 4 points 1 month ago

Hobbyist myself so no worries! Git is one example of source control / version control software. You normally have your local working copy of a repository and then a remote where you push your changes when they are finished or to share them with others.

[–] WolfLink@sh.itjust.works 2 points 1 month ago* (last edited 1 month ago)

You may be confusing git with GitHub.

git is a version control tool that lets you keep and manage a history of the files you are editing

GitHub is a website (not directly affiliated with the group maintaining git) that lets you upload, backup, and share your code using the format used by the git tool.

source control just refers to software to manage your source code in some form. git is the most popular tool of its kind, but there are others, for example mercurial.

[–] Pyro@programming.dev 5 points 1 month ago (1 children)

It's not that. It means discard all changes made after the last change committed to this local repository.

[–] fahfahfahfah@lemmy.billiam.net 9 points 1 month ago

In this case it seems like it also performed a git clean and deleted his untracked files too. Someone actually opened a an issue to try and prevent the behaviour in the future

[–] TeamAssimilation@infosec.pub 8 points 1 month ago

I guess cancelling would go back to the "Then you want to commit all files?" dialog, which the user didn't want to, he just wanted to cancel whatever the IDE was trying to start.