Posted Mar 20, 2012 12:56 UTC (Tue) by nevets (subscriber, #11875)
[Link]
> If rebased code is the same as merged code, yes, it was tested.
But that's the big "If". When I first started using git, the upstream maintainer use to rebase my changes into his tree. The problem I had was I never knew what changes he pulled. I would push out a patch series of commits but I never knew what patches actually made it upstream. This changed later when Linus told everyone how to do it, and my push requests were then merged.
The problem is that I can not check what patches I pushed actually made it into upstream. There were some cases that a patch or two was dropped, and I had no clue. It was dropped because of conflicts or someone questioned the patch. But because the other patches were rebased in, I had to go patch by patch to determine what was in and what was not, and this was very time consuming.
I totally understand the usefulness of git pull being a rebase, but it should not be the default. Could you imagine Linux if Linus rebased everyone's pull requests?
pull --rebase
Posted Mar 20, 2012 21:38 UTC (Tue) by mathstuf (subscriber, #69389)
[Link]
Unless I'm sorely mistaken, pull --rebase doesn't rebase pulled branches onto another branch. Instead, it rebases any changes that you have locally that are on a branch onto whatever you pulled down from the remote for that branch. The only problem I've encountered with this when I've made merges into master or next and pulling rebases the merge on top of the tree. A pull --rebase should probably pass -p to rebase so that merges are re-merged instead of streamlined on the branch.
pull --rebase
Posted Mar 20, 2012 22:30 UTC (Tue) by nevets (subscriber, #11875)
[Link]
You may not be mistaken, I may be. I've never used a pull --rebase before, as that's not part of my workflow.
My workflow would be to do a git remote update of the repo that I'm going to base my work on, and then start adding commits to it. Then push those changes upstream.
The repos I take changes from, I do a pull from others, which I do not want to have any rebase (mine or theirs). If you pull from multiple people, how would this work? One pull would rebase against the other.
If I have old commits and want to rebase them on the latest upstream, I simply do a git remote update of the upstream branch and then do a local rebase.
Now I'm confused to the purpose of pull --rebase?
pull --rebase
Posted Mar 20, 2012 23:14 UTC (Tue) by mathstuf (subscriber, #69389)
[Link]
Suppose you have two machines with different commits on some branch. You push from one machine to a common remote repository. On the other machine, you need to pull.
Before:
--B--R (origin/branch)
--B--L (branch)
pull --merge:
--B--R
\
\
--B--L--R'
pull --rebase:
--B--R
| (fast-forward merge on top of B, then rebase L on top of R)
|
--B--R--L'
The problem is that pull --merge creates a merge commit on the branch with "itself". These commits are, IMNSHO, ugly and shouldn't happen. Now what happens if L is some topic branch that got merged into the branch?
With the -p flag, pulling from the remote, keeps the repository looking most similar to what it did before the pull which is one reason why I like it more. The other is that I believe that feature branch merges should *always* use --no-ff so that reverting them is easy (reverting L' is easy; S' and T' less so, especially if topic will land later at some point and it's just broken now).
As for multiple remotes sharing a single branch name, all I can say is that I prefer to not do that. I name remotes in namespaces for non-origin repositories (so foobar's github clone is the gh/foobar remote and I checkout foobar's branches as foobar/branchname). Even my forks get named gh/mathstuf on my machines so that if I keep a personal master branch (mathstuf/master) with my feature branches merged in, it doesn't conflict with the actual master branch. My personal feature branches get named under the dev/ namespace and are not under a username. If they become collaborative, then I'd start namespacing them.
pull --rebase
Posted Mar 21, 2012 15:42 UTC (Wed) by misiu_mp (guest, #41936)
[Link]
Yes, you should test the code after a rebase as well as after a merge, but,
as we all know testing is not always bullet proof.
Part of the testing is code review, including the one you do when you modify the existing code.
Take the following history:
A - B - C - D - H
\ /
F - G
you implement a feature (F, G) starting from version B.
In order to implement the feature, you have to investigate and understand how the existing code works. When you do that you see version B and the history above accurately depicts it.
Now imagine C introduces a change that affects the code you analyzed in a logical, non-trivial way (that does not introduce a merge conflict with your feature). Your feature will now behave incorrectly, but in a very subtle way. If you based your feature off C or D, you would have probably analyzed the code correctly and made a correct implementation. But you didn't. You maybe just quickly review the changes in C and D, run tests and push to H, merging without conflicts. The tests didn't pick up the subtle error and you've got a bastard-of-a-bug, which depends on a simultaneous modification in two branches, but not in each separately.
If you rebase, the other branch disappears and the history looks as if you indeed started your work after C, indicating you should have seen the changed behavior and its code.
A - B - C - D - F - G
After the bug was found it will be much more difficult for anyone, including you to realize what happened.
The lack of rebasing would not prevent the bug, but it would make it easier to track and fix.