4.3 Exercise 3
From git’s repo, checkout revision fe870600fe and merge 1bdca81641
.
Solve both conflicts (there are 2 conflicting files, one conflict section on each one of
the files).
Conflict in path.c
Listing 4.5:Exercise 3 - conflict in path.c852 if (is_git_directory(".")) { 853<<<<<<< HEAD 854 set_git_dir(".", 0); 855 check_repository_format(); 856||||||| 51ebf55b93 857 set_git_dir("."); 858 check_repository_format(); 859======= 860 set_git_dir("."); 861 check_repository_format(NULL); 862>>>>>>> 1bdca81641 863 return path; 864 }
I don’t think it is too difficult to realize what happened on each branch. On
HEAD the call to set_git_dir() got a second parameter on line 854. On
the other branch, the call to check_repository_format() got a new
NULL parameter on line 861. That points to having this as the conflict
resolution:
Listing 4.6:Exercise 3 - resolution to conflict in path.c852 if (is_git_directory(".")) { 853 set_git_dir(".", 0); 854 check_repository_format(NULL); 855 return path; 856 }
Conflict in builtin/pack-objects.c
Listing 4.7:Exercise 3 - conflict in builtin/pack-objects.c880 len = encode_in_pack_object_header(header, sizeof(header), 881 OBJ_REF_DELTA, size); 882 hashwrite(out, header, len); 883<<<<<<< HEAD 884 hashwrite(out, base_oid.hash, 20); 885||||||| 51ebf55b93 886 hashwrite(out, base_sha1, 20); 887======= 888 hashwrite(out, base_sha1, the_hash_algo->rawsz); 889>>>>>>> 1bdca81641 890 copy_pack_data(out, reuse_packfile, w_curs, cur, next - cur); 891 return;
In this case, on HEAD the second parameter to the hashwrite() call was
changed from base_sha1 on line 886 to base_oid.hash on line 884. On the ther
branch, the third parameter to the same call was changed from 20 on line 886 to
the_hash_algo->rawsz on line 888. This all points to this as the conflict
resolution:
Listing 4.8:Exercise 3 - conflict in builtin/pack-objects.c880 len = encode_in_pack_object_header(header, sizeof(header), 881 OBJ_REF_DELTA, size); 882 hashwrite(out, header, len); 883 hashwrite(out, base_oid.hash, the_hash_algo->rawsz); 884 copy_pack_data(out, reuse_packfile, w_curs, cur, next - cur); 885 return;
If you compare with revision f8cb64e3d4, you should get no meaningful
difference.
As an additional exercise, imagine what the task would have been if diff3 had
not been used.