Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c	(revision 16154)
+++ subversion/libsvn_repos/repos.c	(working copy)
@@ -1680,6 +1680,63 @@
 }
 
 
+/* If the default hook location is a file, set the hook
+   directory to the directory on the first line of that
+   file.
+   Use POOL for temporary allocation. */
+static svn_error_t *
+check_hook_location (svn_repos_t *repos,
+                     apr_pool_t *pool)
+{
+  apr_finfo_t finfo;
+  char* new_hook_path;
+
+  SVN_ERR (svn_io_stat (&finfo, repos->hook_path, 
+                        APR_FINFO_TYPE, pool));
+
+  if (finfo.filetype == APR_REG)
+    {
+      apr_file_t *hook_file;
+      char buf[255];
+      apr_size_t len;
+
+      SVN_ERR (svn_io_file_open (&hook_file, repos->hook_path, 
+                                 APR_READ, APR_OS_DEFAULT, pool));
+      len = sizeof(buf);
+      SVN_ERR (svn_io_file_read (hook_file, buf, &len, pool));
+
+      /* If there was no data in PATH, return an error. */
+      if (len == 0)
+        return svn_error_createf (SVN_ERR_STREAM_UNEXPECTED_EOF, NULL,
+                                  _("Reading '%s'"),
+                                  svn_path_local_style (repos->hook_path,
+                                                        pool));
+
+      /* find the length of the first line and copy the string */
+      {
+        apr_size_t i;
+
+        for (i = 0; i < len; ++i)
+        {
+          char c = buf[i];
+
+          if (i > 0 && (c == '\r' || c == '\n' ))
+            break;
+        }
+
+        new_hook_path = apr_pstrndup (pool, buf, i);
+      }
+
+      /* And finally, close the file. */
+      SVN_ERR (svn_io_file_close (hook_file, pool));
+    }
+
+  repos->hook_path = new_hook_path;
+
+  return SVN_NO_ERROR;
+}
+
+
 /* Set *REPOS_P to a repository at PATH which has been opened with
    some kind of lock.  LOCKTYPE is one of APR_FLOCK_SHARED (for
    standard readers/writers), or APR_FLOCK_EXCLUSIVE (for processes
@@ -1707,6 +1764,9 @@
   /* Verify the validity of our repository format. */
   SVN_ERR (check_repos_format (repos, pool));
 
+  /* Verify the location of the hook script directory. */
+  SVN_ERR (check_hook_location (repos, pool));
+
   /* Locking. */
   {
     const char *lockfile_path;


