Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Ithaqua posted:

Agreed, that's the perfect case for a comment saying "this exists in this form because of reasons X, Y, Z."

In the .NET world, Visual Studio even shows you commit history hovering right above the class/method definition so you can pull up the previous implementation in a few clicks for comparison.

That sounds p deece, but the VS we have at work (2013) doesn't do that... or maybe Perforce doesn't offer this? Would be nice.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Ithaqua posted:

Agreed, that's the perfect case for a comment saying "this exists in this form because of reasons X, Y, Z."

In the .NET world, Visual Studio even shows you commit history hovering right above the class/method definition so you can pull up the previous implementation in a few clicks for comparison.

JetBrains stuff does something similar. Well at least PyCharm does, I can't remember if its in IntelliJ/WebStorm/etc, but I would assume so.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Hammerite posted:

That sounds p deece, but the VS we have at work (2013) doesn't do that... or maybe Perforce doesn't offer this? Would be nice.

It's part of CodeLens, which is in 2013 Ultimate (and 2015 Pro+). It only works for TFVC and Git, though.

itskage
Aug 26, 2003


Thermopyle posted:

JetBrains stuff does something similar. Well at least PyCharm does, I can't remember if its in IntelliJ/WebStorm/etc, but I would assume so.

I don't seem to have this in phpstorm, unless it's just not working.

down with slavery
Dec 23, 2013
STOP QUOTING MY POSTS SO PEOPLE THAT AREN'T IDIOTS DON'T HAVE TO READ MY FUCKING TERRIBLE OPINIONS THANKS

itskage posted:

I don't seem to have this in phpstorm, unless it's just not working.

select the method, right click, git -> show history for selection

itskage
Aug 26, 2003


Oh my god!

This is great.

QuarkJets
Sep 8, 2008

TheresaJayne posted:

What made me laugh was "at midnight dec 31st 1999 any plane in the air will suddenly turn off , and baby incubators and heart lung machines will stop working because they will think its 1900 and they didnt exist then so cannot continue to work"

ok so the reports and such will have an incorrect date, but why would that stop a heater keeping a constant temperature or stop fuel flowing into the plane engines?

Some of the claims were just stupid.. i mean what power station knows what to do just because it is a certain date.. time maybe, but date? WTF!!!

i write all of my code to check the current date and if the current date is before the code's last revision date then i start formatting the nearest disk

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



QuarkJets posted:

i write all of my code to check the current date and if the current date is before the code's last revision date then i start formatting the nearest disk

Same but emailing the data to China first

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

QuarkJets posted:

i write all of my code to check the current date and if the current date is before the code's last revision date then i start formatting the nearest disk

Bernard S. Greenberg came up with an interesting strategy to prevent that happening in Multics.

Ruzihm
Aug 11, 2010

Group up and push mid, proletariat!


itskage posted:

Oh my god!

:regd10:

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Factor Mystic posted:

http://blog.parse.com/learn/how-we-moved-our-api-from-ruby-to-go-and-saved-our-sanity/

Kind of an interesting & apropos article


Rails and/or webdevs ¯\_(ツ)_/¯


Rails does 10,000 things before your code, and this is good, except it is slow, which also... somehow doesn't mean rails is bad. Also, why in the world would anyone compare two backend languaegs for a website?? ¯\_(ツ)_/¯

Oh man this whole Go thing pissed so many people off. Introducing yet another language to FB's infra is exactly what people wanted to do with their day.

Steve French
Sep 8, 2003

ultramiraculous posted:

Oh man this whole Go thing pissed so many people off. Introducing yet another language to FB's infra is exactly what people wanted to do with their day.

I'd say it would be higher up on my list than dealing with rails.

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison

Bognar posted:

I think you should go a step further and remove the commented code entirely, but leave a note saying "This was changed from XXX on 06/06/06, see commit YYY for reference". All commented code is gone, but there's a trail for the developer to follow in case they need it. A datestamp lets them know how relevant it is.

What happens if you change your VCS? Becomes kinda less useful.

nielsm
Jun 1, 2009



uncurable mlady posted:

What happens if you change your VCS? Becomes kinda less useful.

And if you use a VCS with hashy revision IDs like git, and someone for some reason rewrites history (or even just yourself doing some rebasing shortly after writing those comments, before pushing them) you also risk them going bad.
Having a date of the change in the comment as well largely makes up for that, however.

brap
Aug 23, 2004

Grimey Drawer
It seems like git encourages "rewriting history" to somehow clarify the course of your project. I do not see the purpose of doing this unless something gets committed by accident and needs to be amended.

comedyblissoption
Mar 15, 2006

You should almost never rewrite the history of the main integration branch. However, when you work on a feature or something locally, you will end up with a series of commits that have not been integrated yet to the main branch. Sometimes you can make the history read better by amending or re-arranging the commits. This is usually accomplished with amend or rebase interactive.

comedyblissoption
Mar 15, 2006

I have often 'rewrote' history by realizing I need to refactor something or clean up a source file before I work on it while I am in the middle of working on a feature. The history and changes are much easier to read and review if you can separate out this refactoring from the changes required for the feature. So, I rebase the refactoring to happen before my feature's changes even though chronologically I did not actually work this way. Another benefit from doing this is that I can easily undo bad changes and go back to a good state w/ my refactorings without accidentally undoing my refactorings. This isn't some esoteric edge case thing b/c it's essentially part of my daily workflow whenever I clean up or refactor something.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
As above, I can turn a local history of

1) WIP
2) Added foo method
3) asdfhkdsa
4) quitting time
5) fix up: import asdf library
6) almost works
7) yessss

Into

1) Added foo method to the Bar implementation, which will aid in fizzing the zequod.
2) Full zequod implementation, as per feature request DILZ47.

Which looks more professional when sent upstream, and which functions correctly for each commit.

apseudonym
Feb 25, 2011

Rewrite aggressively until your commit is merged upstream and after that only if you really hate the people you work with.

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.

apseudonym posted:

Rewrite aggressively until your commit is merged upstream and after that only if you really hate the people you work with.

This. There's a few cases like "accidentally committed 10G of binaries" or "accidentally committed confidential data" where you will revise history of upstream but in general you never do it.

Your local branch? Go wild.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
I've often wondered why git doesn't keep a history file that shows history rewrites, rebases, etc. I fully understand it's a content-addressable file system and how the hashing works. My assumption is the history file would only preserve history for pushed branches.

But assuming the actual content didn't change (just the hash as a result of the parent hash changing) then it should be trivial for your client to realize you don't actually have three unmerged commits, your coworker just force pushed a rewritten history. Even if the content did change at least git could tell you that it's possibly the result of a rebase.

The whole rewriting of history seems like it should be a first-class citizen. I do it almost daily, yet one tiny mistake can completely screw up many people's day.

Pollyzoid
Nov 2, 2010

GRUUAGH you say?
Mercurial does history rewriting well with phases. Allows it by default on local commits, prevents it after they've been pushed (unless forced to).

Doctor w-rw-rw-
Jun 24, 2008

Ender.uNF posted:

I've often wondered why git doesn't keep a history file that shows history rewrites, rebases, etc.

git reflog isn't enough?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Doctor w-rw-rw- posted:

git reflog isn't enough?

I always read that as re-flog and I'm like, hasn't the repo history had enough punishment?

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Doctor w-rw-rw- posted:

git reflog isn't enough?

I want the (partial) reflog to be pushed and shared; any rewriting of history that involves already pushed commits should include a log of what was done and whether any content was changed in a commit (or just the parent hash).

I can sit down with a list of hashes and figure out what happened after a bad force push by a coworker. (Or in reality by matching up commit comments), why can't git just handle it for me? The answer is that it could, it just doesn't.

apseudonym
Feb 25, 2011

Ender.uNF posted:

I want the (partial) reflog to be pushed and shared; any rewriting of history that involves already pushed commits should include a log of what was done and whether any content was changed in a commit (or just the parent hash).

I can sit down with a list of hashes and figure out what happened after a bad force push by a coworker. (Or in reality by matching up commit comments), why can't git just handle it for me? The answer is that it could, it just doesn't.

Why should reflog info be pushed? Do you want to see twenty commits resulting from git commit --amend? Why? When should they get gc'd away since you're suddenly sharing a lot of garbage commits.

If you have a coworker screw you over with a force push you A) shame them B) use git rebase --onto to base your branch(es) off the new ToT after you shame them C) Shame them harder.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Ender.uNF posted:

I want the (partial) reflog to be pushed and shared; any rewriting of history that involves already pushed commits should include a log of what was done and whether any content was changed in a commit (or just the parent hash).

I can sit down with a list of hashes and figure out what happened after a bad force push by a coworker. (Or in reality by matching up commit comments), why can't git just handle it for me? The answer is that it could, it just doesn't.

It'd be really nice if unchanged commits could somehow retain their hashes, but as I understand, that would require completely different internals. Every time I've had to do a force push, it's been some really dumb thing like 20 commits back that just had to be done, and now all the following commits are changed too :shrug:

Makes sense though, deep down. Git can't know how whatever is in your local branches should be applied to a different history. What if the file your changes are on doesn't exist any more? Does that mean it's supposed to be completely gone, and your changes aren't important anymore, or does it mean that it has been refactored into several other things where your changes are still relevant? In the end, we annoyingly have to handle some of it manually.

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.

nielsm posted:

And if you use a VCS with hashy revision IDs like git, and someone for some reason rewrites history (or even just yourself doing some rebasing shortly after writing those comments, before pushing them) you also risk them going bad.
Having a date of the change in the comment as well largely makes up for that, however.

The discussion went off on a tangent, but note that if this is an issue or if you switch VCS or whatever, revision IDs are unique so you can write scripts to fix this up.

Coffee Mugshot
Jun 26, 2010

by Lowtax

Skuto posted:

The discussion went off on a tangent, but note that if this is an issue or if you switch VCS or whatever, revision IDs are unique so you can write scripts to fix this up.

As a practical example, when go moved from mercurial to gerrit git, they simply hid all cls behind golang.org/cl/# which decides if that commit belonged to mercurial, in which case it would be on codereview.appspot.com. Otherwise, it links to go-review.googlesource.com. This made it possible to migrate every issue from the code.google.com issue tracker to github's tracker without breaking any references to cls.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Using git sure sounds complicated. I mean it's like reading stuff written in a foreign language.

At our place we don't really make use of branches on a daily basis, it's used for release management and is something that the project managers do relatively infrequently and people doing maintenance work on the project not at all; work done on the project is just done on trunk. Is that really unusual or does git just push you into branching all the time?

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.
I guess everyone is rebasing all the time then? And nobody ever does a quick bug fix in the middle of their normal work?

I dunno that does sound really unusual. Branches in git are extremely well designed compared to some other VCS. The basic CLI commands are a bit weird but you only have to know like 3 or 4.

I wouldn't be surprised if the lack of using branches is what makes git seem complicated as you're likely abusing other features for the same effect.

Edit: Remote and remote tracking branches is a concept that may take a bit getting used to. I wish remote tracking branches contained their remotes' name by default, would probably help beginners a lot.

Hiowf fucked around with this message at 13:04 on Jun 14, 2015

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Skuto posted:

I guess everyone is rebasing all the time then? And nobody ever does a quick bug fix in the middle of their normal work?

I dunno that does sound really unusual. Branches in git are extremely well designed compared to some other VCS. The basic CLI commands are a bit weird but you only have to know like 3 or 4.

I wouldn't be surprised if the lack of using branches is what makes git seem complicated as you're likely abusing other features for the same effect.

Edit: Remote and remote tracking branches is a concept that may take a bit getting used to. I wish remote tracking branches contained their remotes' name by default, would probably help beginners a lot.

I don't know offhand what "rebasing" is. I took a quick look at this page but couldn't really follow what the difference is with just merging changes. It looks as though the codebase would end up in exactly the same state either way? Of course we do quick fixes of stuff in the middle of doing other things. I don't follow why you would think we don't.

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Hammerite posted:

Using git sure sounds complicated. I mean it's like reading stuff written in a foreign language.

At our place we don't really make use of branches on a daily basis, it's used for release management and is something that the project managers do relatively infrequently and people doing maintenance work on the project not at all; work done on the project is just done on trunk. Is that really unusual or does git just push you into branching all the time?
It's the same way around here, depends on the complexity of the project I guess. We're just doing routine maintenance work where changes rarely take multiple commits, so keeping a clean VCS history is of little concern as opposed to just getting stuff done.

SupSuper fucked around with this message at 14:37 on Jun 14, 2015

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

Hammerite posted:

I don't know offhand what "rebasing" is. I took a quick look at this page but couldn't really follow what the difference is with just merging changes. It looks as though the codebase would end up in exactly the same state either way? Of course we do quick fixes of stuff in the middle of doing other things. I don't follow why you would think we don't.

a merge literally merges two branches, it creates a special commit that has two parents rather than one (and whatever changes you did to fix merge conflicts). a rebase lops off a series of commits and makes the tail of the place you're rebasing onto the parent of the first commit you're rebasing. there's still only one parent for each commit. it's nice because you don't get merge commits everywhere but it does remove the history of the branch.... it's a preference thing really.

Coffee Mugshot
Jun 26, 2010

by Lowtax
git is good because branches are cheap as hell and this is a good feature for a time machine to have.

comedyblissoption
Mar 15, 2006

Snapchat A Titty posted:

It'd be really nice if unchanged commits could somehow retain their hashes, but as I understand, that would require completely different internals. Every time I've had to do a force push, it's been some really dumb thing like 20 commits back that just had to be done, and now all the following commits are changed too :shrug:

Makes sense though, deep down. Git can't know how whatever is in your local branches should be applied to a different history. What if the file your changes are on doesn't exist any more? Does that mean it's supposed to be completely gone, and your changes aren't important anymore, or does it mean that it has been refactored into several other things where your changes are still relevant? In the end, we annoyingly have to handle some of it manually.
The hashcode of a commit depending upon prior commits is explicitly a security measure and also to make it easier to detect persistence/disk errors. Security is also why author and other meta fields for a commit are part of the commit hashcode.

This is buried somewhere in this talk that Torvalds gave:
https://www.youtube.com/watch?v=4XpnKHJAok8

comedyblissoption
Mar 15, 2006

Hammerite posted:

Using git sure sounds complicated. I mean it's like reading stuff written in a foreign language.

At our place we don't really make use of branches on a daily basis, it's used for release management and is something that the project managers do relatively infrequently and people doing maintenance work on the project not at all; work done on the project is just done on trunk. Is that really unusual or does git just push you into branching all the time?
You can use git however you want and make it as complicated or uncomplicated as you want to fit your needs. Git works perfectly fine at replicating an SVN-like workflow with very few remote branches. Git does not pigeonhole you into this however unlike SVN and allows a bunch of different workflows that actually work as advertised.

One of the main benefits of using branching is for creating individual features or bug fixes. If everyone uses a branch to develop and test a feature in isolation, this means that you do not see the in-progress work and half-baked commits of unfinished functionality of other developers and vice versa. This makes testing and development easier, because you are not worried if the stupid poo poo you are seeing is because of in-progress unfinished work. It also makes it easier to develop incremental changes because you are not afraid of breaking everyone else when you commit. You're not ridiculously stuck in the office on a Friday evening trying to fix the CI server for your unfinished development. This also makes it so the main integration branch is kept free of half-baked development and that it always contains features (or parts of features) that have been developed and tested.

A discussion of this workflow is here:
https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow

Usually, it is best to keep the scope of the developed feature short and break up developing the feature into a bunch of smaller "complete enough" smaller features leading to completing the overall feature so that integration with the rest of the project happens frequently. This will result in less complicated merging scenarios.

If you try to do this seemingly simple workflow in SVN, you will crash and burn. I have tried this on SVN releases with the mergeinfo stuff, and it is god awful trying to merge your branch back in. The history of the branch also is annoying difficult to get at (and may even be lost) if you want to delete the branch after you're done with it so you don't see 1000s of feature branches. lol

comedyblissoption fucked around with this message at 17:22 on Jun 14, 2015

Linear Zoetrope
Nov 28, 2011

A hero must cook
In addition, I find it's generally best to take a policy of always rebasing before merging, because I find it makes histories much less confusing, but that's contentious and a lot of people disagree.

comedyblissoption
Mar 15, 2006

Rebasing is essentially what SVN does whenever you get latest and have to fix your commit. Git just requires you to be explicit about it.

Rebase will make the history easier to look at and is also my preferred default. You should use a merge commit when there's actually a complicated merge conflict though.

Using rebase with a story workflow will usually require force push permissions on story branches and people understanding what that entails. If you force push, make sure you use the recent --force-with-lease parameter for push. This will deny the force push if the relevant git history looks different on the remote than in your local history at the time of force pushing. This should honestly be the new default setting. Git has had some dumbass defaults.

You should almost never force push the main integration branches and set up the permissions so this is difficult to acquire.

Adbot
ADBOT LOVES YOU

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Jsor posted:

In addition, I find it's generally best to take a policy of always rebasing before merging, because I find it makes histories much less confusing, but that's contentious and a lot of people disagree.

Same, I try to avoid merge commits as much as possible, ideally everything I push would be a fast-forward. Luckily this is simple in a lot of cases by just changing git pull to automatically rebase instead of merge, then for merging feature branches just use rebase before merge.

code:
git config --global branch.autosetuprebase always

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply