svn commit: r1932394 - subversion/trunk/subversion/svn

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <[email protected]>
Author: rinrab
Date: Thu Mar 19 20:57:55 2026
New Revision: 1932394

Log:
Use svn_io_stat() instead of apr_stat() when checking if --message is a file
(in this case we should show a warning because user might have intendent to
used it as a log message, i.e. [svn ci -F svn-commit.tmp]).

1.  svn_io_stat, unlike apr_stat uses svn_error error handling which are more
    convenient to use.

2.  It works in UTF8 encoding. This change will act  as a groundwork change for
    switching the command-line to a canonical encoding entirely.

Don't forget to convert encoding to UTF8. As svn_io_stat actually does a
conversion back to cstring, they basically "cancel out".

Please refer to a small discussion on [email protected] about this change [1].

* subversion/svn/svn.c
  (sub_main): Use new function.

[1] https://lists.apache.org/thread/mlht6fwy62jr598p8kqx5q5gjwfl0ccl

Modified:
   subversion/trunk/subversion/svn/svn.c

Modified: subversion/trunk/subversion/svn/svn.c
==============================================================================
--- subversion/trunk/subversion/svn/svn.c	Thu Mar 19 16:42:14 2026	(r1932393)
+++ subversion/trunk/subversion/svn/svn.c	Thu Mar 19 20:57:55 2026	(r1932394)
@@ -3179,23 +3179,37 @@ sub_main(int *exit_code,
       if (opt_state.message)
         {
           apr_finfo_t finfo;
-          if (apr_stat(&finfo, opt_state.message /* not converted to UTF-8 */,
-                       APR_FINFO_MIN, pool) == APR_SUCCESS)
+          const char *utf8_message;
+
+          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_message, opt_state.message,
+                                          pool));
+
+          /* We don't want to warn for '' */
+          if (opt_state.message[0] != '\0')
             {
-              if (subcommand->cmd_func != svn_cl__lock)
+              err = svn_io_stat(&finfo, opt_state.message,
+                                APR_FINFO_MIN, pool);
+
+              if (!err)
                 {
-                  return svn_error_create
-                    (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
-                     _("The log message is a pathname "
-                       "(was -F intended?); use '--force-log' to override"));
-                }
-              else
-                {
-                  return svn_error_create
-                    (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
-                     _("The lock comment is a pathname "
-                       "(was -F intended?); use '--force-log' to override"));
+                  if (subcommand->cmd_func != svn_cl__lock)
+                    {
+                      return svn_error_create(
+                          SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
+                          _("The log message is a pathname "
+                            "(was -F intended?); use '--force-log' to "
+                            "override"));
+                    }
+                  else
+                    {
+                      return svn_error_create(
+                          SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
+                          _("The lock comment is a pathname "
+                            "(was -F intended?); use '--force-log' to "
+                            "override"));
+                    }
                 }
+              svn_error_clear(err);
             }
         }
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.