Consider Figure 5.1.1. This figure shows a feature branch (in the left panel) that is to be merged into the current main branch (in the right panel). The center panel shows the best common ancestor from which both the feature branch and main branch have diverged.
The current main branch contains changes, merged by the maintainers, to fix several bugs that existed in the best common ancestor. The feature branch has been changed to use more descriptive variable names, but has not fixed all of the bugs.
Study the program shown in the main branch of Figure 5.1.1. Then choose the statement below that best describes the computation the program is trying to perform. Note: The Feature Branch and the Best Common Ancestor both contain bugs.
What does the program do besides count the numbers?
None of these.
One of the other answers is correct.
Hint.
The statements in the loop are indented, whereas the statement that will happen after the loop has the same indentation as the word while. Think about what is being repeated and how those values are being used after the loop.
When both the feature branch being merged and the main branch that it is being merged into contain changes with respect to the best common ancestor, those changes can be non-conflicting or conflicting.
A non-conflicting change occurs when a part of the code changes in the feature branch or in the main branch but not in both.
Correct!
A non-conflicting change occurs when a part of the code changes in both the feature branch and the main branch.
Review the definitions of non-conflicting and conflicting changes in the class slides.
A non-conflicting change occurs when the best common ancestor is modified.
The best common ancestor cannot be changed, all changes are either in the feature branch or the main branch.
A non-conflicting change occurs when part of the feature branch contains only one change.
You need to consider changes to both the feature branch and the main branch to determine if a change is non-conflicting.
Hint.
Refer to the class slides for the definitions of non-conflicting and conflicting. Then go back to Figure 5.1.1 and look at the changes made in both branches.
A conflicting change occurs when a part of the code changes in the feature branch or in the main branch but not in both.
Review the definitions of non-conflicting and conflicting changes in the class slides.
A conflicting change occurs when a part of the code changes in both the feature branch and the main branch.
Correct!
A conflicting change occurs when the best common ancestor is modified.
The best common ancestor cannot be changed, all changes are either in the feature branch or the main branch.
A conflicting change occurs when a part of the feature branch contains multiple changes.
You need to consider changes to both the feature branch and the main branch to determine if a change is conflicting.
Hint.
Refer to the class slides for the definitions of non-conflicting and conflicting. Then go back to Figure 5.1.1 and look at the changes made in both branches.
Highlight (by clicking) all of the lines (if any) in the main branch and the feature branch that contain non-conflicting changes. Use the example in the course slides as a guide.
Highlight by clicking all of the lines (if any) in the main and feature branches that contain conflicting changes. Use the example in the course slides as a guide.
Select the statement below that best describes why the feature branch in Figure 5.1.1 would, or would not, be able to be merged automatically by the project maintainers.
The feature branch cannot be merged automatically because there is a conflicting change.
Correct!
The feature branch can be merged automatically because all of the changes are non-conflicting.
Are you sure there are no conflicting changes? Refer back to Task 5.1.1.3.b.
The feature branch cannot be merged automatically because there are non-conflicting changes.
Non-conflicting changes can (usually) be merged automatically.
It is not possible to tell if the feature branch can be merged automatically.
It is possible to tell by comparing the changes between the feature branch and the main branch.
The feature branch cannot be merged automatically because there are changes both in main and in the feature branch.
You are close. What type of changes prevent automatic merges?
Hint.
Think about which type of changes can be automatically merged and which cause merge conflicts. Then refer to Figure 5.1.1 to see which type(s) of changes it contains.
Use the table below to indicate how the feature branch would be merged into the main branch. Each line that contains a change is shown in boldface. Click the boldfaced statements in the feature branch or the main branch to indicate the version of the line that will appear in the merged result. The merged result should include all non-conflicting changes and should resolve the conflicting change. The resulting program must perform the desired computation as identified in Exercise 5.1.1.1
As in the previous example, the right-hand panel shows commits that the maintainers have merged into the main branch to fix a bug that existed in the program. The left-hand panel shows the contributor’s feature branch with changes that also fix the bug, but in a different way. The center panel shows the best common ancestor of the feature and main branches.
Study the program in Figure 5.1.2. Then choose the statement below that best describes the computation the program is trying to perform. Note: The ** operator indicates exponentiation, so x**2 computes x squared.
Select the statement below that best describes why the feature branch in Figure 5.1.2 would, or would not, be able to be merged automatically by the project maintainers.
The feature branch can be merged automatically because all of the changes are non-conflicting.
Correct!
The feature branch cannot be merged automatically because there is a conflicting change.
Refer back to your previous answers and think about whether there are any conflicting changes.
The feature branch cannot be merged automatically because there are non-conflicting changes.
Non-conflicting changes can (usually) be merged automatically.
It is not possible to tell if the feature branch can be merged automatically.
Refer back to your previous answers and think about whether there are any conflicting changes.
The feature branch cannot be merged automatically because there are changes both in main and in the feature branch.
What type of changes prevent automatic merges?
Hint.
Think about which type of changes can be automatically merged and which cause merge conflicts. Then refer to Figure 5.1.2 to see which type(s) of changes it contains.
Imagine that the non-conflicting changes you identified in Task 5.1.2.2.a are automatically merged. Select the statement below that best describes the result.
The merged program will not work correctly because the formula for the area will be incorrect.
Correct!
The merged program will work correctly because automatic merge’s are guaranteed to produce a correct program.
Look closely at the lines that define rsq and area.
The merged program will not work correctly because an incorrect value of pi will be used.
3.1415927 is a valid approximation of pi.
The merged program will work correctly because rsq is correctly computed as r squared instead of r*2.
Look closely at how the area will be computed.
Hint.
Merged changes are not always correct. It is important to look closely at the code that is being accepted to determine if the changes fix any problems or introduce new problems.
When both the feature branch and the main branch function correctly, and the merge contains no conflicting changes then the result of an automatic merge will also be correct.