Merge (no conflicts)

Meanwhile, over in the trunk, Harry decides the white balls should be sorted before analysing them, because that’s how they get shown on the telly.

trunk harry$ svn diff
Index: pb.c
===================================================================
--- pb.c    (revision 12)
+++ pb.c    (working copy)
@@ -6,6 +6,25 @@
 #define MAX_WHITE_BALL 59
 #define MAX_POWER_BALL 39
 
+static int my_sort_func(const void* p1, const void* p2)
+{
+    int v1 = *((int *) p1);
+    int v2 = *((int *) p2);
+
+    if (v1 < v2)
+    {
+        return -1;
+    }
+    else if (v1 > v2)
+    {
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
 int calculate_result(int white_balls[5], int power_ball)
 {
     for (int i=0; i<5; i++)
@@ -27,6 +46,8 @@
         return -1;
     }
 
+    qsort(white_balls, 5, sizeof(int), my_sort_func);
+
     return 0;
 }

And he commits the change.

trunk harry$ svn commit -m "sort the white balls"
Sending        trunk/pb.c
Transmitting file data .
Committed revision 16.

But now he’s curious about what Sally has been doing. She said he wasn’t allowed to commit to her branch but she didn’t say anything about looking at it.

trunk harry$ cd ../branches/   

branches harry$ svn update
A    no_boys_allowed
A    no_boys_allowed/pb.c
A    no_boys_allowed/Makefile
Updated to revision 16.

branches harry$ svn log
------------------------------------------------------------------------
r15 | sally | 2011-04-08 09:04:38 -0500 (Fri, 08 Apr 2011) | 1 line

add -favorite and cleanup some other stuff
------------------------------------------------------------------------
...

Interesting. She added the “favorite” feature. Harry decides he wants that. So he asks Subversion to merge stuff from Sally’s branch into trunk.

branches harry$ cd ..

lottery harry$ cd trunk

trunk harry$ svn merge ../branches/no_boys_allowed 
--- Merging r14 through r16 into '.':
U    pb.c

Smashing! Harry examines pb.c and discovers that it was merged correctly. Sally’s “favorite” changes are there and his qsort changes are as well. So he compiles the code, runs a quick test, and commits the merge.

trunk harry$ make
gcc -std=c99 -Wall -Wextra -Werror pb.c -o pb

trunk harry$ ./pb -favorite 5 3 33 22 7 31
0 percent chance of winning

trunk harry$ svn commit -m "merge changes from sally"
Sending        trunk
Sending        trunk/pb.c
Transmitting file data .
Committed revision 17.