Skip to contentSkip to conversation

user-manual: add advanced topic "bisecting merges"

PATCH Superseded Steffen Prohaska 10 participants 30 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 user-manual: add advanced topic "bisecting merges"

This commits adds a discussion of the challenge of bisecting merge commits to the user manual. The text is slightly adapted from a mail by Junio C Hamano <[email protected]> to the mailing list
<http://marc.info/?l=git&m=119403257315527&w=2>.

The discussion is added to "Exploring git history" in a sub-section titled "Advanced topics". The discussion requires detailed knowledge about git. It is assumed that the reader will skip advanced topics on first reading. At least the text suggest to do so.

---
 Documentation/user-manual.txt |   89 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)

Junio's discussion was enlightening for me. I think it's a good idea to add such discussions to the user manual. It was not obvious to me where to place the discussion in the current structure of the manual. So I added "Advanced topics".

Is a sub-section "Advanced topics" a good idea? Any better suggestions?

Steffen

Documentation/user-manual.txt +89 -0
index d99adc6..480e7c1 100644
@@ -934,6 +934,95 @@ Figuring out why this works is left as an exercise to the (advanced)
 student.  The gitlink:git-log[1], gitlink:git-diff-tree[1], and
 gitlink:git-hash-object[1] man pages may prove helpful.
 
+[[history-advanced-topics]]
+Advanced topics
+---------------
+This section covers advanced topics that typically require more
+knowledge about git than the manual presented to this point.
+
+You may want to skip the section at first reading, and come back
+later when you have a better understanding of git.
+
+[[bisect-merges]]
+Why bisecting merge commits can be harder than bisecting linear history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The following text is based upon an email by Junio C. Hamano to
+the git mailing list
+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http://marc.info/?l=git&m=119403257315527&w=2]).
+It was slightly adapted for this manual.
+
+Bisecting merges can be challenging due to the complexity of
+changes introduced at a merge.  Bisecting through merges is not a
+technical problem. The real problem is what to do when the
+culprit turns out to be a merge commit.  How to spot what really
+is wrong, and figure out how to fix.  The problem is not for the
+tool but for the human, and it is real.
+
+Imagine this history.
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B
+................................................
+
+Suppose that on the upper development line, the meaning of one
+of the functions existed at Z was changed at commit X.  The
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.
+
+Suppose in the meantime the lower development line somebody
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.
+
+You merge to create C.  There is no textual conflict with this
+three way merge, and the result merges cleanly.  You bisect
+this, because you found D is bad and you know Z was good.  Your
+bisect will find that C (merge) is broken.  Understandably so,
+as at C, the new calling site of the function added by the lower
+branch is not converted to the new semantics, while all the
+other calling sites that already existed at Z would have been
+converted by the merge.  The new calling site has semantic
+adjustment needed, but you do not know that yet.  You need to
+find out that is the cause of the breakage by looking at the
+merge commit C and the history leading to it.
+
+How would you do that?
+
+Both "git diff A C" and "git diff B C" would be an enormous patch.
+Each of them essentially shows the whole change on each branch
+since they diverged.  The developers may have well behaved to
+create good commits that follow the "commit small, commit often,
+commit well contained units" mantra, and each individual commit
+leading from Z to A and from Z to B may be easy to review and
+understand, but looking at these small and easily reviewable
+steps alone would not let you spot the breakage.  You need to
+have a global picture of what the upper branch did (and
+among many, one of them is to change the semantics of that
+particular function) and look first at the huge "diff A C"
+(which shows the change the lower branch introduces), and see if
+that huge change is consistent with what have been done between
+Z and A.
+
+If you linearlize the history by rebasing the lower branch on
+top of upper, instead of merging, the bug becomes much easier to
+find and understand.  Your history would instead be:
+
+................................................................
+    ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*
+................................................................
+
+and there is a single commit Y* between A and B* that introduced
+the new calling site that still uses the old semantics of the
+function, even though that was already modified at X. "git show
+Y*" will be a much smaller patch than "git diff A C" and it is
+much easier to deal with.
+
+
 [[Developing-with-git]]
 Developing with git
 ===================
Signature · 1 line
1.5.3.4.464.ge1bc2
#1 lore raw

Hello Steffen,

A couple of language nits:

* Steffen Prohaska wrote on Sun, Nov 04, 2007 at 10:16:13AM CET:

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 970

Quoted 2 lines
Documentation/user-manual.txt +2 -0
+Suppose that on the upper development line, the meaning of one
+of the functions existed at Z was changed at commit X.  The

s/functions/& that/

Quoted 4 lines
Documentation/user-manual.txt +4 -0
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.

[...]

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 991

Quoted 10 lines
Documentation/user-manual.txt +10 -0
+You merge to create C.  There is no textual conflict with this
+three way merge, and the result merges cleanly.  You bisect
+this, because you found D is bad and you know Z was good.  Your
+bisect will find that C (merge) is broken.  Understandably so,
+as at C, the new calling site of the function added by the lower
+branch is not converted to the new semantics, while all the
+other calling sites that already existed at Z would have been
+converted by the merge.  The new calling site has semantic
+adjustment needed, but you do not know that yet.  You need to
+find out that is the cause of the breakage by looking at the

s/that/that that/

Quoted 1 line

+merge commit C and the history leading to it.

[...]

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1012

Quoted 2 lines
Documentation/user-manual.txt +2 -0
+If you linearlize the history by rebasing the lower branch on
+top of upper, instead of merging, the bug becomes much easier to

s/upper/the &/

Quoted 1 line

+find and understand. Your history would instead be:

[...]

Cheers,
Ralf

#29 lore raw
In reply to Steffen Prohaska
Quoted 6 lines · Steffen Prohaska
Documentation/user-manual.txt +0 -0
index d99adc6..480e7c1 100644
@@ -934,6 +934,95 @@ Figuring out why this works is left as an  
 exercise to the (advanced)

[...]

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 968

Quoted 9 lines
Documentation/user-manual.txt +9 -0
+
+Imagine this history.
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B
+................................................
+

I don't know how you chose these letters, but I don't find them particularly intuitive to remember.

................................................

      ---B---o---X---...---o---Y---M---H
          \                       /
           o---o---T---...---o---Z

................................................

would be better (IMO): B stands for "Branch point"
M stands for "Merge" H stands for "HEAD" T stands for "Topic"

Otherwise thanks for documenting this, the patch looks fine to me.

Signature · 2 lines
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory
#2 lore raw

PATCH v2 1/1 user-manual: add advanced topic "bisecting merges"

In reply to Ralf Wildenhues

This commits adds a discussion of the challenge of bisecting merge commits to the user manual. The text is slightly adapted from a mail by Junio C Hamano <[email protected]> to the mailing list
<http://marc.info/?l=git&m=119403257315527&w=2>.

The discussion is added to "Exploring git history" in a sub-section titled "Advanced topics". The discussion requires detailed knowledge about git. It is assumed that the reader will skip advanced topics on first reading. At least the text suggest to do so.

---
 Documentation/user-manual.txt |   89 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)

Some minor errors were fixed. Thanks to <[email protected]>.

I kept the naming of the commits. Benoit Sigoure suggested to choose a different naming which he claims would be easier to remember. I'm not convinced. The current naming starts with X, Y, Z on the left and names the remaining commits on the right with A, B, C, D. This is simple and give sufficient orientation.

Steffen

Documentation/user-manual.txt +89 -0
index d99adc6..d0e738e 100644
@@ -934,6 +934,95 @@ Figuring out why this works is left as an exercise to the (advanced)
 student.  The gitlink:git-log[1], gitlink:git-diff-tree[1], and
 gitlink:git-hash-object[1] man pages may prove helpful.
 
+[[history-advanced-topics]]
+Advanced topics
+---------------
+This section covers advanced topics that typically require more
+knowledge about git than the manual presented to this point.
+
+You may want to skip the section at first reading, and come back
+later when you have a better understanding of git.
+
+[[bisect-merges]]
+Why bisecting merge commits can be harder than bisecting linear history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The following text is based upon an email by Junio C. Hamano to
+the git mailing list
+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http://marc.info/?l=git&m=119403257315527&w=2]).
+It was slightly adapted for this manual.
+
+Bisecting merges can be challenging due to the complexity of
+changes introduced at a merge.  Bisecting through merges is not a
+technical problem. The real problem is what to do when the
+culprit turns out to be a merge commit.  How to spot what really
+is wrong, and figure out how to fix.  The problem is not for the
+tool but for the human, and it is real.
+
+Imagine this history.
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B
+................................................
+
+Suppose that on the upper development line, the meaning of one
+of the functions that existed at Z was changed at commit X.  The
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.
+
+Suppose in the meantime the lower development line somebody
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.
+
+You merge to create C.  There is no textual conflict with this
+three way merge, and the result merges cleanly.  You bisect
+this, because you found D is bad and you know Z was good.  Your
+bisect will find that C (merge) is broken.  Understandably so,
+as at C, the new calling site of the function added by the lower
+branch is not converted to the new semantics, while all the
+other calling sites that already existed at Z would have been
+converted by the merge.  The new calling site has semantic
+adjustment needed, but you do not know that yet.  You need to
+find out that that is the cause of the breakage by looking at the
+merge commit C and the history leading to it.
+
+How would you do that?
+
+Both "git diff A C" and "git diff B C" would be an enormous patch.
+Each of them essentially shows the whole change on each branch
+since they diverged.  The developers may have well behaved to
+create good commits that follow the "commit small, commit often,
+commit well contained units" mantra, and each individual commit
+leading from Z to A and from Z to B may be easy to review and
+understand, but looking at these small and easily reviewable
+steps alone would not let you spot the breakage.  You need to
+have a global picture of what the upper branch did (and
+among many, one of them is to change the semantics of that
+particular function) and look first at the huge "diff A C"
+(which shows the change the lower branch introduces), and see if
+that huge change is consistent with what have been done between
+Z and A.
+
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much easier to
+find and understand.  Your history would instead be:
+
+................................................................
+    ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*
+................................................................
+
+and there is a single commit Y* between A and B* that introduced
+the new calling site that still uses the old semantics of the
+function, even though that was already modified at X. "git show
+Y*" will be a much smaller patch than "git diff A C" and it is
+much easier to deal with.
+
+
 [[Developing-with-git]]
 Developing with git
 ===================
Signature · 1 line
1.5.3.5.578.g886d
#3 lore raw

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1013

Quoted 3 lines · Steffen Prohaska
Documentation/user-manual.txt +3 -0
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much easier to
+find and understand.  Your history would instead be:

At this point I'm missing the words

The solution is ...

I.e.:

The solution is to linearize the history by rebasing the lower branch on top of the upper, instead of merging. Now the bug becomes much easier to find and understand. Your history would instead be:

-- Hannes

#4 lore raw
Quoted 7 lines · Johannes Sixt

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1013

Quoted 3 lines · Steffen Prohaska
Documentation/user-manual.txt +3 -0
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much easier to
+find and understand.  Your history would instead be:

At this point I'm missing the words

Quoted 7 lines

The solution is ...

I.e.:

The solution is to linearize the history by rebasing the lower branch on top of the upper, instead of merging. Now the bug becomes much easier to find and understand. Your history would instead be:

Hmm. It might be a solution if you did not publish history.

How about leaving the text as is and adding an introductory paragraph at the beginning of the section?

I.e:

This section discusses how gitlink:git-bisect[1] plays with differently shaped histories. If you did not yet publish a branch you can use either gitlink:git-merge[1] or gitlink:git-rebase[1] to integrate changes from a second branch. The two approaches create differently shaped histories. So it might be interesting to know about the implications on gitlink:git-bisect[1].

Steffen

#5 lore raw
Quoted 12 lines · Steffen Prohaska
Quoted 9 lines · Johannes Sixt

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1013

Quoted 3 lines · Steffen Prohaska
Documentation/user-manual.txt +3 -0
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much easier to
+find and understand.  Your history would instead be:

At this point I'm missing the words

The solution is ...

Quoted 7 lines
Quoted 5 lines

I.e.:

The solution is to linearize the history by rebasing the lower branch on top of the upper, instead of merging. Now the bug becomes much easier to find and understand. Your history would instead be:

Hmm. It might be a solution if you did not publish history.

This is about finding the commit that introduced a bug. Once you found it, better: you know how to fix the bug, you are expected to throw away the rebased branch, not to publish it! Maybe a note along these lines could be appended:

Now that you know what caused the error (and how to fix it), throw away the rebased branch, and commit a fix on top of D.

-- Hannes

#6 lore raw
Quoted 19 lines · Johannes Sixt
Quoted 18 lines · Steffen Prohaska
Quoted 14 lines · Johannes Sixt

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1013

Quoted 3 lines · Steffen Prohaska
Documentation/user-manual.txt +3 -0
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much easier to
+find and understand.  Your history would instead be:

At this point I'm missing the words

The solution is ...

I.e.:

The solution is to linearize the history by rebasing the lower branch on top of the upper, instead of merging. Now the bug becomes much easier to find and understand. Your history would instead be:

Quoted 6 lines
Quoted 1 line

Hmm. It might be a solution if you did not publish history.

This is about finding the commit that introduced a bug. Once you found it, better: you know how to fix the bug, you are expected to throw away the rebased branch, not to publish it! Maybe a note along these lines could be appended:

Now that you know what caused the error (and how to fix it), throw away the rebased branch, and commit a fix on top of D.

Well, if rebasing becomes the standard for normal development, it's hardly right to throw it away, is it? I like Steffen's suggestion better.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#7 lore raw
Quoted 22 lines · Andreas Ericsson
Quoted 21 lines · Johannes Sixt
Quoted 19 lines · Steffen Prohaska
Quoted 7 lines · Johannes Sixt

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1013

Quoted 3 lines · Steffen Prohaska
Documentation/user-manual.txt +3 -0
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much easier to
+find and understand.  Your history would instead be:

At this point I'm missing the words

Quoted 7 lines

The solution is ...

I.e.:

The solution is to linearize the history by rebasing the lower branch on top of the upper, instead of merging. Now the bug becomes much easier to find and understand. Your history would instead be:

Hmm. It might be a solution if you did not publish history.

Quoted 7 lines
Quoted 4 lines

This is about finding the commit that introduced a bug. Once you found it, better: you know how to fix the bug, you are expected to throw away the rebased branch, not to publish it! Maybe a note along these lines could be appended:

Now that you know what caused the error (and how to fix it), throw away the rebased branch, and commit a fix on top of D.

Well, if rebasing becomes the standard for normal development, it's hardly right to throw it away, is it? I like Steffen's suggestion better.

There is a big misunderstanding. The text that the patch amends is about bisecting history that reveals that a merge commit breaks, which is not helpful, and then how to find where and what and why the breakage really was introduce.

And the answer to "how to find" is to rebase and bisect in the rebased history.

My initial complaint was that in the flow of reading the instructions the pointer to "the solution" was missing. Rather, at the point where the reader is supposed to think "ah, yes, that's how to do it", there is the conditional statement "If you linearize history". My suggestion is to put a big emphasis on the solution by using the words "The solution is".

Now, the user can *always* rebase one of the branches on top of the other, even if both histories are already published. *But* if both were indeed published, then the rebased history must be thrown away, and the only thing you learnt from it was where and what and why the breakage really was introduced.

Of course we could include a few "ifs" and "unlesses" (about published histories), before suggesting to throw away rebased history. But once the task is accomplished (find the bogus commit), throwing away the rebased history (and continuing at commit D) is always correct, but keeping it (and continuing at D*) is not.

-- Hannes

#8 lore raw
Quoted 26 lines · Johannes Sixt
Quoted 25 lines · Andreas Ericsson
Quoted 24 lines · Johannes Sixt
Quoted 13 lines · Steffen Prohaska
Quoted 10 lines · Johannes Sixt
Quoted 4 lines · Steffen Prohaska
(quoted diff) +2 -0
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much  

easier to
+find and understand. Your history would instead be:

At this point I'm missing the words

The solution is ...

Quoted 7 lines
Quoted 5 lines

I.e.:

The solution is to linearize the history by rebasing the lower branch on top of the upper, instead of merging. Now the bug becomes much easier to find and understand. Your history would instead be:

Hmm. It might be a solution if you did not publish history.

This is about finding the commit that introduced a bug. Once you found it, better: you know how to fix the bug, you are expected to throw away the rebased branch, not to publish it! Maybe a note along these lines could be appended:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Now that you know what caused the error (and how to fix it), throw away the rebased branch, and commit a fix on top of D.

Well, if rebasing becomes the standard for normal development, it's hardly right to throw it away, is it? I like Steffen's suggestion better.

There is a big misunderstanding. The text that the patch amends is about bisecting history that reveals that a merge commit breaks, which is not helpful, and then how to find where and what and why the breakage really was introduce.

And the answer to "how to find" is to rebase and bisect in the rebased history.

Do you use rebase like this in real life?

I thought of the text as background information that might be helpful for users who want do decide wether to merge or to rebase. The problem described may be valuable information supporting a decision about a recommended workflow for a group of users.

My personal conclusion was: I'll accept the danger of complex merges that might be hard to bisect. I now understand this risk, but I nonetheless prefer the simplicity of a merge based workflow. This avoids the danger that published history gets rewritten.

But now I'm wondering if your suggestions of rebasing only for locating the evil commit is feasible in reality. You may need to solve a lot of merge conflicts if you rebase a larger part of the history. If you do not have them in your rerere cache this might be time consuming. ...

Quoted 5 lines

My initial complaint was that in the flow of reading the instructions the pointer to "the solution" was missing. Rather, at the point where the reader is supposed to think "ah, yes, that's how to do it", there is the conditional statement "If you linearize history". My suggestion is to put a big emphasis on the solution by using the words "The solution is".

Now, the user can *always* rebase one of the branches on top of the other, even if both histories are already published. *But* if both were indeed published, then the rebased history must be thrown away, and the only thing you learnt from it was where and what and why the breakage really was introduced.

Of course we could include a few "ifs" and "unlesses" (about published histories), before suggesting to throw away rebased history. But once the task is accomplished (find the bogus commit), throwing away the rebased history (and continuing at commit D) is always correct, but keeping it (and continuing at D*) is not.

... So, again, the question for me is if someone does use rebase in reality in the way that you suggests. Do you? Does someone else?

Steffen

#9 lore raw
Quoted 7 lines · Steffen Prohaska
Quoted 3 lines · Johannes Sixt

The text that the patch amends is about bisecting history that reveals that a merge commit breaks, which is not helpful, and then how to find where and what and why the breakage really was introduce.

And the answer to "how to find" is to rebase and bisect in the rebased history.

Do you use rebase like this in real life?

Why is this relevant?

You've written a superb addendum to the user manual, but IT TALKS ABOUT BISECTION, and is not a guideline when to use merges and when to rebase.

It better not be meant as such. Consider an integrator who has just merged two histories, both of which are available publically. Pushing out a rebased history IS NOT AN OPTION. If the poor fellow for the heck of it has no choice but to find the bogus commit, then your instructions are worth a thousand bucks - even if the rebased history is otherwise useless -, but any guidelines how to construct histories are IRRELEVANT for his case.

Quoted 5 lines

But now I'm wondering if your suggestions of rebasing only for locating the evil commit is feasible in reality. You may need to solve a lot of merge conflicts if you rebase a larger part of the history. If you do not have them in your rerere cache this might be time consuming. ...

During the rebase you will see the same conflicts that you also had during the merge, even simpler ones (because they are - hopefully - broken down into smaller pieces). If your merge was clean (as was suggested in the patch), then you won't see a lot of conflicts during the rebase, either.

-- Hannes

#10 lore raw
Quoted 8 lines · Johannes Sixt
Quoted 5 lines · Steffen Prohaska
Quoted 3 lines · Johannes Sixt

The text that the patch amends is about bisecting history that reveals that a merge commit breaks, which is not helpful, and then how to find where and what and why the breakage really was introduce.

And the answer to "how to find" is to rebase and bisect in the rebased history.

Do you use rebase like this in real life?

Why is this relevant?

Well, I don't want to give recommendations that are not tested in real life. Maybe the solution turns out to be less practical than it should be theoretically.

Quoted 1 line

You've written a superb addendum to the user manual, but IT TALKS ABOUT BISECTION, and is not a guideline when to use merges and when to rebase.

BTW, I only took what Junio wrote during a recent discussion on the list, polished it a bit and sent it as a patch. I'm only the editor, not the original author. That doesn't mean I wouldn't care about the text. I'm willing to improve the text. But all the cheers really should go to Junio.

Quoted 1 line

It better not be meant as such. Consider an integrator who has just merged two histories, both of which are available publically. Pushing out a rebased history IS NOT AN OPTION. If the poor fellow for the heck of it has no choice but to find the bogus commit, then your instructions are worth a thousand bucks - even if the rebased history is otherwise useless -, but any guidelines how to construct histories are IRRELEVANT for his case.

Ok, I see your point. I'll mention these points.

Quoted 7 lines
Quoted 5 lines

But now I'm wondering if your suggestions of rebasing only for locating the evil commit is feasible in reality. You may need to solve a lot of merge conflicts if you rebase a larger part of the history. If you do not have them in your rerere cache this might be time consuming. ...

During the rebase you will see the same conflicts that you also had during the merge, even simpler ones (because they are - hopefully - broken down into smaller pieces). If your merge was clean (as was suggested in the patch), then you won't see a lot of conflicts during the rebase, either.

Yeah. I'll try to mention this at an appropriate place.

Steffen

#21 lore raw
In reply to Steffen Prohaska
Quoted 52 lines · Steffen Prohaska
Quoted 26 lines · Johannes Sixt
Quoted 25 lines · Andreas Ericsson
Quoted 24 lines · Johannes Sixt
Quoted 13 lines · Steffen Prohaska
Quoted 10 lines · Johannes Sixt
Quoted 4 lines · Steffen Prohaska
(quoted diff) +2 -0
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much 

easier to
+find and understand. Your history would instead be:

At this point I'm missing the words

The solution is ...

Quoted 7 lines
Quoted 5 lines

I.e.:

The solution is to linearize the history by rebasing the lower branch on top of the upper, instead of merging. Now the bug becomes much easier to find and understand. Your history would instead be:

Hmm. It might be a solution if you did not publish history.

This is about finding the commit that introduced a bug. Once you found it, better: you know how to fix the bug, you are expected to throw away the rebased branch, not to publish it! Maybe a note along these lines could be appended:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Now that you know what caused the error (and how to fix it), throw away the rebased branch, and commit a fix on top of D.

Well, if rebasing becomes the standard for normal development, it's hardly right to throw it away, is it? I like Steffen's suggestion better.

There is a big misunderstanding. The text that the patch amends is about bisecting history that reveals that a merge commit breaks, which is not helpful, and then how to find where and what and why the breakage really was introduce.

And the answer to "how to find" is to rebase and bisect in the rebased history.

Do you use rebase like this in real life?

I thought of the text as background information that might be helpful for users who want do decide wether to merge or to rebase. The problem described may be valuable information supporting a decision about a recommended workflow for a group of users.

My personal conclusion was: I'll accept the danger of complex merges that might be hard to bisect. I now understand this risk, but I nonetheless prefer the simplicity of a merge based workflow. This avoids the danger that published history gets rewritten.

Quoted 6 lines

But now I'm wondering if your suggestions of rebasing only for locating the evil commit is feasible in reality. You may need to solve a lot of merge conflicts if you rebase a larger part of the history. If you do not have them in your rerere cache this might be time consuming. ...

It is no great chore to put one merge-parent on top of another and then re-run bisect on the result. git-bisect could even be taught to do that by itself.

Quoted 9 lines
Quoted 6 lines

My initial complaint was that in the flow of reading the instructions the pointer to "the solution" was missing. Rather, at the point where the reader is supposed to think "ah, yes, that's how to do it", there is the conditional statement "If you linearize history". My suggestion is to put a big emphasis on the solution by using the words "The solution is".

Now, the user can *always* rebase one of the branches on top of the other, even if both histories are already published. *But* if both were indeed published, then the rebased history must be thrown away, and the only thing you learnt from it was where and what and why the breakage really was introduced.

Of course we could include a few "ifs" and "unlesses" (about published histories), before suggesting to throw away rebased history. But once the task is accomplished (find the bogus commit), throwing away the rebased history (and continuing at commit D) is always correct, but keeping it (and continuing at D*) is not.

... So, again, the question for me is if someone does use rebase in reality in the way that you suggests. Do you?

I don't, but if I'd thought a bit further I would have on at least one occasion in the past. Instead I spent two days manually auditing every commit of several branches.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#22 lore raw
In reply to Steffen Prohaska
Quoted 7 lines · Steffen Prohaska

Do you use rebase like this in real life?

I thought of the text as background information that might be helpful for users who want do decide wether to merge or to rebase. The problem described may be valuable information supporting a decision about a recommended workflow for a group of users.

You're missing the point. Johannes suggested that you rebase *only* for bisecting purpose. Once you find the culprit commit, throw away your rebased stuff. I've never thought about doing this myself, but it's a very clever way of tackling this problem. It's slightly less convenient if you need to bisect a large portion of the history (that involves many branches and merges) because in this case we'd like to have a magic git-linearize-history <start-treeish> <end-treeish>. Unless this is already easily doable with git-rebase?

So to summarize (untested):
git merge topic
make check
<omg something's broken>
git reset --hard HEAD~1 # undo the merge
git checkout -b wtf
git rebase topic master
git bisect ...
<OK I found the culprit>
git checkout master
git branch -D wtf
git merge --no-commit topic
<fix the problem>
git commit # merge done, semantic glitch fixed

Correct me if I'm wrong.

This has *nothing* to do with the fact that you use merge or rebase to do whatever you were doing.

Signature · 2 lines
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory
#23 lore raw
Quoted 11 lines · Benoit Sigoure
Quoted 7 lines · Steffen Prohaska

Do you use rebase like this in real life?

I thought of the text as background information that might be helpful for users who want do decide wether to merge or to rebase. The problem described may be valuable information supporting a decision about a recommended workflow for a group of users.

You're missing the point. Johannes suggested that you rebase *only* for bisecting purpose. Once you find the culprit commit, throw away your rebased stuff.

I got this point. I also noted that it might be time consuming if you need to resolve conflicts.

The original discussion in which Junio explained the problem with bisecting merges was about workflows. The question then was if users should _always_ rebase if possible to make bisecting easier. It was really a workflow question.

Well, the context of the original discussion is no longer present in the patch I sent. Therefore, Johannes' comments absolutely make sense. Actually I find them really inspiring as I have not thought before about rebasing temporarily, just for finding a commit. Now I learnt that this could be a useful tool.

Quoted 1 line

I've never thought about doing this myself, but it's a very clever way of tackling this problem.

Apparently, you haven't thought about this solution either ;)

Steffen

#24 lore raw
In reply to Benoit Sigoure
Quoted 1 line · Benoit Sigoure

You're missing the point. Johannes suggested that you rebase *only* for bisecting purpose. Once you find the culprit commit, throw away your rebased stuff. I've never thought about doing this myself, but it's a very clever way of tackling this problem. It's slightly less convenient if you need to bisect a large portion of the history (that involves many branches and merges) because in this case we'd like to have a magic git-linearize-history <start-treeish> <end-treeish>. Unless this is already easily doable with git-rebase?

I don't think you have to linearize it before bisecting. If you bisect and discover that it was due to a merge, then you can rebase *that merge* to discover what part of the merge caused the issue.

~~ Brian

#25 lore raw
In reply to Benoit Sigoure

Hi,

Quoted 4 lines · Benoit Sigoure
Quoted 2 lines · Steffen Prohaska

Do you use rebase like this in real life?

Quoted 8 lines
Quoted 4 lines

I thought of the text as background information that might be helpful for users who want do decide wether to merge or to rebase. The problem described may be valuable information supporting a decision about a recommended workflow for a group of users.

You're missing the point. Johannes suggested that you rebase *only* for bisecting purpose. Once you find the culprit commit, throw away your rebased stuff.

Just to clear things up: it was the other Johannes who suggested it.

But I strongly advise not to rebase before bisecting, since you could very well end up changing the behaviour of the program by rebasing it. Even to a point where you cannot bisect it any longer, for example when the merge of two branches contains an important fix without which the combined branches (or even parts of them) will not even compile.

Last time I checked, however, bisect worked like a charm even on a history with complicated ancestry.

Ciao,
Dscho

#26 lore raw
In reply to Steffen Prohaska

Hi Steffen,

Quoted 18 lines · Steffen Prohaska

This commits adds a discussion of the challenge of bisecting merge commits to the user manual. The text is slightly adapted from a mail by Junio C Hamano <[email protected]> to the mailing list
<http://marc.info/?l=git&m=119403257315527&w=2>.

The discussion is added to "Exploring git history" in a sub-section titled "Advanced topics". The discussion requires detailed knowledge about git. It is assumed that the reader will skip advanced topics on first reading. At least the text suggest to do so.

---
 Documentation/user-manual.txt |   89 ++++++++++++++++++++++++++++++ 
+++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)
Quoted 7 lines

Some minor errors were fixed. Thanks to <[email protected]>.

I kept the naming of the commits. Benoit Sigoure suggested to choose a different naming which he claims would be easier to remember. I'm not convinced. The current naming starts with X, Y, Z on the left and names the remaining commits on the right with A, B, C, D. This is simple and give sufficient orientation.

I still disagree but... fair enough ;)
You end up comparing [ABCD] with [XYZ] which (to me) is hard to follow because it's like you were comparing two different kind of entities. I tend to think more in term of branch (e.g. what's happened to the upper branch and what's happened to the lower branch, rather than think in terms of "before a point in time" and "after that point in time"). Because of that, I constantly need to look back at the scheme to find out what is A', what is Z' etc.

Some more comments below. Sorry for not spotting these earlier.

Quoted 7 lines
Documentation/user-manual.txt +0 -0
index d99adc6..d0e738e 100644
@@ -934,6 +934,95 @@ Figuring out why this works is left as an  
 exercise to the (advanced)

Documentation/user-manual.txt Figuring out why this works is left as an · line 944

Quoted 10 lines
Documentation/user-manual.txt +7 -0
 student.  The gitlink:git-log[1], gitlink:git-diff-tree[1], and
 gitlink:git-hash-object[1] man pages may prove helpful.
 
+[[history-advanced-topics]]
+Advanced topics
+---------------
+This section covers advanced topics that typically require more
+knowledge about git than the manual presented to this point.
+
+You may want to skip the section at first reading, and come back

I think the correct wording here is "on first reading". If a native English speaker could confirm this...

Quoted 11 lines
Documentation/user-manual.txt +4 -0
+later when you have a better understanding of git.
+
+[[bisect-merges]]
+Why bisecting merge commits can be harder than bisecting linear  

history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~

Documentation/user-manual.txt +3 -0
+The following text is based upon an email by Junio C. Hamano to
+the git mailing list
+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http:// 

marc.info/?l=git&m=119403257315527&w=2]).

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 955

Quoted 4 lines
Documentation/user-manual.txt +4 -0
+It was slightly adapted for this manual.
+
+Bisecting merges can be challenging due to the complexity of
+changes introduced at a merge.  Bisecting through merges is not a

s/at a merge/& point/ ?

Quoted 11 lines
Documentation/user-manual.txt +11 -0
+technical problem. The real problem is what to do when the
+culprit turns out to be a merge commit.  How to spot what really
+is wrong, and figure out how to fix.  The problem is not for the
+tool but for the human, and it is real.
+
+Imagine this history.
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 976

Quoted 10 lines
Documentation/user-manual.txt +10 -0
+................................................
+
+Suppose that on the upper development line, the meaning of one
+of the functions that existed at Z was changed at commit X.  The
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.
+
+Suppose in the meantime the lower development line somebody

s/Suppose/& that/

Quoted 4 lines
Documentation/user-manual.txt +4 -0
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 990

Quoted 10 lines
Documentation/user-manual.txt +10 -0
+
+You merge to create C.  There is no textual conflict with this
+three way merge, and the result merges cleanly.  You bisect
+this, because you found D is bad and you know Z was good.  Your
+bisect will find that C (merge) is broken.  Understandably so,
+as at C, the new calling site of the function added by the lower
+branch is not converted to the new semantics, while all the
+other calling sites that already existed at Z would have been
+converted by the merge.  The new calling site has semantic
+adjustment needed, but you do not know that yet.  You need to

s/adjustment/&s/

Quoted 28 lines
Documentation/user-manual.txt +28 -0
+find out that that is the cause of the breakage by looking at the
+merge commit C and the history leading to it.
+
+How would you do that?
+
+Both "git diff A C" and "git diff B C" would be an enormous patch.
+Each of them essentially shows the whole change on each branch
+since they diverged.  The developers may have well behaved to
+create good commits that follow the "commit small, commit often,
+commit well contained units" mantra, and each individual commit
+leading from Z to A and from Z to B may be easy to review and
+understand, but looking at these small and easily reviewable
+steps alone would not let you spot the breakage.  You need to
+have a global picture of what the upper branch did (and
+among many, one of them is to change the semantics of that
+particular function) and look first at the huge "diff A C"
+(which shows the change the lower branch introduces), and see if
+that huge change is consistent with what have been done between
+Z and A.
+
+If you linearize the history by rebasing the lower branch on
+top of the upper, instead of merging, the bug becomes much easier to
+find and understand.  Your history would instead be:
+
+................................................................
+    ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*
+................................................................
+

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1028

Quoted 10 lines
Documentation/user-manual.txt +7 -0
+and there is a single commit Y* between A and B* that introduced
+the new calling site that still uses the old semantics of the
+function, even though that was already modified at X. "git show
+Y*" will be a much smaller patch than "git diff A C" and it is
+much easier to deal with.
+
+
 [[Developing-with-git]]
 Developing with git
 ===================

Thank you!

Signature · 2 lines
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory
#27 lore raw
Quoted 5 lines · Benoit Sigoure

Hi Steffen,

On Nov 7, 2007, at 10:50 PM, Steffen Prohaska wrote:

Some more comments below. Sorry for not spotting these earlier.

I'll took all your suggestions except for ...

[...]

Quoted 9 lines
Quoted 9 lines
Documentation/user-manual.txt +4 -0
+later when you have a better understanding of git.
+
+[[bisect-merges]]
+Why bisecting merge commits can be harder than bisecting linear  

history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~

Documentation/user-manual.txt +2 -0
+The following text is based upon an email by Junio C. Hamano to
+the git mailing list
Quoted 8 lines

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 955

Quoted 6 lines

+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http:// marc.info/?l=git&m=119403257315527&w=2]).

Documentation/user-manual.txt +4 -0
+It was slightly adapted for this manual.
+
+Bisecting merges can be challenging due to the complexity of
+changes introduced at a merge.  Bisecting through merges is not a

s/at a merge/& point/ ?

I'll replace the first sentence with

Using gitlink:git-bisect[1] on a history with merges can be challenging.

The details are explained in the remainder of the paragraph.

[...]

Quoted 8 lines
Quoted 8 lines
Documentation/user-manual.txt +8 -0
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.
+
+You merge to create C.  There is no textual conflict with this
+three way merge, and the result merges cleanly.  You bisect
+this, because you found D is bad and you know Z was good.  Your
Quoted 8 lines

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 990

Quoted 6 lines
Documentation/user-manual.txt +6 -0
+bisect will find that C (merge) is broken.  Understandably so,
+as at C, the new calling site of the function added by the lower
+branch is not converted to the new semantics, while all the
+other calling sites that already existed at Z would have been
+converted by the merge.  The new calling site has semantic
+adjustment needed, but you do not know that yet.  You need to

s/adjustment/&s/

I'm not sure if plural is needed.

Steffen

--
Steffen Prohaska <[email protected]> <http://www.zib.de/prohaska/>
Zuse Institute Berlin, Takustraße 7, D-14195 Berlin-Dahlem, Germany +49 (30) 841 85-337, fax -107

#28 lore raw
In reply to Benoit Sigoure
Quoted 51 lines · Benoit Sigoure

Hi Steffen,

Quoted 18 lines · Steffen Prohaska

This commits adds a discussion of the challenge of bisecting merge commits to the user manual. The text is slightly adapted from a mail by Junio C Hamano <[email protected]> to the mailing list
<http://marc.info/?l=git&m=119403257315527&w=2>.

The discussion is added to "Exploring git history" in a sub-section titled "Advanced topics". The discussion requires detailed knowledge about git. It is assumed that the reader will skip advanced topics on first reading. At least the text suggest to do so.

---
 Documentation/user-manual.txt |   89 
+++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)
Quoted 7 lines

Some minor errors were fixed. Thanks to <[email protected]>.

I kept the naming of the commits. Benoit Sigoure suggested to choose a different naming which he claims would be easier to remember. I'm not convinced. The current naming starts with X, Y, Z on the left and names the remaining commits on the right with A, B, C, D. This is simple and give sufficient orientation.

I still disagree but... fair enough ;)
You end up comparing [ABCD] with [XYZ] which (to me) is hard to follow because it's like you were comparing two different kind of entities. I tend to think more in term of branch (e.g. what's happened to the upper branch and what's happened to the lower branch, rather than think in terms of "before a point in time" and "after that point in time"). Because of that, I constantly need to look back at the scheme to find out what is A', what is Z' etc.

Some more comments below. Sorry for not spotting these earlier.

Quoted 10 lines
Documentation/user-manual.txt +0 -0
index d99adc6..d0e738e 100644
@@ -934,6 +934,95 @@ Figuring out why this works is left as an exercise to 
 the (advanced)
 student.  The gitlink:git-log[1], gitlink:git-diff-tree[1], and
 gitlink:git-hash-object[1] man pages may prove helpful.
 
Quoted 10 lines

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 943

Quoted 7 lines
Documentation/user-manual.txt +7 -0
+[[history-advanced-topics]]
+Advanced topics
+---------------
+This section covers advanced topics that typically require more
+knowledge about git than the manual presented to this point.
+
+You may want to skip the section at first reading, and come back

I think the correct wording here is "on first reading". If a native English speaker could confirm this...

Confirmed....

--b.

#11 lore raw

PATCH v3 1/1 user-manual: add advanced topic "bisecting merges"

In reply to Steffen Prohaska

This commits adds a discussion of the challenge of bisecting merge commits to the user manual. The original author is Junio C Hamano <[email protected]>, who posted the text to the mailing list:
<http://marc.info/?l=git&m=119403257315527&w=2>.
The text from the email is slightly adapted for the manual.

The discussion is added to "Exploring git history" in a sub-section titled "Advanced topics". The discussion requires detailed knowledge about git. It is assumed that the reader will skip advanced topics on first reading. At least the text suggest to do so.

The text includes suggestions and fixed by
Ralf Wildenhues <[email protected]>,
Benoit Sigoure <[email protected]>,
Johannes Sixt <[email protected]>.

---
 Documentation/user-manual.txt |  104 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 104 insertions(+), 0 deletions(-)

Next try.

The text now contains an introductory paragraph, proposes rebase as a 'solution', and recommends to throw away the rebased branch.

Steffen

Documentation/user-manual.txt +104 -0
index d99adc6..2f4c314 100644
@@ -934,6 +934,110 @@ Figuring out why this works is left as an exercise to the (advanced)
 student.  The gitlink:git-log[1], gitlink:git-diff-tree[1], and
 gitlink:git-hash-object[1] man pages may prove helpful.
 
+[[history-advanced-topics]]
+Advanced topics
+---------------
+This section covers advanced topics that typically require more
+knowledge about git than the manual presented to this point.
+
+You may want to skip the section on first reading, and come back
+later when you have a better understanding of git.
+
+[[bisect-merges]]
+Why bisecting merge commits can be harder than bisecting linear history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+This section discusses how gitlink:git-bisect[1] plays
+with differently shaped histories. If you did not yet
+publish a branch you can use either gitlink:git-merge[1] or
+gitlink:git-rebase[1] to integrate changes from a second
+branch. The two approaches create differently shaped
+histories. This section discusses the implications on
+gitlink:git-bisect[1]. If the history is already published
+temporarily rebasing can still be helpful for bisecting.
+
+The following text is based upon an email by Junio C. Hamano to
+the git mailing list
+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http://marc.info/?l=git&m=119403257315527&w=2]).
+It was slightly adapted for this manual.
+
+Using gitlink:git-bisect[1] on a history with merges can be challenging.
+Bisecting through merges is not a
+technical problem. The real problem is what to do when the
+culprit turns out to be a merge commit.  How to spot what really
+is wrong, and figure out how to fix.  The problem is not for the
+tool but for the human, and it is real.
+
+Imagine this history.
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B
+................................................
+
+Suppose that on the upper development line, the meaning of one
+of the functions that existed at Z was changed at commit X.  The
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.
+
+Suppose that in the meantime the lower development line somebody
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.
+
+You merge to create C.  There is no textual conflict with this
+three way merge, and the result merges cleanly.  You bisect
+this, because you found D is bad and you know Z was good.  Your
+bisect will find that C (merge) is broken.  Understandably so,
+as at C, the new calling site of the function added by the lower
+branch is not converted to the new semantics, while all the
+other calling sites that already existed at Z would have been
+converted by the merge.  The new calling site has semantic
+adjustment needed, but you do not know that yet.  You need to
+find out that that is the cause of the breakage by looking at the
+merge commit C and the history leading to it.
+
+How would you do that?
+
+Both "git diff A C" and "git diff B C" would be an enormous patch.
+Each of them essentially shows the whole change on each branch
+since they diverged.  The developers may have well behaved to
+create good commits that follow the "commit small, commit often,
+commit well contained units" mantra, and each individual commit
+leading from Z to A and from Z to B may be easy to review and
+understand, but looking at these small and easily reviewable
+steps alone would not let you spot the breakage.  You need to
+have a global picture of what the upper branch did (and
+among many, one of them is to change the semantics of that
+particular function) and look first at the huge "diff A C"
+(which shows the change the lower branch introduces), and see if
+that huge change is consistent with what have been done between
+Z and A.
+
+A solution is to linearize the history by rebasing the lower
+branch on top of the upper, instead of merging. There were no
+textual conflicts in the original three way merge. So there
+should not be conflicts during rebase either. Now the bug becomes
+much easier to find and understand. Your history would instead
+be:
+
+................................................................
+    ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*
+................................................................
+
+and there is a single commit Y* between A and B* that introduced
+the new calling site that still uses the old semantics of the
+function, even though that was already modified at X. "git show
+Y*" will be a much smaller patch than "git diff A C" and it is
+much easier to deal with.
+
+Now that you know what caused the error (and how to fix it),
+throw away the rebased branch, and commit a fix on top of D.
+
+
 [[Developing-with-git]]
 Developing with git
 ===================
Signature · 1 line
1.5.3.5.578.g886d
#12 lore raw

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1021

Quoted 3 lines · Steffen Prohaska

...

Documentation/user-manual.txt +2 -0
+A solution is to linearize the history by rebasing the lower
+branch on top of the upper, instead of merging. There were no

Hmm. When I wrote it, I did not mean this as a "solution", but as an illustration of how a merge heavy history and a linear history have impact on bisectability. So it is more like...

On the other hand, if you did not merge at C but rebased the history between Z to B on top of A, you would have get this linear history [illustration here]. Bisecting between Z and D* would hit a single culprit commit Y* instead. This tends to be easier to understand why it is broken.

For this reason, many experienced git users, even when they are working on an otherwise merge-heavy project, keep the histories linear by rebasing their work on top of public upstreams before publishing (when able). An extreme example: merges from a few top-level lieutenants to Linus in the kernel, e.g. David Miller, are known to _almost always_ fast-forward for Linus.

IOW, the description is to mildly encourage private rebasing to keep the job of later bisecting (for potentially others) easier. I realize I originally wrote as if C (merge) was made by the same person as the person who ends up bisecting, but that is not necessarily the case. Keeping the history without needless merges tend to make _other_ people's lives simpler.

And after encouraging the private rebasing, I would continue like...

But if you already made a merge C instead of rebasing, all is not lost. In the illustrated case, you can easily rebase one parent branch on top of the other after the fact, just to understand the history and to make the history more easily bisectable. Even though the published history should not be rewound without consent with others in the project, nobody gets hurt if you rebased to create alternate history privately. After understanding the breakage and coming up with a fix on top of D*, you can discard that rebased history, and apply the same fix on top of D, as D* and D should have the identical trees.

#13 lore raw
Quoted 9 lines · Junio C Hamano

Documentation/user-manual.txt Figuring out why this works is left as an exercise to the (advanced) · line 1021

Quoted 3 lines · Steffen Prohaska

...

Documentation/user-manual.txt +2 -0
+A solution is to linearize the history by rebasing the lower
+branch on top of the upper, instead of merging. There were no

Hmm. When I wrote it, I did not mean this as a "solution", but as an illustration of how a merge heavy history and a linear history have impact on bisectability.

I agree. This is what I understood. But later Johannes brought up the idea of naming it a "solution"; and some others liked this.

We should probably move the discussion to Chapter 5 "Rewriting history and maintaining patch series". Discussing pros and cons of merge versus rebase makes more sense there. The discussion would go right after "Problems with rewriting history". So, users should be warned not to rebase without thinking about the consequences. Another advantage is that users should have learnt more about git when they reach Chapter 5. Hence, it should be easier to follow the discussion.

Quoted 7 lines

So it is more like...

On the other hand, if you did not merge at C but rebased the history between Z to B on top of A, you would have get this linear history [illustration here]. Bisecting between Z and D* would hit a single culprit commit Y* instead. This tends to be easier to understand why it is broken.

I'll take this...

Quoted 14 lines

For this reason, many experienced git users, even when they are working on an otherwise merge-heavy project, keep the histories linear by rebasing their work on top of public upstreams before publishing (when able). An extreme example: merges from a few top-level lieutenants to Linus in the kernel, e.g. David Miller, are known to _almost always_ fast-forward for Linus.

IOW, the description is to mildly encourage private rebasing to keep the job of later bisecting (for potentially others) easier. I realize I originally wrote as if C (merge) was made by the same person as the person who ends up bisecting, but that is not necessarily the case. Keeping the history without needless merges tend to make _other_ people's lives simpler.

Quoted 8 lines

And after encouraging the private rebasing, I would continue like...

But if you already made a merge C instead of rebasing, all is not lost. In the illustrated case, you can easily rebase one parent branch on top of the other after the fact, just to understand the history and to make the history more easily bisectable.

s/more easily bisectable/easier to bisect/ ?

Quoted 7 lines

Even though the published history should
not be rewound without consent with others in the project, nobody gets hurt if you rebased to create alternate history privately. After understanding the breakage and coming up with a fix on top of D*, you can discard that rebased history, and apply the same fix on top of D, as D* and D should have the identical trees.

... and will prepare PATCH v4.

Steffen

#14 lore raw

PATCH v4 1/1 user-manual: Add section "Why bisecting merge commits can be harder ..."

This commit adds a discussion of the challenge of bisecting merge commits to the user manual. The original author is Junio C Hamano <[email protected]>, who posted the text to the mailing list <http://marc.info/?l=git&m=119403257315527&w=2>.
His email was adapted for the manual.

The discussion is added to "Rewriting history and maintainig patch series". The text added requires good understanding of merging and rebasing. Therefore it should not be placed too early in the manual. Right after the section on "Problems with rewriting history", the discussion of bisect gives another reason for linearizing as much of the history as possible.

The text includes suggestions and fixes by
Ralf Wildenhues <[email protected]> and
Benoit Sigoure <[email protected]>.

---
 Documentation/user-manual.txt |   98 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 98 insertions(+), 0 deletions(-)

Since PATCH v3: I moved the section to chapter 5. It's not longer in a separate section titled "Advance Topics". I split the paragraph on merge C and reordered some sentences. I took part the paragraph on "experienced users" from Junio's last email.

Junio, you can take ownership of the commit when applying -- if you like. Most of the text was written by you. Just mention me as the editor in the commit message.

Steffen

Documentation/user-manual.txt +98 -0
index d99adc6..8ddc19f 100644
@@ -2554,6 +2554,104 @@ branches into their own work.
 For true distributed development that supports proper merging,
 published branches should never be rewritten.
 
+[[bisect-merges]]
+Why bisecting merge commits can be harder than bisecting linear history
+-----------------------------------------------------------------------
+
+This section discusses how gitlink:git-bisect[1] plays
+with differently shaped histories.  The text is based upon
+an email by Junio C. Hamano to the git mailing list
+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http://marc.info/?l=git&m=119403257315527&w=2]).
+It was adapted for the user manual.
+
+Using gitlink:git-bisect[1] on a history with merges can be
+challenging.  Bisecting through merges is not a technical
+problem. The real problem is what to do when the culprit turns
+out to be a merge commit.  How to spot what really is wrong, and
+figure out how to fix it.  The problem is not for the tool but
+for the human, and it is real.
+
+Imagine this history:
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B
+................................................
+
+Suppose that on the upper development line, the meaning of one
+of the functions that existed at Z was changed at commit X.  The
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.
+
+Suppose that in the meantime the lower development line somebody
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.
+
+Suppose further that the two development lines were merged at C
+and there was no textual conflict with this three way merge.
+The result merged cleanly.
+
+Now, during bisect you find that the merge C is broken.  You
+started to bisect, because you found D is bad and you know Z was
+good.  The breakage is understandable, as at C, the new calling
+site of the function added by the lower branch is not converted
+to the new semantics, while all the other calling sites that
+already existed at Z would have been converted by the merge.  The
+new calling site has semantic adjustment needed, but you do not
+know that yet.
+
+You need to find out what is the cause of the breakage by looking
+at the merge commit C and the history leading to it.  How would
+you do that?
+
+Both "git diff A C" and "git diff B C" would be an enormous patch.
+Each of them essentially shows the whole change on each branch
+since they diverged.  The developers may have well behaved to
+create good commits that follow the "commit small, commit often,
+commit well contained units" mantra, and each individual commit
+leading from Z to A and from Z to B may be easy to review and
+understand, but looking at these small and easily reviewable
+steps alone would not let you spot the breakage.  You need to
+have a global picture of what the upper branch did (and
+among many, one of them is to change the semantics of that
+particular function) and look first at the huge "diff A C"
+(which shows the change the lower branch introduces), and see if
+that huge change is consistent with what have been done between
+Z and A.
+
+On the other hand, if you did not merge at C but rebased the
+history between Z to B on top of A, you would have get this
+linear history:
+
+................................................................
+    ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*
+................................................................
+
+Bisecting between Z and D* would hit a single culprit commit Y*
+instead.  This tends to be easier to understand why it is broken.
+
+For this reason, many experienced git users, even when they are
+working on an otherwise merge-heavy project, keep the histories
+linear by rebasing their work on top of public upstreams before
+publishing.
+
+But if you already made a merge C instead of rebasing, all
+is not lost.  In the illustrated case, you can easily rebase
+one parent branch on top of the other after the fact, just
+to understand the history and to make the history more
+easily to bisect.  Even though the published history should
+not be rewound without consent with others in the project,
+nobody gets hurt if you rebased to create alternate history
+privately.  After understanding the breakage and coming up
+with a fix on top of D*, you can discard that rebased
+history, and apply the same fix on top of D, as D* and D
+should have the identical trees.
+
 [[advanced-branch-management]]
 Advanced branch management
 ==========================
Signature · 1 line
1.5.3.5.578.g886d
#15 lore raw

Re: [PATCH v4] user-manual: Add section "Why bisecting merge commits can be harder ..."

Documentation/user-manual.txt branches into their own work.

Quoted 6 lines · Steffen Prohaska
Documentation/user-manual.txt +6 -0
+
+But if you already made a merge C instead of rebasing, all
+is not lost.  In the illustrated case, you can easily rebase
+one parent branch on top of the other after the fact, just
+to understand the history and to make the history more
+easily to bisect.

I simply don't think this is true.

You can *not* easily rebase after the fact. Both the parents may have lots of merges independently of each other, and rebase won't be able to do *anything* with such a case. In fact, the only reason you think you can easily rebase after-the-fact is that you made the example history be trivial. In real life, if the example history is that trivial (just a single merge of two otherwise linear histories), you'd probably generally not have this problem in the first place.

The facts are:

- git bisect can handle merges quite well, and points to the right commit (which is *usually* not a merge).

- but merges by definition introduce changes from two independent lines of development, and while both lines may work well on their own, it is possible that (a) the merge itself was done incorrectly or (b) the two (or more) features that were introduced simply clash.

- "git rebase" won't do a thing for this after the fact, except in trivial cases, and even then it will generate a new history that simply isn't compatible with the original history, so while it could in theory help bisect things further in some limited and simple cases, in general it's simply not that useful an approach.

..and I think it's simply wrong to even *try* to imply that "git rebase" can somehow change any of this.

Linus

#16 lore raw

Re: [PATCH v4] user-manual: Add section "Why bisecting merge commits can be harder ..."

Quoted 28 lines · Linus Torvalds

Documentation/user-manual.txt branches into their own work.

Quoted 6 lines · Steffen Prohaska
Documentation/user-manual.txt +6 -0
+
+But if you already made a merge C instead of rebasing, all
+is not lost.  In the illustrated case, you can easily rebase
+one parent branch on top of the other after the fact, just
+to understand the history and to make the history more
+easily to bisect.

I simply don't think this is true.

You can *not* easily rebase after the fact. Both the parents may have lots of merges independently of each other, and rebase won't be able to do *anything* with such a case. In fact, the only reason you think you can easily rebase after-the-fact is that you made the example history be trivial. In real life, if the example history is that trivial (just a single merge of two otherwise linear histories), you'd probably generally not have this problem in the first place.

The facts are:

- git bisect can handle merges quite well, and points to the right commit (which is *usually* not a merge).

- but merges by definition introduce changes from two independent lines of development, and while both lines may work well on their own, it is possible that (a) the merge itself was done incorrectly or (b) the two (or more) features that were introduced simply clash.

Quoted 8 lines

- "git rebase" won't do a thing for this after the fact, except in trivial cases, and even then it will generate a new history that simply isn't compatible with the original history, so while it could in theory help bisect things further in some limited and simple cases, in general it's simply not that useful an approach.

..and I think it's simply wrong to even *try* to imply that "git rebase" can somehow change any of this.

Very true. It is a suggestion useful _only_ when you can easily rebase. Like the one illustrated in the description, which is artificial and of very limited scope. If you cannot rebase easily, then (by definition) rebase would not help you.

#17 lore raw

Re: [PATCH v4] user-manual: Add section "Why bisecting merge commits can be harder ..."

Quoted 42 lines · Junio C Hamano
Quoted 40 lines · Linus Torvalds

Documentation/user-manual.txt branches into their own work.

Quoted 6 lines · Steffen Prohaska
Documentation/user-manual.txt +6 -0
+
+But if you already made a merge C instead of rebasing, all
+is not lost.  In the illustrated case, you can easily rebase
+one parent branch on top of the other after the fact, just
+to understand the history and to make the history more
+easily to bisect.

I simply don't think this is true.

You can *not* easily rebase after the fact. Both the parents may have lots of merges independently of each other, and rebase won't be able to do *anything* with such a case. In fact, the only reason you think you can easily rebase after-the-fact is that you made the example history be trivial. In real life, if the example history is that trivial (just a single merge of two otherwise linear histories), you'd probably generally not have this problem in the first place.

The facts are:

- git bisect can handle merges quite well, and points to the right commit (which is *usually* not a merge).

- but merges by definition introduce changes from two independent
lines
of development, and while both lines may work well on their
own, it is
possible that (a) the merge itself was done incorrectly or (b)
the two
(or more) features that were introduced simply clash.

- "git rebase" won't do a thing for this after the fact, except in trivial cases, and even then it will generate a new history
that simply
isn't compatible with the original history, so while it could
in theory
help bisect things further in some limited and simple cases, in
general
it's simply not that useful an approach.

Quoted 7 lines
Quoted 2 lines

..and I think it's simply wrong to even *try* to imply that "git rebase" can somehow change any of this.

Very true. It is a suggestion useful _only_ when you can easily rebase. Like the one illustrated in the description, which is artificial and of very limited scope. If you cannot rebase easily, then (by definition) rebase would not help you.

I propose to remove this suggestion if no one comes up with a real world example where rebasing after the fact turned out to be useful. If nobody has such an example it doesn't make sense to tell readers of the manual that rebase could be useful in such a situation.

The patch would be identical except for the last paragraph removed.

Steffen

#18 lore raw

Re: [PATCH v4] user-manual: Add section "Why bisecting merge commits can be harder ..."

In reply to Steffen Prohaska

Documentation/user-manual.txt branches into their own work. · line 2565

Quoted 9 lines · Steffen Prohaska

+[[bisect-merges]]

Documentation/user-manual.txt +8 -0
+Why bisecting merge commits can be harder than bisecting linear history
+-----------------------------------------------------------------------
+
+This section discusses how gitlink:git-bisect[1] plays
+with differently shaped histories.  The text is based upon
+an email by Junio C. Hamano to the git mailing list
+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http://marc.info/?l=git&m=119403257315527&w=2]).
+It was adapted for the user manual.

This is not the only text that's been taken from someplace else, but if we attributed them all in the text it would get a little cumbersome.... I think the place for that kind of thing is in the commit message, but if we really think we need to include it in the main text, we could add a separate "'acknowledgements" section.

Documentation/user-manual.txt branches into their own work. · line 2572

Quoted 7 lines
Documentation/user-manual.txt +7 -0
+
+Using gitlink:git-bisect[1] on a history with merges can be
+challenging.  Bisecting through merges is not a technical
+problem. The real problem is what to do when the culprit turns
+out to be a merge commit.  How to spot what really is wrong, and
+figure out how to fix it.  The problem is not for the tool but
+for the human, and it is real.

I think we can pare that down a little.

Quoted 59 lines
Documentation/user-manual.txt +59 -0
+
+Imagine this history:
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B
+................................................
+
+Suppose that on the upper development line, the meaning of one
+of the functions that existed at Z was changed at commit X.  The
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.
+
+Suppose that in the meantime the lower development line somebody
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.
+
+Suppose further that the two development lines were merged at C
+and there was no textual conflict with this three way merge.
+The result merged cleanly.
+
+Now, during bisect you find that the merge C is broken.  You
+started to bisect, because you found D is bad and you know Z was
+good.  The breakage is understandable, as at C, the new calling
+site of the function added by the lower branch is not converted
+to the new semantics, while all the other calling sites that
+already existed at Z would have been converted by the merge.  The
+new calling site has semantic adjustment needed, but you do not
+know that yet.
+
+You need to find out what is the cause of the breakage by looking
+at the merge commit C and the history leading to it.  How would
+you do that?
+
+Both "git diff A C" and "git diff B C" would be an enormous patch.
+Each of them essentially shows the whole change on each branch
+since they diverged.  The developers may have well behaved to
+create good commits that follow the "commit small, commit often,
+commit well contained units" mantra, and each individual commit
+leading from Z to A and from Z to B may be easy to review and
+understand, but looking at these small and easily reviewable
+steps alone would not let you spot the breakage.  You need to
+have a global picture of what the upper branch did (and
+among many, one of them is to change the semantics of that
+particular function) and look first at the huge "diff A C"
+(which shows the change the lower branch introduces), and see if
+that huge change is consistent with what have been done between
+Z and A.
+
+On the other hand, if you did not merge at C but rebased the
+history between Z to B on top of A, you would have get this
+linear history:
+
+................................................................

Documentation/user-manual.txt branches into their own work. · line 2641

Quoted 10 lines
Documentation/user-manual.txt +10 -0
+    ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*
+................................................................
+
+Bisecting between Z and D* would hit a single culprit commit Y*
+instead.  This tends to be easier to understand why it is broken.
+
+For this reason, many experienced git users, even when they are
+working on an otherwise merge-heavy project, keep the histories
+linear by rebasing their work on top of public upstreams before
+publishing.

I'd say "partly for this reason", as I don't think this is the only reason people do that.

I've done the above revisions and a few others and pushed them to

git://linux-nfs.org/~bfields/git.git maint

I'll take another look in the morning.

--b.

#19 lore raw

Re: [PATCH v4] user-manual: Add section "Why bisecting merge commits can be harder ..."

Quoted 11 lines · J. Bruce Fields
Quoted 10 lines · Steffen Prohaska

+[[bisect-merges]]
+Why bisecting merge commits can be harder than bisecting linear history
+--------------------------------------------------------------------
---

Documentation/user-manual.txt +5 -0
+
+This section discusses how gitlink:git-bisect[1] plays
+with differently shaped histories.  The text is based upon
+an email by Junio C. Hamano to the git mailing list
+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http:// 
Quoted 8 lines
Quoted 2 lines

marc.info/?l=git&m=119403257315527&w=2]).
+It was adapted for the user manual.

This is not the only text that's been taken from someplace else, but if we attributed them all in the text it would get a little cumbersome.... I think the place for that kind of thing is in the commit message, but if we really think we need to include it in the main text, we could add a separate "'acknowledgements" section.

ack for this change.

And a general comment: I had two purposes in mind when I added this paragraph
1) Attribution;
2) Giving a reference to the original discussion. If someone disagrees, or has further questions, the original discussion on the mailing list could be useful.

I believe the commit message is sufficient for attribution. I don't think we need more. Maybe if the manual goes to print we need to reconsider. But who know if this ever will happen.

However, adding a References section with links to other resources could be a useful thing. Such resources could give additional information, without sacrificing the conciseness of the manual. An example are links to the original discussion on the list. Often they contain more details, which may sometimes be useful.

Does asciidoc provide a mechanism for this? Something like \cite{} in LaTeX.

Quoted 9 lines

Documentation/user-manual.txt branches into their own work. · line 2572

Quoted 7 lines
Documentation/user-manual.txt +7 -0
+
+Using gitlink:git-bisect[1] on a history with merges can be
+challenging.  Bisecting through merges is not a technical
+problem. The real problem is what to do when the culprit turns
+out to be a merge commit.  How to spot what really is wrong, and
+figure out how to fix it.  The problem is not for the tool but
+for the human, and it is real.

I think we can pare that down a little.

From your 7df716bec6bf6e3dafe4c36a6313a4346de2585a

+The gitlink:git-bisect[1] commands deals fine with history that includes +merge commits. However, when the final commit that ends on is a merge +commit, the user may need to work harder than usual to figure out +exactly what the problem was.

If you don't take the text below, first line: s/commands/command/

I'd reverse the order of the sentences. The section is about the difficulty, not about praising git-bisect. How about

When the final commit that a bisect ends on is a merge commit, the user may need to work harder than usual to figure out exactly what the problem was. This is not a technical problem. In principle, the gitlink:git-bisect[1] command deals fine with history that includes merge commits.

It's your call. I'm also fine with your version.

Quoted 27 lines
Quoted 27 lines
Documentation/user-manual.txt +27 -0
+
+Imagine this history:
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B
+................................................
+
+Suppose that on the upper development line, the meaning of one
+of the functions that existed at Z was changed at commit X.  The
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.
+
+Suppose that in the meantime the lower development line somebody
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.
+
+Suppose further that the two development lines were merged at C
+and there was no textual conflict with this three way merge.
+The result merged cleanly.
+
+Now, during bisect you find that the merge C is broken.  You
Quoted 8 lines

Documentation/user-manual.txt branches into their own work. · line 2607

Quoted 8 lines
Documentation/user-manual.txt +8 -0
+started to bisect, because you found D is bad and you know Z was
+good.  The breakage is understandable, as at C, the new calling
+site of the function added by the lower branch is not converted
+to the new semantics, while all the other calling sites that
+already existed at Z would have been converted by the merge.  The
+new calling site has semantic adjustment needed, but you do not
+know that yet.
+

From your 7df716bec6bf6e3dafe4c36a6313a4346de2585a

+Nevertheless, the code at C is broken, because the callers added +on the lower line of development have not been converted to the new +semantics introduced on the upper line of development. So if all +you know is that D was bad, Z was good, and that a

s/a//? I'm not sure; you are the native speaker ;)

+gitlink:git-bisect[1] identified C as the culprit, how will you +figure out that the problem was due to this change in semantics?

Quoted 11 lines
Quoted 11 lines
Documentation/user-manual.txt +11 -0
+You need to find out what is the cause of the breakage by looking
+at the merge commit C and the history leading to it.  How would
+you do that?
+
+Both "git diff A C" and "git diff B C" would be an enormous patch.
+Each of them essentially shows the whole change on each branch
+since they diverged.  The developers may have well behaved to
+create good commits that follow the "commit small, commit often,
+commit well contained units" mantra, and each individual commit
+leading from Z to A and from Z to B may be easy to review and
+understand, but looking at these small and easily reviewable
Quoted 8 lines

Documentation/user-manual.txt branches into their own work. · line 2626

Quoted 8 lines
Documentation/user-manual.txt +8 -0
+steps alone would not let you spot the breakage.  You need to
+have a global picture of what the upper branch did (and
+among many, one of them is to change the semantics of that
+particular function) and look first at the huge "diff A C"
+(which shows the change the lower branch introduces), and see if
+that huge change is consistent with what have been done between
+Z and A.
+

From your 7df716bec6bf6e3dafe4c36a6313a4346de2585a

+When the result of a git-bisect is a non-merge commit, you should +normally be able to discover the problem be examining just that commit.

s/be examining/by examining/

+Developers can make this easy by breaking their changes into small +self-contained commits. That won't help in the case above, however, +because the problem isn't obvious from examination of any single +commit; instead, a global view of the development is required. To +make matters worse, the change in semantics in the problematic +function may be just one small part of the changes in the upper +line of development.
+

Quoted 19 lines
Quoted 5 lines
Documentation/user-manual.txt +5 -0
+On the other hand, if you did not merge at C but rebased the
+history between Z to B on top of A, you would have get this
+linear history:
+
+................................................................

Documentation/user-manual.txt branches into their own work. · line 2641

Quoted 10 lines
Documentation/user-manual.txt +10 -0
+    ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*
+................................................................
+
+Bisecting between Z and D* would hit a single culprit commit Y*
+instead.  This tends to be easier to understand why it is broken.
+
+For this reason, many experienced git users, even when they are
+working on an otherwise merge-heavy project, keep the histories
+linear by rebasing their work on top of public upstreams before
+publishing.

I'd say "partly for this reason", as I don't think this is the only reason people do that.

Quoted 5 lines

I've done the above revisions and a few others and pushed them to

git://linux-nfs.org/~bfields/git.git maint

I'll take another look in the morning.

Besides the minor fixes above, ack from me. We already spend a lot of time on this section. It improved compared to the first version and I think it's now ready for the manual.

Steffen

#20 lore raw

Re: [PATCH v4] user-manual: Add section "Why bisecting merge commits can be harder ..."

Quoted 40 lines · Steffen Prohaska
Quoted 16 lines · J. Bruce Fields

Documentation/user-manual.txt branches into their own work. · line 2565

Quoted 9 lines · Steffen Prohaska

+[[bisect-merges]]

Documentation/user-manual.txt +8 -0
+Why bisecting merge commits can be harder than bisecting linear history
+-----------------------------------------------------------------------
+
+This section discusses how gitlink:git-bisect[1] plays
+with differently shaped histories.  The text is based upon
+an email by Junio C. Hamano to the git mailing list
+(link:http://marc.info/?l=git&m=119403257315527&w=2[link:http://marc.info/?l=git&m=119403257315527&w=2]).
+It was adapted for the user manual.

This is not the only text that's been taken from someplace else, but if we attributed them all in the text it would get a little cumbersome.... I think the place for that kind of thing is in the commit message, but if we really think we need to include it in the main text, we could add a separate "'acknowledgements" section.

ack for this change.

And a general comment: I had two purposes in mind when I added this paragraph
1) Attribution;
2) Giving a reference to the original discussion. If someone disagrees, or has further questions, the original discussion on the mailing list could be useful.

I believe the commit message is sufficient for attribution. I don't think we need more. Maybe if the manual goes to print we need to reconsider. But who know if this ever will happen.

However, adding a References section with links to other resources could be a useful thing. Such resources could give additional information, without sacrificing the conciseness of the manual. An example are links to the original discussion on the list. Often they contain more details, which may sometimes be useful.

Quoted 2 lines

Does asciidoc provide a mechanism for this? Something like \cite{} in LaTeX.

We could add a "for more details, see link:..." at the end, though I don't think it's necessary in this case.

Quoted 16 lines
Quoted 8 lines

Documentation/user-manual.txt branches into their own work. · line 2572

Quoted 6 lines
Documentation/user-manual.txt +6 -0
+Using gitlink:git-bisect[1] on a history with merges can be
+challenging.  Bisecting through merges is not a technical
+problem. The real problem is what to do when the culprit turns
+out to be a merge commit.  How to spot what really is wrong, and
+figure out how to fix it.  The problem is not for the tool but
+for the human, and it is real.

I think we can pare that down a little.

From your 7df716bec6bf6e3dafe4c36a6313a4346de2585a

(quoted diff) +4 -0
+The gitlink:git-bisect[1] commands deals fine with history that includes
+merge commits.  However, when the final commit that ends on is a merge
+commit, the user may need to work harder than usual to figure out
+exactly what the problem was.
Quoted 1 line

If you don't take the text below, first line: s/commands/command/

Whoops, thanks!

Quoted 11 lines

I'd reverse the order of the sentences. The section is about the difficulty, not about praising git-bisect. How about

When the final commit that a bisect ends on is a merge commit, the user may need to work harder than usual to figure out exactly what the problem was. This is not a technical problem. In principle, the gitlink:git-bisect[1] command deals fine with history that includes merge commits.

It's your call. I'm also fine with your version.

OK; I see your point but I think I'll stick with my version (with another minor fix or two)--the order seems more natural: first dismiss the obvious objection to the title, then introduce the problem that leads to the following discussion.

Quoted 43 lines
Quoted 27 lines
Quoted 27 lines
Documentation/user-manual.txt +27 -0
+
+Imagine this history:
+
+................................................
+      ---Z---o---X---...---o---A---C---D
+          \                       /
+           o---o---Y---...---o---B
+................................................
+
+Suppose that on the upper development line, the meaning of one
+of the functions that existed at Z was changed at commit X.  The
+commits from Z leading to A change both the function's
+implementation and all calling sites that existed at Z, as well
+as new calling sites they add, to be consistent.  There is no
+bug at A.
+
+Suppose that in the meantime the lower development line somebody
+added a new calling site for that function at commit Y.  The
+commits from Z leading to B all assume the old semantics of that
+function and the callers and the callee are consistent with each
+other.  There is no bug at B, either.
+
+Suppose further that the two development lines were merged at C
+and there was no textual conflict with this three way merge.
+The result merged cleanly.
+
+Now, during bisect you find that the merge C is broken.  You
Quoted 8 lines

Documentation/user-manual.txt branches into their own work. · line 2607

Quoted 8 lines
Documentation/user-manual.txt +8 -0
+started to bisect, because you found D is bad and you know Z was
+good.  The breakage is understandable, as at C, the new calling
+site of the function added by the lower branch is not converted
+to the new semantics, while all the other calling sites that
+already existed at Z would have been converted by the merge.  The
+new calling site has semantic adjustment needed, but you do not
+know that yet.
+

From your 7df716bec6bf6e3dafe4c36a6313a4346de2585a

(quoted diff) +4 -0
+Nevertheless, the code at C is broken, because the callers added
+on the lower line of development have not been converted to the new
+semantics introduced on the upper line of development.  So if all
+you know is that D was bad, Z was good, and that a
Quoted 1 line

s/a//? I'm not sure; you are the native speaker ;)

I agree, it's better without the "a", thanks.

Quoted 31 lines
(quoted diff) +2 -0
+gitlink:git-bisect[1] identified C as the culprit, how will you
+figure out that the problem was due to this change in semantics?
Quoted 14 lines
Quoted 14 lines
Documentation/user-manual.txt +11 -0
+You need to find out what is the cause of the breakage by looking
+at the merge commit C and the history leading to it.  How would
+you do that?
+
+Both "git diff A C" and "git diff B C" would be an enormous patch.
+Each of them essentially shows the whole change on each branch
+since they diverged.  The developers may have well behaved to
+create good commits that follow the "commit small, commit often,
+commit well contained units" mantra, and each individual commit
+leading from Z to A and from Z to B may be easy to review and
+understand, but looking at these small and easily reviewable
Quoted 8 lines

Documentation/user-manual.txt branches into their own work. · line 2626

Quoted 8 lines
Documentation/user-manual.txt +8 -0
+steps alone would not let you spot the breakage.  You need to
+have a global picture of what the upper branch did (and
+among many, one of them is to change the semantics of that
+particular function) and look first at the huge "diff A C"
+(which shows the change the lower branch introduces), and see if
+that huge change is consistent with what have been done between
+Z and A.
+

From your 7df716bec6bf6e3dafe4c36a6313a4346de2585a

(quoted diff) +2 -0
+When the result of a git-bisect is a non-merge commit, you should
+normally be able to discover the problem be examining just that commit.
Quoted 1 line

s/be examining/by examining/

Oops, thanks.

Quoted 5 lines
Quoted 5 lines

I'd say "partly for this reason", as I don't think this is the only reason people do that.

I've done the above revisions and a few others and pushed them to

Quoted 7 lines
Quoted 3 lines

git://linux-nfs.org/~bfields/git.git maint

I'll take another look in the morning.

Besides the minor fixes above, ack from me. We already spend a lot of time on this section. It improved compared to the first version and I think it's now ready for the manual.

OK, thanks for your patience! This plus an unrelated trivial fix are available for Junio to pull from

git://linux-nfs.org/~bfields/git.git maint

(Full history also available from the maint-history branch).

--b.