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

[PATCH] run hook-scripts on WIN32

From: Chris Foote <Chris.Foote_at_xtra.co.nz>
Date: 2003-01-11 03:55:36 CET

This patch, from rev 4328, gets the hooks working on WIN32 by checking for a
script
with an .exe, .cmd or .bat extentsion.

Log:
Run hook programs on WIN32.

* hooks.c:
  (check_hook_cmd): New function to check for the hook program.
  (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) : use check_hook_cmd.

Index: subversion/libsvn_repos/hooks.c
===================================================================
--- subversion/libsvn_repos/hooks.c (revision 4328)
+++ subversion/libsvn_repos/hooks.c (working copy)
@@ -27,6 +27,7 @@
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_fs.h"
+#include "svn_private_config.h" /* for SVN_WIN32 */
 #include "svn_repos.h"
 #include "repos.h"

@@ -107,6 +108,40 @@
 }

+/* Check if the HOOK program exists and is a file, using POOL for
+ temporary allocations. Returns the hook program if found,
+ otherwise NULL. */
+static const char*
+check_hook_cmd (const char *hook, apr_pool_t *pool)
+{
+ svn_node_kind_t kind;
+ const char* hook_path = hook;
+
+#ifdef SVN_WIN32
+ /* For WIN32 we need to check with an added extentsion(s). */
+ static const char* const check_extns[] = {
+ ".exe", ".cmd", ".bat", /* ### Any other extentsions? */
+ NULL
+ };
+ const char* const * extn = check_extns;
+
+ while (*extn)
+ {
+ hook_path = apr_pstrcat (pool, hook, *(extn++), 0);
+#else
+ {
+#endif
+ if ((! svn_io_check_path(hook_path, &kind, pool))
+ && (kind == svn_node_file))
+ {
+ return hook_path;
+ }
+ }
+
+ return NULL;
+}
+
+
 /* Run the start-commit hook for REPOS. Use POOL for any temporary
    allocations. If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE. */
 svn_error_t *
@@ -114,11 +149,9 @@
                                const char *user,
                                apr_pool_t *pool)
 {
- svn_node_kind_t kind;
   const char *hook = svn_repos_start_commit_hook (repos, pool);

- if ((! svn_io_check_path (hook, &kind, pool))
- && (kind == svn_node_file))
+ if (hook = check_hook_cmd (hook, pool))
     {
       const char *args[4];

@@ -141,11 +174,9 @@
                              const char *txn_name,
                              apr_pool_t *pool)
 {
- svn_node_kind_t kind;
   const char *hook = svn_repos_pre_commit_hook (repos, pool);

- if ((! svn_io_check_path (hook, &kind, pool))
- && (kind == svn_node_file))
+ if (hook = check_hook_cmd (hook, pool))
     {
       const char *args[4];

@@ -168,11 +199,9 @@
                               svn_revnum_t rev,
                               apr_pool_t *pool)
 {
- svn_node_kind_t kind;
   const char *hook = svn_repos_post_commit_hook (repos, pool);

- if ((! svn_io_check_path (hook, &kind, pool))
- && (kind == svn_node_file))
+ if (hook = check_hook_cmd (hook, pool))
     {
       const char *args[4];

@@ -199,11 +228,9 @@
                                      const svn_string_t *value,
                                      apr_pool_t *pool)
 {
- svn_node_kind_t kind;
   const char *hook = svn_repos_pre_revprop_change_hook (repos, pool);

- if ((! svn_io_check_path (hook, &kind, pool))
- && (kind == svn_node_file))
+ if (hook = check_hook_cmd (hook, pool))
     {
       const char *args[6];

@@ -245,11 +272,9 @@
                                       const char *name,
                                       apr_pool_t *pool)
 {
- svn_node_kind_t kind;
   const char *hook = svn_repos_post_revprop_change_hook (repos, pool);

- if ((! svn_io_check_path (hook, &kind, pool))
- && (kind == svn_node_file))
+ if (hook = check_hook_cmd (hook, pool))
     {
       const char *args[6];

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 11 03:57:39 2003

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