Author: philip
Date: Sun Jan 18 11:52:51 2015
New Revision: 1652744

URL: http://svn.apache.org/r1652744
Log:
* subversion/libsvn_client/patch.c
  (sort_matched_hunks): Followup to r1644599, really implement a total order.

Modified:
    subversion/trunk/subversion/libsvn_client/patch.c

Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=1652744&r1=1652743&r2=1652744&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Sun Jan 18 11:52:51 2015
@@ -2213,27 +2213,37 @@ sort_matched_hunks(const void *a, const
   const hunk_info_t *item2 = *((const hunk_info_t * const *)b);
   svn_boolean_t matched1 = !item1->rejected && !item1->already_applied;
   svn_boolean_t matched2 = !item2->rejected && !item2->already_applied;
+  svn_linenum_t original1, original2;
 
   if (matched1 && matched2)
     {
       /* Both match so use order matched in file. */
       if (item1->matched_line > item2->matched_line)
         return 1;
+      else if (item1->matched_line == item2->matched_line)
+        return 0;
+      else
+        return -1;
     }
   else if (matched2)
     /* Only second matches, put it before first. */
     return 1;
-  else
-    {
-      /* Neither matches, sort by original_start. */
-      if (svn_diff_hunk_get_original_start(item1->hunk)
-          > svn_diff_hunk_get_original_start(item2->hunk))
-        return 1;
-    }
+  else if (matched1)
+    /* Only first matches, put it before second. */
+    return -1;
 
-  return -1;
+  /* Neither matches, sort by original_start. */
+  original1 = svn_diff_hunk_get_original_start(item1->hunk);
+  original2 = svn_diff_hunk_get_original_start(item2->hunk);
+  if (original1 > original2)
+    return 1;
+  else if (original1 == original2)
+    return 0;
+  else
+    return -1;
 }
 
+
 /* Apply a PATCH to a working copy at ABS_WC_PATH and put the result
  * into temporary files, to be installed in the working copy later.
  * Return information about the patch target in *PATCH_TARGET, allocated


Reply via email to