Handling merge conflicts

In assignment 3, you will do your first merge for this course. From the ~/os161/src directory, apply git merge:

jharvard@appliance (~/os161/src): git merge instructor/synchprobs
 Auto-merging kern/thread/thread.c
 CONFLICT (add/add): Merge conflict in kern/thread/thread.c
 Auto-merging kern/thread/synch.c
 CONFLICT (add/add): Merge conflict in kern/thread/synch.c
 Auto-merging kern/test/tt3.c
 CONFLICT (add/add): Merge conflict in kern/test/tt3.c
 Auto-merging kern/main/menu.c
 CONFLICT (add/add): Merge conflict in kern/main/menu.c
 Auto-merging kern/include/test.h
 CONFLICT (add/add): Merge conflict in kern/include/test.h
 Auto-merging kern/include/synch.h
 CONFLICT (add/add): Merge conflict in kern/include/synch.h
 Auto-merging kern/include/clock.h
 CONFLICT (add/add): Merge conflict in kern/include/clock.h
 Auto-merging kern/conf/conf.kern
 CONFLICT (add/add): Merge conflict in kern/conf/conf.kern
 Auto-merging kern/conf/GENERIC-OPT
 CONFLICT (add/add): Merge conflict in kern/conf/GENERIC-OPT
 Auto-merging kern/conf/GENERIC
 CONFLICT (add/add): Merge conflict in kern/conf/GENERIC
 Auto-merging kern/conf/DUMBVM-OPT
 CONFLICT (add/add): Merge conflict in kern/conf/DUMBVM-OPT
 Auto-merging kern/conf/DUMBVM
 CONFLICT (add/add): Merge conflict in kern/conf/DUMBVM
 Automatic merge failed; fix conflicts and then commit the result.
Next, Fix the conflicts by editing each of the listed files above around the areas marked by <<<<<<<, =======, and >>>>>>> annotations. For example, the following conflict in kern/conf/DUMBVM:
<<<<<<< HEAD
=======
#options synchprobs        # Enable this only when doing the
# synchronization problems.
>>>>>>> instructor/synchprobs
can be fixed by choosing either the current (marked by HEAD), remote (marked by instructor/synchprobs), or a combination from the current and the remote versions. We will choose the remote version since that is what we want for the current assignment:
#options synchprobs # Enable this only when doing the
# synchronization problems.

After you think you have fixed all the conflicts, make sure you actually did by searching for the conflict strings in your entire source tree:

cd ~/os161/src
grep -r ">>>>>> instructor" *
If the search returns no files, you are ready to complete the merge and commit! To proceed, run git status to check what you have to stage for commit/merging. You will see something like this:
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")

Changes to be committed:

 new file:   kern/conf/SYNCHPROBS
 new file:   kern/synchprobs/airballoon.c

Unmerged paths:
  (use "git add ..." to mark resolution)

 both added:      kern/conf/DUMBVM
 both added:      kern/conf/DUMBVM-OPT
 both added:      kern/conf/GENERIC
 both added:      kern/conf/GENERIC-OPT
 both added:      kern/conf/conf.kern
 both added:      kern/include/clock.h
 both added:      kern/include/test.h
 both added:      kern/main/menu.c
 both added:      kern/test/tt3.c
 both added:      kern/thread/thread.c

Changes not staged for commit:
As requested by git, run git add on the files under the Unmerged paths category. Note, your list of files might be different than the one listed in this example! So check the list printed by your git status command.
git add kern/conf/DUMBVM
git add kern/conf/DUMBVM-OPT 
git add kern/conf/GENERIC
git add kern/conf/GENERIC-OPT 
git add kern/conf/conf.kern 
git add kern/include/clock.h 
git add kern/include/test.h 
git add kern/main/menu.c 
git add kern/test/tt3.c  
git add kern/thread/thread.c 
Run git status to check if the files are staged. If they are, you should see something like this:
On branch master
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:

 modified:   kern/conf/DUMBVM
 modified:   kern/conf/DUMBVM-OPT
 modified:   kern/conf/GENERIC
 modified:   kern/conf/GENERIC-OPT
 new file:   kern/conf/SYNCHPROBS
 modified:   kern/conf/conf.kern
 modified:   kern/include/clock.h
 modified:   kern/include/test.h
 modified:   kern/main/menu.c
 new file:   kern/synchprobs/airballoon.c
 modified:   kern/test/tt3.c
 modified:   kern/thread/thread.c

Changes not staged for commit:
and finally commit/merge:
git commit -m "merged with instructor/synchprobs!"
To check the differences before and after the merging, get the hashes of the last two commits by running git log and then run git diff using the commits ids (or just the first seven characters of the commit hash):
git log
git diff -u 30fded8 377807b
Note, you have to use the commit hashes from your git log command.

Bonus: To see how branches get merged use the following git command:

git log --graph --oneline --decorate --date=relative --all
You will see something like this:
*   377807b merged with instructor/synchprobs!
|\  
| * 4598963 Fix typos and copyright
| * 98ac74c Adding the SYNCHPROBS config file
| * 6583765 Fix menu item.
| * fe7c9d8 Synchprobs branch
| | *   0c74d03 WIP on master: 30fded8 CV implentation is complete!
| | |\  
| |/ /  
|/| |   
| | * a83e9b4 index on master: 30fded8 CV implentation is complete!
| |/  
|/|   
* | 30fded8 CV implentation is complete!
* | 2db7b21 Lock implentation is complete ..Phew!
* | 1c1e29f Answers for Code reading exercises
* | 720008f Answers to asst1
* | 4257084 Answers to asst0
* | c0daf35 Initial commit of os161 for CPEN331
 /  
| * 536a63e Fixed a string buffer issue. The character array was declared with size 40 and also had 40 characters, so there's no space for the compiler to put the null character. As a result, string operations such as comparison and prin
| * 208640f Additional tests for dup2, chdir and getcwd. But fix with string buffers.
| * adf53fa Reducing the open file limit for the kernel to ensure that the fsyscalltest works as expected.
| * 7d55be6 A test for read, write, open, close and lseek system calls that can be run before fork/exec and friends are implemented.
|/  
* e3ecd58 A proper fix to invocation of the write function delcared to mandate the checking of the return value.
* e5cb32b Included stdint.h in hostcompat, so the compilation does not complain about not knowing the uint64_t type. Added -Wno-error=unused-result, because some code didn't check the return value of write function. Need to provide a cle
* e129d41 Replaced the OS version in the master with 1.99.08, because the 2.0 that was originally there does not build due to a known issue.
* 69c0330 Initial commit of pristine OS161-base-2.0 source