[from now] 2012/09/04 11:45:59

diff --git a/Rakefile b/Rakefile
index 9fa2e12..68f9462 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,10 +1,28 @@
 require 'tmpdir'
+require 'securerandom'

 def run(command, options={})
   puts command if options[:verbose]
   system command
 end

+def write
+  open('README', 'a'){ |f| f.puts SecureRandom.uuid }
+end
+
+def commit
+  run 'git add .'
+  run 'git commit -m "." -q'
+end
+
+def push
+  run 'git push origin master -q'
+end
+
+def branch(branch_name)
+  run "git branch #{branch_name}"
+end
+
 desc 'git hooks test detect force update'
 task :default do
   pwd = Dir.getwd
@@ -15,24 +33,22 @@ task :default do
       run 'git clone test.git test_1 -q'
       Dir.chdir('test_1') do
         run 'git commit --allow-empty -m "Initial commit" -q'
-        run 'git push origin master -q'
+        push
       end

       Dir.chdir('test_1') do
-        run 'date >> README'
-        run 'git add .'
-        run 'git commit -m "." -q'
-        run 'git push origin master -q'
+        write; commit; push;
+        write; commit; push;
+        write; commit; push;
       end

       run 'git clone test.git test_2 -q'

       Dir.chdir('test_1') do
         2.times do
-          run 'date >> README'
-          run 'git add .'
-          run 'git commit -m "." -q'
-          run 'git push origin master -q'
+          write; commit; push;
+          write; commit; push;
+          write; commit; push;
         end

         puts '--> IN test_1'
@@ -40,9 +56,14 @@ task :default do
       end

       Dir.chdir('test_2') do
-        run 'uptime >> README'
-        run 'git add .'
-        run 'git commit -m "."'
+        branch('foo'); branch('bar'); branch('baz');
+      end
+
+      Dir.chdir('test_2') do
+        write; commit; push;
+        write; commit; push;
+        write; commit; push;
+
         puts '--> IN test_2'
         run 'git log --oneline'
       end
@@ -57,7 +78,7 @@ task :default do

       puts '-' * 80
       Dir.chdir('test_2') do
-        run 'git push -f origin master', verbose: true
+        run 'git push -f --all', verbose: true
       end
     end
   end
diff --git a/pre-receive b/pre-receive
index 3f09433..7223eda 100755
--- a/pre-receive
+++ b/pre-receive
@@ -1,12 +1,21 @@
 #!/usr/bin/env ruby

-oldrev, newrev, refname = STDIN.read.strip.split(/ /)
-puts "oldrev=#{oldrev}"
-puts "newrev=#{newrev}"
-puts "refname=#{refname}"
+def show(oldrev, newrev, refname)
+  puts "oldrev=#{oldrev}"
+  puts "newrev=#{newrev}"
+  puts "refname=#{refname}"
+
+  puts '-' * 80
+  puts `git rev-list #{oldrev}`
+
+  puts '-' * 80
+  puts `git rev-list #{newrev}`
+end
+
+while line = STDIN.gets
+  oldrev, newrev, refname = line.strip.split(/ /)
+  show(oldrev, newrev, refname)
+end
+

-puts '-' * 80
-puts `git rev-list #{oldrev}`

-puts '-' * 80
-puts `git rev-list #{newrev}`
[from now] 2012/09/04 11:46:54

diff --git a/pre-receive b/pre-receive
index 7223eda..02d1009 100755
--- a/pre-receive
+++ b/pre-receive
@@ -9,7 +9,7 @@ def show(oldrev, newrev, refname)
   puts `git rev-list #{oldrev}`

   puts '-' * 80
-  puts `git rev-list #{newrev}`
+  puts `git rev-list origin/master | grep $(git rev-parse origin/mastrer@{1})`
 end

 while line = STDIN.gets
[from now] 2012/09/04 14:38:27

diff --git a/Rakefile b/Rakefile
index 68f9462..9d3f23e 100644
--- a/Rakefile
+++ b/Rakefile
@@ -39,7 +39,6 @@ task :default do
       Dir.chdir('test_1') do
         write; commit; push;
         write; commit; push;
-        write; commit; push;
       end

       run 'git clone test.git test_2 -q'
@@ -48,7 +47,6 @@ task :default do
         2.times do
           write; commit; push;
           write; commit; push;
-          write; commit; push;
         end

         puts '--> IN test_1'
@@ -62,7 +60,6 @@ task :default do
       Dir.chdir('test_2') do
         write; commit; push;
         write; commit; push;
-        write; commit; push;

         puts '--> IN test_2'
         run 'git log --oneline'
@@ -78,7 +75,7 @@ task :default do

       puts '-' * 80
       Dir.chdir('test_2') do
-        run 'git push -f --all', verbose: true
+        run 'git push -f origin master', verbose: true
       end
     end
   end
diff --git a/pre-receive b/pre-receive
index 02d1009..8ba5eb0 100755
--- a/pre-receive
+++ b/pre-receive
@@ -1,15 +1,43 @@
 #!/usr/bin/env ruby

+def line(m)
+  puts '-' * 5 + " #{m} " + '-' * 60
+end
+
 def show(oldrev, newrev, refname)
-  puts "oldrev=#{oldrev}"
-  puts "newrev=#{newrev}"
-  puts "refname=#{refname}"
+  command = "git merge-base #{oldrev} #{newrev}"
+  puts command
+  system command
+
+  line('oldrev')
+  command = "git rev-list #{oldrev}"
+  line command
+  system command
+
+  line('newrev')
+  command = "git rev-list #{newrev}"
+  line command
+  system command
+
+  line('oldrev ^newrev')
+  command = "git rev-list #{oldrev} ^#{newrev}"
+  line command
+  system command
+
+  line('^oldrev newrev')
+  command = "git rev-list ^#{oldrev} #{newrev}"
+  line command
+  system command
+
+  # puts "oldrev=#{oldrev}"
+  # puts "newrev=#{newrev}"
+  # puts "refname=#{refname}"

-  puts '-' * 80
-  puts `git rev-list #{oldrev}`
+  # puts '-' * 80
+  # # puts `git rev-list #{oldrev}`

-  puts '-' * 80
-  puts `git rev-list origin/master | grep $(git rev-parse origin/mastrer@{1})`
+  # puts '-' * 80
+  # # puts `git rev-list master | grep $(git rev-parse master@{1})`
 end

 while line = STDIN.gets