pre-upload: fix COMMIT-QUEUE.ini check

The current check never works because _get_file_content always returns
an empty string.  This is because we pass it full filesystem paths, but
_get_file_content only works with relative paths.

Fix the file filtering call to get relative paths, and add a sanity
check to the _get_file_content helper to prevent any future hooks from
going unnoticed.

BUG=chromium:655381
TEST=`repo upload` rejects an invalid COMMIT-QUEUE.ini CL now

Change-Id: If80aa5ed18e932255262ad5aba5ccb8bc0cefd8d
Reviewed-on: https://chromium-review.googlesource.com/847941
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index 5be3748..7db459e 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -236,6 +236,11 @@
   if commit == PRE_SUBMIT:
     return _run_command(['git', 'diff', 'HEAD', path])
   else:
+    # Make sure people don't accidentally pass in full paths which will never
+    # work.  You need to use relative=True with _get_affected_files.
+    if path.startswith('/'):
+      raise ValueError('_get_file_content must be called with relative paths: '
+                       + path)
     return _run_command(['git', 'show', '%s:%s' % (commit, path)])
 
 
@@ -1291,7 +1296,7 @@
 def _check_cq_ini_well_formed(_project, commit):
   """Check that any modified COMMIT-QUEUE.ini files are well formed."""
   pattern = '.*' + constants.CQ_CONFIG_FILENAME
-  files = _filter_files(_get_affected_files(commit), (pattern,))
+  files = _filter_files(_get_affected_files(commit, relative=True), (pattern,))
 
   # TODO(akeshet): Check not only that the file is parseable, but that all the
   # pre-cq configs it requests are existing ones.