Simultaneously, both Harry and Sally realize that their code has no comments.
Harry:
lottery harry$ git diff diff --git a/src/pb.c b/src/pb.c index 961c1f2..f7d0b61 100644 --- a/src/pb.c +++ b/src/pb.c @@ -47,6 +47,7 @@ return -1; } + // lottery ball numbers are always shown sorted qsort(white_balls, 5, sizeof(int), my_sort_func); return 0; lottery harry$ git commit -a -m comments [master 571e482] comments 1 files changed, 1 insertions(+), 0 deletions(-) lottery harry$ git push Counting objects: 7, done. Compressing objects: 100% (3/3), done. Writing objects: 100% (4/4), 388 bytes, done. Total 4 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (4/4), done. To http://server.futilisoft.com:8000/lottery df43333..571e482 master -> master
And Sally:
lottery sally$ git diff diff --git a/src/pb.c b/src/pb.c index ad680c7..7881352 100644 --- a/src/pb.c +++ b/src/pb.c @@ -35,7 +35,7 @@ { int balls[6]; int count_balls = 0; - int favorite = 0; + int favorite = 0; // this should be a bool for (int i=1; i<argc; i++) { @@ -69,10 +69,13 @@ goto usage_error; } + // the power ball is always the last one given int power_ball = balls[5]; int result = calculate_result(balls, power_ball); + // calculate result can return -1 if the ball numbers + // are out of range if (result < 0) { goto usage_error; lottery sally$ git commit -a -m comments [no_boys_allowed 7570e84] comments 1 files changed, 4 insertions(+), 1 deletions(-) lottery sally$ git push Counting objects: 7, done. Compressing objects: 100% (3/3), done. Writing objects: 100% (4/4), 474 bytes, done. Total 4 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (4/4), done. To http://server.futilisoft.com:8000/lottery 02f9797..7570e84 no_boys_allowed -> no_boys_allowed ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'http://server.futilisoft.com:8000/lottery' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
Sally notices that the push of her private branch succeeded. Git seems to be griping about something else, related to the master branch. She thinks it best that she just ignore it.
That error message is Git’s way of saying the master branch in Sally’s repository instance is out of date. |
Harry decides to try again to merge the changes from Sally’s branch.
lottery harry$ git pull 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 02f9797..7570e84 no_boys_allowed -> origin/no_boys_allowed Already up-to-date. lottery harry$ git merge origin/no_boys_allowed Auto-merging src/pb.c Merge made by recursive. src/pb.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
No worries on the merge then. Harry checks to see if everything compiles.
lottery harry$ make gcc -std=c99 -Wall -Wextra -Werror pb.c -o pb lottery harry$ git push Counting objects: 10, done. Compressing objects: 100% (3/3), done. Unpacking objects: 100% (4/4), done. Writing objects: 100% (4/4), 541 bytes, done. Total 4 (delta 1), reused 0 (delta 0) To http://server.futilisoft.com:8000/lottery 571e482..31b9ef7 master -> master