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.
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.
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.
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.
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.
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.
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.