Merge (conflicts)

Sally realizes that C99 has a bool type that should have been used.

lottery sally$ git diff
diff --git a/src/pb.c b/src/pb.c
index 7881352..3351455 100644
--- a/src/pb.c
+++ b/src/pb.c
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdbool.h>
 
 #define LUCKY_NUMBER 7
 #define MAX_WHITE_BALL 59
@@ -35,7 +36,7 @@
 {
     int balls[6];
     int count_balls = 0;
-    int favorite = 0;  // this should be a bool
+    bool favorite = false;
 
     for (int i=1; i<argc; i++)
     {
@@ -45,7 +46,7 @@
         {
             if (0 == strcmp(arg, "-favorite"))
             {
-                favorite = 1;
+                favorite = true;
             }
             else
             {

And she commits the change to her private branch.

lottery sally$ git commit -a -m "use the bool type"
[no_boys_allowed a1d4dcf] use the bool type
 1 files changed, 4 insertions(+), 2 deletions(-)

lottery sally$ git push origin HEAD
Counting objects: 7, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 406 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
To http://server.futilisoft.com:8000/lottery
   7570e84..a1d4dcf  HEAD -> no_boys_allowed

Meanwhile, Harry has been grumbling about Sally’s butchering of the Queen’s English and decides to correct the spelling of the word “favourite”.

lottery harry$ git diff
diff --git a/src/pb.c b/src/pb.c
index 0cecd1c..4d28bbb 100644
--- a/src/pb.c
+++ b/src/pb.c
@@ -57,7 +57,7 @@
 {
     int balls[6];
     int count_balls = 0;
-    int favorite = 0;  // this should be a bool
+    int favourite = 0;  // this should be a bool
 
     for (int i=1; i<argc; i++)
     {
@@ -65,9 +65,9 @@
 
         if ('-' == arg[0])
         {
-            if (0 == strcmp(arg, "-favorite"))
+            if (0 == strcmp(arg, "-favourite"))
             {
-                favorite = 1;
+                favourite = 1;
             }
             else
             {
@@ -108,7 +108,7 @@
         result = result * 2;
     }
 
-    if (favorite)
+    if (favourite)
     {
         result = result * 2;
     }
@@ -118,7 +118,7 @@
     return 0;
 
 usage_error:
-    fprintf(stderr, "Usage: %s [-favorite] (5 white balls) power_ball\n", argv[0]);
+    fprintf(stderr, "Usage: %s [-favourite] (5 white balls) power_ball\n", argv[0]);
     return -1;
 }

Feeling quite chuffed about his pedantry, Harry proceeds to commit the change.

lottery harry$ git commit -a -m "fixed spelling error"
[master f822657] fixed spelling error
 1 files changed, 5 insertions(+), 5 deletions(-)

And to once again merge Sally’s changes into the default branch.

lottery harry$ git fetch
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From http://server.futilisoft.com:8000/lottery
   7570e84..a1d4dcf  no_boys_allowed -> origin/no_boys_allowed

lottery harry$ git merge origin/no_boys_allowed
Auto-merging src/pb.c
CONFLICT (content): Merge conflict in src/pb.c
Automatic merge failed; fix conflicts and then commit the result.

Crikey! Conflicts in pb.c again.

lottery harry$ git diff
diff --cc src/pb.c
index 4d28bbb,3351455..0000000
--- a/src/pb.c
+++ b/src/pb.c
@@@ -1,6 -1,7 +1,10 @@@
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
++<<<<<<< HEAD
++=======
+ #include <stdbool.h>
++>>>>>>> origin/no_boys_allowed
  
  #define LUCKY_NUMBER 7
  #define MAX_WHITE_BALL 59
@@@ -55,7 -35,7 +59,11 @@@ int main(int argc, char** argv
  {
    int balls[6];
    int count_balls = 0;
++<<<<<<< HEAD
 +  int favourite = 0; // this should be a bool
++=======
+   bool favorite = false;
++>>>>>>> origin/no_boys_allowed
  
    for (int i=1; i<argc; i++)
    {
@@@ -63,9 -43,9 +71,13 @@@
  
        if ('-' == arg[0])
        {
 -          if (0 == strcmp(arg, "-favorite"))
 +          if (0 == strcmp(arg, "-favourite"))
            {
++<<<<<<< HEAD
 +              favourite = 1;
++=======
+               favorite = true;
++>>>>>>> origin/no_boys_allowed
            }
            else
            {

That is a sticky wicket. Harry quickly realises this conflict needs to be resolved manually by keeping the proper spelling but converting the type to bool like Sally did.

lottery harry$ git diff
diff --cc src/pb.c
index 4d28bbb,3351455..0000000
--- a/src/pb.c
+++ b/src/pb.c
@@@ -55,7 -35,7 +56,7 @@@ int main(int argc, char** argv
  {
    int balls[6];
    int count_balls = 0;
-   int favourite = 0; // this should be a bool
 -  bool favorite = false;
++  bool favourite = false;
  
    for (int i=1; i<argc; i++)
    {
@@@ -63,9 -43,9 +64,9 @@@
  
        if ('-' == arg[0])
        {
 -          if (0 == strcmp(arg, "-favorite"))
 +          if (0 == strcmp(arg, "-favourite"))
            {
-               favourite = 1;
 -              favorite = true;
++              favourite = true;
            }
            else
            {

After manually merging the changes, Harry proceeds to resolve the conflict and commit the merge.

lottery harry$ git commit -a -m "merge, conflicts fixed"
[master b5480ab] merge, conflicts fixed

lottery harry$ git push
...

And all of Futilisoft’s customers lived happily ever after.