You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2018/07/02 11:00:58 UTC

svn commit: r1834835 - /subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c

Author: julianfoad
Date: Mon Jul  2 11:00:58 2018
New Revision: 1834835

URL: http://svn.apache.org/viewvc?rev=1834835&view=rev
Log:
On the '1.10.x-issue4758' branch: restore config even on error.

* subversion/libsvn_client/shelve.c
  (shelf_write_patch): Don't let an error return leave the client context in
    a modified state.

Modified:
    subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c

Modified: subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c?rev=1834835&r1=1834834&r2=1834835&view=diff
==============================================================================
--- subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c (original)
+++ subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c Mon Jul  2 11:00:58 2018
@@ -158,7 +158,6 @@ shelf_write_patch(const char *name,
   svn_opt_revision_t peg_revision = {svn_opt_revision_unspecified, {0}};
   svn_opt_revision_t start_revision = {svn_opt_revision_base, {0}};
   svn_opt_revision_t end_revision = {svn_opt_revision_working, {0}};
-  apr_hash_t *old_config;
 
   SVN_ERR(get_patch_abspath(&patch_abspath, name, wc_root_abspath,
                             ctx, scratch_pool, scratch_pool));
@@ -186,20 +185,21 @@ shelf_write_patch(const char *name,
   SVN_ERR(svn_stream_printf(outstream, scratch_pool,
                             "--This patch was generated by 'svn shelve'--\n\n"));
 
-  /* Ensure we use internal diff, not any configured external diff-cmd. */
-  old_config = ctx->config;
-  ctx->config = NULL;
-
   for (i = 0; i < paths->nelts; i++)
     {
       const char *path = APR_ARRAY_IDX(paths, i, const char *);
+      apr_hash_t *old_config;
+      svn_error_t *err;
 
       if (svn_path_is_url(path))
         return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
                                  _("'%s' is not a local path"), path);
       SVN_ERR(svn_dirent_get_absolute(&path, path, scratch_pool));
 
-      SVN_ERR(svn_client_diff_peg6(
+      /* Ensure we use internal diff, not any configured external diff-cmd. */
+      old_config = ctx->config;
+      ctx->config = NULL;
+      err = svn_client_diff_peg6(
                      NULL /*options*/,
                      path,
                      &peg_revision,
@@ -219,11 +219,11 @@ shelf_write_patch(const char *name,
                      outstream,
                      errstream,
                      changelists,
-                     ctx, iterpool));
+                     ctx, iterpool);
+      ctx->config = old_config;
+      SVN_ERR(err);
     }
 
-  ctx->config = old_config;
-
   SVN_ERR(svn_stream_close(outstream));
   SVN_ERR(svn_stream_close(errstream));