Live data from Hacker News

Two Years of Squash Merge (2019)

blog.dnsimple.com

101–110 of 194 posts

Re: Two Years of Squash Merge (2019)

#101
post #2

I will always fight tooth and nail against squash merge. Squash merge has the major disadvantage of getting rid of valuable meaningful git history. Squash merge is not the proper solution for keeping your git history clean, it is a hack using the side effect of squash. Keeping your git history clean is a matter of policy, best-practices and education: Developers should be required to submit _clean_ PRs, that is, PR's…

As long as CI is run on all commits, I’ll agree.

If you don’t run CI on every commit, then you have to balance nicer commits a higher likelihood of bisecting not working as easily.

Re: Two Years of Squash Merge (2019)

#102
post #10
post #2

I will always fight tooth and nail against squash merge. Squash merge has the major disadvantage of getting rid of valuable meaningful git history. Squash merge is not the proper solution for keeping your git history clean, it is a hack using the side effect of squash. Keeping your git history clean is a matter of policy, best-practices and education: Developers should be required to submit _clean_ PRs, that is, PR's…

I do agree that PRs should have a clean history. However: - Services like GitHub allow you to restore the original branch, so you never actually lose history. So I don't see any major drawbacks of squashing on merge. - If your PRs are several thousand lines long, they probably should've been broken up into multiple PRs (your reviewer will appreciate it)

So, if your PR has a clean history in the first place (clean as in multiple small digestible, atomic commits, that are easy to review in isolation), why get rid of it with a squash?

Is there a fundamental drawback to keeping that clean history? _It's already here_

Re: Two Years of Squash Merge (2019)

#103

Earlier quoted context omitted.

I think I'm missing something here. How valuable is to have 20 commits of "fix this error" , "fix the fix of the error", "revert all fixes", "real fix".... etc? I'd argue a PR with many commits such as these, conveys little no no useful information, when the actual change is 1-3 LOC. what about cleaning and filtering out useless commits, by soft reseting the branch and commiting just the actual changes to merge. Sure…

> what about cleaning and filtering out useless commits, by soft reseting the branch and commiting just the actual changes to merge. So... squashing?

Yes, but the author of the code, who would presumably know their intent, gets to choose how many commits to squash to instead of just one. This means that they can preserve the development process in a logical way.

Re: Two Years of Squash Merge (2019)

#104
post #30
post #10

Earlier quoted context omitted.

I do agree that PRs should have a clean history. However: - Services like GitHub allow you to restore the original branch, so you never actually lose history. So I don't see any major drawbacks of squashing on merge. - If your PRs are several thousand lines long, they probably should've been broken up into multiple PRs (your reviewer will appreciate it)

Spot-on for both counts. Preserving a PR's individual commits in the master branch is insane - many of those commits won't represent a fully working system anyway, so why keep them in master?

It's entirely not insane _on the premise that the history is clean_. That's the whole argument that is being made here.

If you think that "Preserving a PR's individual commits in the master branch is insane - many of those commits won't represent a fully working system anyway", your issue _is_ "that your commits don't represent a fully working system anyway", _that_ is what you need to fix.

You need to make sure your history _does_ represent multiple small digestible atomic chunk of codes, that are understandable individually.

By squashing, you're not fixing the root cause, you're treating the symptoms.

Re: Two Years of Squash Merge (2019)

#105
post #58

Earlier quoted context omitted.

What's an example of a bug you've had to bisect for recently? Forgive me, it just seems like such a last resort thing.

I can give you an example though I have to be sort of vague for obvious reasons too. In fact, I have been bisecting to find the cause of a bug 3 times in the past 3 to 4 weeks. Customer Service reported a problem with something that my team is responsible for. I knew almost for certain that we didn't break it. I had a vague idea that another team might have broken it by a recent-ish change to a different service that…

But that just sounds like an _incredible_ amount of effort and even at the end you still don't actually know the cause of the bug. Surely you just raise it to someone who owns the code in question? It sounds like you know who they are already?

Re: Two Years of Squash Merge (2019)

#106
post #92

Earlier quoted context omitted.

In my experience squash messages combine the messages of the commits they consolidate. And the actual branch merged still exists, I don't buy hardlined stances against squashed merges.

> In my experience squash messages combine the messages of the commits they consolidate. I believe they do, by default, but the developer gets to modify. In other words, if I squash 3 commits, the git cli will set the resulting message to be a combination of all 3, but opens an editor to let me change it. I'm not for or against any git merge/squash/rebase flow on technical grounds, but I do want every message in the…

I guess I haven't worked on a project important enough where the history is more important than the current state. Usually it's more like it might be useful to gain perspective by looking at the history, only to find it was a conflicted merge or the comment contained no useful info anyway ("Clean up", or "Fix this feature").

Even if it tried really hard to document the purpose of the change, I've rarely gotten more from a commit message than the content of the code changes in the commit.

Re: Two Years of Squash Merge (2019)

#107
post #92

It seems DNSimple has determined that the git commit messages are the System of Record not only for what changed, but why . But there are other ways. You could name the branch (or put in the comment a number) for a ticket in the bug tracker/kanban/whatever you use to track work. You could add a link in the commit to internal discussion or documentation about the work. While a bit unorthodox, I'm not sure I can be aga…

In my experience squash messages combine the messages of the commits they consolidate. And the actual branch merged still exists, I don't buy hardlined stances against squashed merges.

That would be fine if the only important information in a commit was the message. But that's not the case.

A commit gives you a message, but also a specific line of code and its surrounding context. The message is just one more bit of information (an important one!).

By squashing, maybe you keep the messages, but without their associated changeset (which you lost when you squashed), these messages are of poor to null value.

Re: Two Years of Squash Merge (2019)

#108
post #105

Earlier quoted context omitted.

I can give you an example though I have to be sort of vague for obvious reasons too. In fact, I have been bisecting to find the cause of a bug 3 times in the past 3 to 4 weeks. Customer Service reported a problem with something that my team is responsible for. I knew almost for certain that we didn't break it. I had a vague idea that another team might have broken it by a recent-ish change to a different service that…

But that just sounds like an _incredible_ amount of effort and even at the end you still don't actually know the cause of the bug. Surely you just raise it to someone who owns the code in question? It sounds like you know who they are already?

Until you have done it it may sound like an incredible amount of effort but in fact it isn't at all. Your reality might be different, but we also deal with different time zones. In this particular example the other team was in a different time zone and already gone for the day. The easiest and most efficient way was a 'dumb' bisect.

If you _only_ raise it to the team in question, you have nothing in hand but suspicions. Their natural reaction is most probably going to be "No can't be us, must be something/someone else" and you've wasted an entire day waiting for their response that was predictable anyway and you've also just increased both their and your own irritation level. Their's because they probably feel like you're trying to blame them for something they feel is not their fault. Your own because you've just wasted a day trying to solve this and meanwhile customer service thinks you caused a regression.

A bisect that literally took zero brain cycles and told me which commit caused it before I was even halfway done with my meetings allowed me to let them know exactly which commit caused it without a doubt (unless your company is so broken that they wouldn't even believe the bisect output :)). This also gives them very valuable information because instead of them now trying to have to figure out which of their changes maybe caused this thing I'm 'accusing' them of, they have a single commit, which is directly tied to a single ticket. In this particular case, the developer in question actually knew right away from seeing the commit message/ticket number what particular part of their change was the cause of the issue, without even having to dig through the code.

Re: Two Years of Squash Merge (2019)

#109
post #58

Earlier quoted context omitted.

What's an example of a bug you've had to bisect for recently? Forgive me, it just seems like such a last resort thing.

I don't bisect regularly, but when I do, it's usually trying to figure out what the original reason for introducing the code that is problematic is. The entire point is on projects big enough, you may not be able to just "follow the logic" enough to know that your fix the to apparent bug isn't re-introducing some regression that was fixed previously. So bisect to me, is a way to figure out where and why the code was…

If you've got a codebase where the intent of the code isn't clear, where you can't track bugs, and where you can't fix them without being confident you're not breaking other stuff, surely those are all fundamental problems worth addressing?

Re: Two Years of Squash Merge (2019)

#110
> You can use short-living branches to avoid repetitive merge of master

> No, this doesn't work. It does if you have very few developers, each working on individual branches. But when multiple developers are working on multiple-feature branches together, that doesn't scale. We encourage backporting master often into your branch to limit the risk of conflicts, and stay on top of the latest changes. For example, we continuously update dependencies. We also merge and ship on average 10 times a day.

Those are development branches that should be treated like master/main and developers should be writing short feature branches which are merged into those branches.

And in the simplest case when you start work on N+1 then that becomes your main branch, and you fork off the stable N branch. Both of those are treated the same and devs should do PRs into them. Those PRs should ideally be simple things that are easy to review which should be single commits. This enables squash+rebase on those daily private branches.

You can also fork off a nuclear reactor branch which is long-lived, occasionally merge back from the main branch and then merge into main later. I'd discourage that since you have the issues of merging and porting, potentially both ways. But again you shouldn't have devs directly committing to that branch and then pushing, they should be opening PRs of their work into it, when its merged, then other devs can pull that branch and rebase their local work on top of it.

I've helped out individual devs with commits on top of their feature branches from time-to-time, but I consider that they've got the ultimate "write lock" on those branches. Typically as a result of actually chatting with them in zoom sometimes it might be faster to just push a commit with the work. But once that is done, its their private branch again, and I expect them to rebase and for me to have to deal with that if I look at it again.

EDIT: Also the long-lived feature branches are going to be impossible to adequately review when it is time to merge them back into main. That code review needs to be happening all along the way if that is your process. You can't adequately review 4 months of work by several devs once at the end of it all. They need to be doing that the whole time. That calls for a branch they're doing their own PRs and code review into.

Post reply on HN