Update check-copyright-headers.rb so it can handle the first push to an
[arvados-dev.git] / git / hooks / check-copyright-headers.rb
index 2f6b20d2a063ba46ac8f21c35987abbfbe204482..7d726f96d8f587fa67dd56a544b70d1f0698e28d 100755 (executable)
@@ -58,9 +58,12 @@ def check_copyright_headers
       all_objects = blob_objects + commit_objects
       commits = `git rev-list main..#{$newrev}`.split("\n")
     else
-      # When does this happen?
-      puts "UNEXPECTED ERROR"
-      exit 1
+      # First push to an empty repository
+      puts "git rev-list --objects #{$newrev} | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'"
+      blob_objects  = `git rev-list --objects #{$newrev} | git cat-file --follow-symlinks --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'`.split("\n")
+      commit_objects  = `git rev-list --objects #{$newrev} | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^commit //p'`.split("\n")
+      all_objects = blob_objects + commit_objects
+      commits = `git rev-list #{$newrev}`.split("\n")
     end
   else
     blob_objects = `git rev-list --objects #{$oldrev}..#{$newrev} --not --branches='*' | git cat-file --follow-symlinks --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'`.split("\n")