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

Re: request for new patch in issue #1700

From: Marcos Chaves <mchvs_at_hotmail.com>
Date: 2004-08-18 23:50:15 CEST

Karl,

this is the updated patch as of r10683. The gzip version is attached
too because my mailer doesn't like patch files. I'll attach the patch
to issue #1700 too.

Please tell me if you have comments on this patch.

I hope it helps,

Marcos

- - - - - 8< - - - - -

Fix issue #1700 - hook script ignored when symlink is broken.

  * subversion/libsvn_repos/hooks.c
    (check_hook_cmd): New parameter indicates if the found hook script
    is a broken symbolic link.

    (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): Fail commit if the hook
    script is a broken symbolic link.

Index: subversion/libsvn_repos/hooks.c
===================================================================
--- subversion/libsvn_repos/hooks.c (revision 10683)
+++ subversion/libsvn_repos/hooks.c (working copy)
@@ -145,11 +145,12 @@
}

-/* Check if the HOOK program exists and is a file, using POOL for
- temporary allocations. Returns the hook program if found,
- otherwise NULL. */
+/* Check if the HOOK program exists and is a file or a symbolic link, using
+ POOL for temporary allocations. Returns the hook program if found,
+ otherwise NULL. BROKEN_LINK tells if the hook program is a broken
symbolic
+ link. */
static const char*
-check_hook_cmd (const char *hook, apr_pool_t *pool)
+check_hook_cmd (const char *hook, svn_boolean_t *broken_link, apr_pool_t
*pool)
{
   static const char* const check_extns[] = {
#ifdef WIN32
@@ -163,6 +164,7 @@

   const char *const *extn;
   svn_error_t *err = NULL;
+ svn_boolean_t is_special;
   for (extn = check_extns; *extn; ++extn)
     {
       const char *const hook_path =
@@ -171,11 +173,19 @@
       svn_node_kind_t kind;
       if (!(err = svn_io_check_resolved_path (hook_path, &kind, pool))
           && kind == svn_node_file)
- return hook_path;
-
+ {
+ *broken_link = FALSE;
+ return hook_path;
+ }
+ svn_error_clear(err);
+ if (!(err = svn_io_check_special_path (hook_path, &kind, &is_special,
pool))
+ && is_special == TRUE)
+ {
+ *broken_link = TRUE;
+ return hook_path;
+ }
+ svn_error_clear(err);
     }
-
- svn_error_clear(err);
   return NULL;
}

@@ -186,9 +196,16 @@
                                apr_pool_t *pool)
{
   const char *hook = svn_repos_start_commit_hook (repos, pool);
+ svn_boolean_t broken_link;

- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
     {
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
       const char *args[4];

       args[0] = hook;
@@ -209,9 +226,16 @@
                              apr_pool_t *pool)
{
   const char *hook = svn_repos_pre_commit_hook (repos, pool);
+ svn_boolean_t broken_link;

- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
     {
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
       const char *args[4];

       args[0] = hook;
@@ -232,9 +256,16 @@
                               apr_pool_t *pool)
{
   const char *hook = svn_repos_post_commit_hook (repos, pool);
+ svn_boolean_t broken_link;

- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
     {
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
       const char *args[4];

       args[0] = hook;
@@ -258,9 +289,16 @@
                                      apr_pool_t *pool)
{
   const char *hook = svn_repos_pre_revprop_change_hook (repos, pool);
+ svn_boolean_t broken_link;

- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
     {
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
       const char *args[6];
       apr_file_t *stdin_handle = NULL;

@@ -307,9 +345,16 @@
                                       apr_pool_t *pool)
{
   const char *hook = svn_repos_post_revprop_change_hook (repos, pool);
+ svn_boolean_t broken_link;

- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
     {
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
       const char *args[6];
       apr_file_t *stdin_handle = NULL;

_________________________________________________________________
MSN Messenger: converse com os seus amigos online.
http://messenger.msn.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Wed Aug 18 23:50:26 2004

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