[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] make symlinked hook scripts work again

From: Josef Wolf <jw_at_raven.inka.de>
Date: 2003-01-15 00:14:10 CET

Hello!

Here comes the analternate approach for the symlinked hook scripts.
This patch is relative to r4388 and passed "make check" on my machine.

Log entry:

* subversion/include/svn_io.h

  (svn_io_check_resolved_path): New function.

* subversion/libsvn_subr/io.c

  (svn__io_check_path): Rename from svn_io_check_path() and add new
    paramter 'resolve_symlinks' to handle both, svn_io_check_path()
    and svn_io_check_resolved_path().

  (svn_io_check_path): New function. Just a wrapper for the renamed
    svn__io_check_path() to maintain old semantics of svn_io_check_path().

  (svn_io_check_resolved_path): New function. Does the same as
    svn_io_check_path() but resolve symlinks before doing so.

* subversion/libsvn_repos/hooks.c
  (svn_repos__hooks_start_commit, svn_repos__hooks_pre_commit,
   svn_repos__hooks_post_commit, svn_repos__hooks_pre_revprop_change,
   svn_repos__hooks_post_revprop_change): Changed callers to use
    svn_io_check_resolved_path() instead of svn_io_check_path().

Index: subversion/include/svn_io.h
===================================================================
--- subversion/include/svn_io.h (revision 4388)
+++ subversion/include/svn_io.h (working copy)
@@ -68,6 +68,27 @@
                                 svn_node_kind_t *kind,
                                 apr_pool_t *pool);
 
+/** Determine the @a kind of @a path.
+ *
+ * If utf8-encoded @a path exists, set @a *kind to the appropriate kind,
+ * else set it to @c svn_node_unknown.
+ *
+ * If @a path is a file, @a *kind is set to @c svn_node_file.
+ *
+ * If @a path is a directory, @a *kind is set to @c svn_node_dir.
+ *
+ * If @a path does not exist in its final component, @a *kind is set to
+ * @c svn_node_none.
+ *
+ * If intermediate directories on the way to @a path don't exist, an
+ * error is returned, and @a *kind's value is undefined. Contrary to
+ * svn_io_check_path(), svn_io_check_resolved_path() will resolve symlinks
+ * on @a path
+ */
+svn_error_t *svn_io_check_resolved_path (const char *path,
+ svn_node_kind_t *kind,
+ apr_pool_t *pool);
+
 
 /** Open a uniquely named file in a given directory.
  *
Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c (revision 4388)
+++ subversion/libsvn_subr/io.c (working copy)
@@ -105,11 +105,16 @@
 
 
 
-svn_error_t *
-svn_io_check_path (const char *path,
- svn_node_kind_t *kind,
- apr_pool_t *pool)
+/* internal function to do the real work for svn_io_check_path()
+ and svn_io_check_resolved_path
+*/
+static svn_error_t *
+svn__io_check_path (const char *path,
+ svn_boolean_t resolve_symlinks,
+ svn_node_kind_t *kind,
+ apr_pool_t *pool)
 {
+ apr_int32_t flags;
   apr_finfo_t finfo;
   apr_status_t apr_err;
   const char *path_native;
@@ -119,9 +124,11 @@
 
   /* Not using svn_io_stat() here because we want to check the
      apr_err return anyway. */
+
   SVN_ERR (path_from_utf8 (&path_native, path, pool));
- apr_err = apr_stat (&finfo, path_native,
- (APR_FINFO_MIN | APR_FINFO_LINK), pool);
+
+ flags = resolve_symlinks ? APR_FINFO_MIN : (APR_FINFO_MIN | APR_FINFO_LINK);
+ apr_err = apr_stat (&finfo, path_native, flags, pool);
 
   if (apr_err && !APR_STATUS_IS_ENOENT(apr_err))
     return svn_error_createf
@@ -147,6 +154,23 @@
 
 
 svn_error_t *
+svn_io_check_resolved_path (const char *path,
+ svn_node_kind_t *kind,
+ apr_pool_t *pool)
+{
+ return svn__io_check_path (path, TRUE, kind, pool);
+}
+
+svn_error_t *
+svn_io_check_path (const char *path,
+ svn_node_kind_t *kind,
+ apr_pool_t *pool)
+{
+ return svn__io_check_path (path, FALSE, kind, pool);
+}
+
+
+svn_error_t *
 svn_io_open_unique_file (apr_file_t **f,
                          const char **unique_name_p,
                          const char *path,
Index: subversion/libsvn_repos/hooks.c
===================================================================
--- subversion/libsvn_repos/hooks.c (revision 4388)
+++ subversion/libsvn_repos/hooks.c (working copy)
@@ -117,7 +117,7 @@
   svn_node_kind_t kind;
   const char *hook = svn_repos_start_commit_hook (repos, pool);
 
- if ((! svn_io_check_path (hook, &kind, pool))
+ if ((! svn_io_check_resolved_path (hook, &kind, pool))
       && (kind == svn_node_file))
     {
       const char *args[4];
@@ -144,7 +144,7 @@
   svn_node_kind_t kind;
   const char *hook = svn_repos_pre_commit_hook (repos, pool);
 
- if ((! svn_io_check_path (hook, &kind, pool))
+ if ((! svn_io_check_resolved_path (hook, &kind, pool))
       && (kind == svn_node_file))
     {
       const char *args[4];
@@ -171,7 +171,7 @@
   svn_node_kind_t kind;
   const char *hook = svn_repos_post_commit_hook (repos, pool);
 
- if ((! svn_io_check_path (hook, &kind, pool))
+ if ((! svn_io_check_resolved_path (hook, &kind, pool))
       && (kind == svn_node_file))
     {
       const char *args[4];
@@ -202,7 +202,7 @@
   svn_node_kind_t kind;
   const char *hook = svn_repos_pre_revprop_change_hook (repos, pool);
 
- if ((! svn_io_check_path (hook, &kind, pool))
+ if ((! svn_io_check_resolved_path (hook, &kind, pool))
       && (kind == svn_node_file))
     {
       const char *args[6];
@@ -248,7 +248,7 @@
   svn_node_kind_t kind;
   const char *hook = svn_repos_post_revprop_change_hook (repos, pool);
   
- if ((! svn_io_check_path (hook, &kind, pool))
+ if ((! svn_io_check_resolved_path (hook, &kind, pool))
       && (kind == svn_node_file))
     {
       const char *args[6];

-- 
-- Josef Wolf -- jw@raven.inka.de --
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Jan 15 00:16:22 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.