Author: hartmannathan
Date: Fri May 24 15:59:50 2024
New Revision: 1917944

URL: http://svn.apache.org/viewvc?rev=1917944&view=rev
Log:
Fix cmdline parsing bug: Add check of the changeno_end variable for zero.

The parser of the --change argument already checks the revision
number for a zero and raises an error, because there are no changes.
However, if a range is given to this argument it would not check
its second part, and the command aborts.

Command to reproduce:
$ svn diff https://svn.apache.org/repos/asf -c 1-0

Adding the check of the changeno_end variable for zero will fix
the problem.

* subversion\svn\svn.c
  (sub_main): Add check of the changeno_end variable for zero.

* subversion\tests\cmdline\diff_tests.py
  (diff_invalid_change_arg): Add test case for a diff of change,
   done in revision range '1-0' and expect an error from it.

Found by: jun66j5

Patch by: Timofey Zhakov (tima {at} chemodax _dot_ net)

Modified:
    subversion/trunk/subversion/svn/svn.c
    subversion/trunk/subversion/tests/cmdline/diff_tests.py

Modified: subversion/trunk/subversion/svn/svn.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1917944&r1=1917943&r2=1917944&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Fri May 24 15:59:50 2024
@@ -2394,7 +2394,7 @@ sub_main(int *exit_code, int argc, const
                                              "given to -c"), change_str);
                 }
 
-              if (changeno == 0)
+              if (changeno == 0 || changeno_end == 0)
                 {
                   return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                                           _("There is no change 0"));

Modified: subversion/trunk/subversion/tests/cmdline/diff_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/diff_tests.py?rev=1917944&r1=1917943&r2=1917944&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/diff_tests.py Fri May 24 15:59:50 
2024
@@ -5360,6 +5360,11 @@ def diff_invalid_change_arg(sbox):
     (r'.*svn: E205000: Negative number in range \(r1-r-3\) not supported with 
-c'),
     'diff', sbox.wc_dir, '-c', 'r1-r-3')
 
+  svntest.actions.run_and_verify_svn(
+    None,
+    (r'.*svn: E205000: There is no change 0'),
+    'diff', sbox.wc_dir, '-c', '1-0')
+
 ########################################################################
 #Run the tests
 


Reply via email to