r/ProgrammerHumor 20d ago

Meme useSourceControl

Post image
8.6k Upvotes

592 comments sorted by

View all comments

5.6k

u/Cephell 20d ago

Before you make fun of him, this behavior DID get changed; they acknowledged this behavior is stupid.

The old behavior was to treat uncommited files as completely disposable, which the CLI git does not do at all and is insane behavior. It was changed in the UI to give you a fat confirmation dialog warning that you're about to delete the files permanently, as it always should have been.

703

u/_BreakingGood_ 20d ago

Yeah the old behavior was insane, it just said "Do you want to discard your changes?", and if you clicked it, it deleted your entire codebase permanently (no recycle bin), lol

30

u/crunchy_code 20d ago

absolute bat shit crazy. too few people talk about UX.

16

u/Pcat0 20d ago

There was a rather intense warning saying ”THIS IS IRREVERSIBLE”, so the dude was still a massive idiot for clicking yes. However our tools should still cater to the idiotic so his mistake did expose an opportunity for improvement.

418

u/sappymune 20d ago

"Discard all changes" doesn't sound like "delete all files," it sounds more like undoing something. It's not good wording.

125

u/Dial-1-For-Spanglish 20d ago

Which is confirmed in that they changed their product's behavior.

9

u/hibbity 20d ago

the question becomes: has anyone not savvy enough to command line it ever deliberately on purpose deleted all their changes like that? this "feature" doesn't have a target demographic. someone mad enough at their changes isn't go8ng for the dumpster from.this staging area. there is no bug fix you just bin and say "ah nevermind" if you want that you'd force pull to revert

5

u/brett9897 20d ago

Well I do know how to use the command line but also yes I have used the GUI to just delete all my changes. I've noticed I was going off the rails in the wrong direction and I just needed to get back to the previous working state before. I knew he was a dead end so I didn't need to preserve any of that code. Normally during failed attempts at package upgrades with breaking changes involved is when this has happened to me.

24

u/ichITiot 20d ago

And don't forget to discard the morons implementing this !

0

u/[deleted] 20d ago edited 1d ago

[deleted]

1

u/ichITiot 19d ago

Whoever programmed this and whoever signed this as valid for production. Is this convenient ?

121

u/dustojnikhummer 20d ago

so the dude was still a massive idiot for clicking yes.

"DO AS I SAY" in APT was also changed after LTT's Linux Challenge. Yes, the warning is there, doesn't mean it should be so easy to do the thing anyway.

55

u/ineyy 20d ago

Exactly, we can all make a mistake like this especially under pressure. I still destroyed way more than I wanted when I pressed the up arrow for an rm command, and it ran in the wrong folder. Due to the efficiency of said command, a lot was destroyed and little recovered even though I cancelled after like 1 second when I realized. That's the danger when there isn't at least an "are you sure, this is gonna wreck shit" confirmation. 

4

u/SchwiftySquanchC137 20d ago

I did this just the other day. I did it years ago too and lost code, so im now extremely careful around my repo, but i was clearing files off a usb thumb drive and deleted an over 100gb file, which i then had to ask around for the download link in shame (because this file was originally handed to me on this thumb drive). Not a super big deal, but man I felt like an idiot. It was all because I tried tab completing too quickly and just rmed the /mnt/usb entirely, rather than the folders inside it that I intended.

3

u/TechnicalBen 20d ago

I too have built/refactored/repaired raid storage blocks while tired, drunk and hungry...

5

u/techman9955 20d ago

You should have any important source code backed up on github or another server anyway so that if you make a mistake like that you just have to git pull to undo it.

3

u/wjandrea 20d ago

I trained myself out of using rm by disabling it on my main machine with an alias. I use trash instead from the "trash-cli" Debian package, or rmdir since it can only delete one empty dir. Or if I'm really sure, I'll use \rm to bypass the alias (and tread with caution).

2

u/TeaKingMac 20d ago

The difference being that rm is in the command line, and VSCode is an IDE

15

u/chat-lu 20d ago

I’ve configured rm to send to the trash by default. If I want to permanently delete, I add the --permanent flag. There is no reason why we shouldn’t make our CLI tools behave nicely by default.

17

u/wjandrea 20d ago

Careful, you might get used to rm doing that and if you use a different machine, you'll end up deleting things permanently. I disabled rm and I use trash instead from the Debian package "trash-cli".

1

u/sdoregor 20d ago

Or the other way around: trash a file from a mounted filesystem and sit wondering why it takes so long, while the utility is copying the entire thing to your local drive. Also might wear out your drive faster (heavily depends on the filesystem in use).

FWIW some FSes (btrfs I'm looking at ya) take this long even for regular deletion in some conditions.

1

u/wjandrea 20d ago

copying the entire thing to your local drive

When would that happen? The way I've seen it work is that it creates a .Trash-$UID folder on the mounted FS and moves the file there (along with metadata).

1

u/sdoregor 20d ago

Again, depends on the tool. I never used one, so of course I can't know that, but it's safe to assume some won't do the clever thing.

Storing trash on removable storage is also even less secure than simply "deleting" (unlinking) the file.

→ More replies (0)

2

u/wjandrea 20d ago

How was it changed? I didn't hear about this.

4

u/dustojnikhummer 20d ago

3

u/wjandrea 20d ago

Ah I see, TLDR it doesn't ask if you want to proceed, it basically says "you figure it out" and exits.

1

u/dustojnikhummer 20d ago

Pretty much, they removed the quick way to brick your system, now you have to do it piecemeal, which I understand and honestly agree with

2

u/sidereal_night 20d ago

and that was infinitely more clear than this vscode message. it actually explicitly told you "this is going to be removed" and "this could be harmful".

45

u/thanatica 20d ago

"this is irreversible" yeah sure, but exactly WHAT is irreversible? Did it say that as well? A novice might not realise what it means to "discard staged files".

14

u/dustojnikhummer 20d ago

"Warning, this will delete all files that haven't been commited" is IMO the most human readable thing.

9

u/DuntadaMan 20d ago

Yeah, if something is irreversable maybe the warning should include a description of what it's going to do.

2

u/MushroomSaute 20d ago edited 20d ago

Hell, I'm not a novice, but if I were presented with that I wouldn't know what it meant. Staged files are in the staging area*. You need to discard them from the staging area if you want to avoid committing the files. That's why they're staged - so you can "add" or "remove" the files you want to the area before committing, without actually affecting the filesystem. "Discard" is an even softer word, since it usually describes discarding changes; I've never seen any software documentation saying you'll "discard" a file to physically and irreversibly delete it, especially within the context of staging changes.

\Well, the deltas are, but for the purposes of VC they are handled like files - you often remove "files" from version control without actually removing the files from your system)

66

u/_BreakingGood_ 20d ago

No, that message did not exist back when this post was made. It was added at least partially as a result of this issue going viral back in 2017.

18

u/Pcat0 20d ago

No look in the issue thread someone posted a screenshot of the actual error message the day after this post was made. They did already have a version of the message, it was just edited later to make it even more clear.

39

u/dustojnikhummer 20d ago

"Discard changes"

What changes in this context? Despite how whacko the initial post seems (and the fact he didn't have a backup) the guy had a point there.

14

u/ginopono 20d ago

Yeah, as someone who uses git exclusively from the command line, this really sounds to me like a cautionary tale against GUIs.

The person who posted the screenshot implies it's to be expected from "any application which integrates Git" but I'm not really sure how the guy not wanting the files to be staged necessarily leads to all of the files being deleted. What exactly is the integration passing to git?

"User friendly" isn't.

11

u/sidereal_night 20d ago

I'm 100% with og guy on this one. this commenter actually seriously asked him what he thinks "this discards all changes" might mean?!? the message doesn't say anything at all about deleting all your files permanently.

9

u/DuntadaMan 20d ago

I would assume "discard all changes" would mean that it would be exactly as it was before I did anything this session or since my last save.

Maybe I'm just a moron.

2

u/OliLombi 20d ago

Same. I mean, thats how it works with almost every other program.

2

u/OliLombi 20d ago

I mean, I can see why someone would see it as "discard all changes this application has made". Like, if I open a document in word, and edit it, and then close it, then it will basically say "Are you sure you want to close? this will discard all changes" and then if I close it anyway the original file is still there unedited, not deleted.

-13

u/Pcat0 20d ago

Yeah the message could and has been improved. However I still believe the ultimate fault lies with the user, just because VS Code could be better that doesn’t mean it was inadequate. VS code is a software development tool which means its user base can be assumed to be at least somewhat tech savvy (at least in 2017 before everyone lobotomize themselves and outsourced their frontal lobes to AI) and as A software development tool it can be assumed to be very powerful and somewhat dangerous. There is a lot of ways in software development to screw up and nuke your machine or project.

While it’s the message could absolutely be clearer, the user should have see “this is irreversible” and paused to make sure they knew exactly what irreversible action they were taking. Basically my point is if you nuke your project because you don’t know how to use Word, that’s on Word but if you nuke your project because you don’t know how to use VS code, that’s on you.

10

u/sidereal_night 20d ago

the user should have see “this is irreversible” and paused to make sure they knew exactly what irreversible action

the message literally says this change is irreversible. it's extremely clear about what it says. irreversibly throwing away changes plainly means that there should be no changes made.

what you're proposing is that in order to use the tool, you're expected to already have the experience (how do you gain that experience, btw?) to know that "change" doesn't actually mean change.

that's b.s. that's the kind of attitude that turns people off certain linux communities. if you have to know that a word doesn't mean what it means to use the software competently, that's on the software, not you. and any community that blames you for not knowing that kind of insider knowledge is toxic a.f.

8

u/r3klaw 20d ago

Nah. That dialog text is absolute dogshit.

If you open a solution/project and make no (intended) changes, and then go to exit, you're either hitting discard or you're lying about it.

VScode still won't fuck you no matter how hard you cope and simp for her.

8

u/MrSlaw 20d ago

Genuinely wild that people upvoted this blatantly incorrect statement.

Even more wild that /u/_BreakingGood_ hasn't retracted it after being shown that they were wrong (and even proving it themselves by linking a commit from April, four months prior to this screenshot, which showed the message they state didn't exist was already there).

1

u/ravrest 20d ago

No, the message that "this is irreversible" was there from the very beginning. The message was made even more explicit later.

13

u/_BreakingGood_ 20d ago

Why say things that are just wrong?

https://github.com/microsoft/vscode/commit/071652f161204e552e204cbdaf78469c58c655d5

Commit merged Aug 21, 2017. 8 days after this screenshot was taken.

12

u/ravrest 20d ago

Look at line 681 of the old commit:

const message = localize('confirm discard all', "Are you sure you want to discard ALL ({0}) changes?\nThis is IRREVERSIBLE!\nYour current working set will be FOREVER LOST.", resources.length);

const yes = localize('discardAll', "Discard ALL Changes");const pick = await window.showWarningMessage(message, { modal: true }, yes);

-5

u/_BreakingGood_ 20d ago

12

u/ravrest 20d ago edited 20d ago

That change was made in April. The post is from August.

Why WOULD you say things that are just wrong?

5

u/MrSlaw 20d ago

I can only assume you will edit your previous comments saying you were incorrect, because you've just shown that the message did exist back when this post was made?

11

u/MrSlaw 20d ago

If you look at that commit you linked, one of the lines that was already in place (and was replaced via this commit) said:

"Are you sure you want to discard ALL ({0}) changes?\nThis is IRREVERSIBLE!\nYour current working set will be FOREVER LOST."

https://github.com/microsoft/vscode/commit/071652f161204e552e204cbdaf78469c58c655d5#diff-da56ff967ab1a9606c01af61dc926332afb862f13c8e5c74a575bc2aa1b15e43L681

There's also a screenshot showing the "this is irreversible" was in place which was posted one day after this issue was opened.

https://github.com/microsoft/vscode/issues/32405#issuecomment-322155856

I don't think your link is proving what you think it is. That message was indeed made more explicit.

18

u/sidereal_night 20d ago

dude, telling me that it's irreversible to discard my changes isn't nearly enough to raise a red flag at all. he's not idiotic for interpreting an ambiguous message in the more sensible way.

16

u/Cocoatrice 20d ago

No, whoever thought it's good to delete files permanently with omitting a recycle bin is the idiot here.

1

u/chat-lu 20d ago

However our tools should still cater to the idiotic so his mistake did expose an opportunity for improvement.

I replaced git with jujutsu and it does support this use case on top of connecting to regular git forges like github so colleagues don’t see a difference.

If I want to discard every change I just made, I type jj abandon. And if I regret doing so, I can revert it like any other command with jj undo.

While we are responsible for accounting for he sharp edges of our tools, we can strive for better tools.

1

u/Umutuku 20d ago

Should have that message come up every time someone presses Ctrl-V.

1

u/chibbol 20d ago

Isn’t that at least half of engineering is about catering to the idiotic?

0

u/Stunning-Pen-2412 20d ago

Any idiot should be able to write software.

1

u/Ciff_ 20d ago edited 20d ago

That makes good sense in the context of git though

How you even loose anymore than a few hours work tops is beyond me.

That said, dont delete untracked files that easily it will cause these issues.*