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

[PATCH] running svn when diff binary has moved

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2002-01-08 02:36:21 CET

i discovered earlier today that svn diff will silently produce no
useful output if the diff program you compiled svn to use is no longer
there. this patch allows us to at least produce an error message in
such a case.

i couldn't find a good way to tell that the diff util wasn't there, so
we just check for an exit code that doesn't make sense. we know gnu
diff will only return 0, 1, or 2 (at least according to its man page),
so if it returns something else, there is a problem.

* subversion/includes/svn_error_codes.h
  (SVN_ERR_CL_DIFF_FAILED): error code for when there is a problem
  running diff.
* subversion/clients/cmdline/diff.c
  (svn_cl__print_file_diff): error out if diff returns an exit code we
  don't expect. this lets us at least produce an error if the diff
  command we were compiled to use does not exist.

Index: ./subversion/include/svn_error_codes.h
===================================================================
--- ./subversion/include/.svn/text-base/svn_error_codes.h.svn-base Mon Jan 7 18:04:56 2002
+++ ./subversion/include/svn_error_codes.h Mon Jan 7 20:24:40 2002
@@ -368,6 +368,9 @@
   SVN_ERRDEF (SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE,
               "The log message file is under version control.")
 
+ SVN_ERRDEF (SVN_ERR_CL_DIFF_FAILED,
+ "Diff command returned unexpected value.")
+
   /* END Client errors */
   
 
Index: ./subversion/clients/cmdline/diff.c
===================================================================
--- ./subversion/clients/cmdline/.svn/text-base/diff.c.svn-base Mon Jan 7 18:03:37 2002
+++ ./subversion/clients/cmdline/diff.c Mon Jan 7 20:27:36 2002
@@ -109,6 +109,7 @@
   svn_boolean_t text_is_modified = FALSE;
   const char **args;
   int i = 0;
+ int exitcode = 0;
 
   apr_file_t *outhandle = NULL;
 
@@ -158,8 +159,13 @@
   apr_file_printf (outhandle, "Index: %s\n", path->data);
   apr_file_printf (outhandle, "===================================================================\n");
 
- SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, NULL, NULL,
+ SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, &exitcode, NULL,
                         NULL, outhandle, NULL, pool));
+
+ if (exitcode < 0 || exitcode > 2)
+ return svn_error_createf
+ (SVN_ERR_CL_DIFF_FAILED, 0, NULL, pool,
+ "Error calling %s", SVN_CLIENT_DIFF);
 
   /* TODO: Handle exit code == 2 (i.e. errors with diff) here */

-- 
garrett rooney                     Unix was not designed to stop you from 
rooneg@electricjellyfish.net       doing stupid things, because that would  
http://electricjellyfish.net/      stop you from doing clever things.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:55 2006

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.